diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 00000000..9d0b8cb2 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,55 @@ +unused_args = false +allow_defined_top = true +max_line_length = false +redefined = false + +globals = { + "minetest", "core", +} + +read_globals = { + "DIR_DELIM", + "dump", "dump2", + "vector", + "VoxelManip", "VoxelArea", + "PseudoRandom", "PcgRandom", "PerlinNoise", "PerlinNoiseMap", + "ItemStack", + "Settings", + "unpack", + + table = { + fields = { + "copy", + "indexof", + "insert_all", + "key_value_swap", + } + }, + + string = { + fields = { + "split", + "trim", + } + }, + + math = { + fields = { + "hypot", + "sign", + "factorial" + } + }, + ------ + --MODS + ------ + + --GENERAL + "default", + + --ENTITIES + "cmi", + + --HUD + "sfinv", "sfinv_buttons", "unified_inventory", "cmsg", "inventory_plus", +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f26ccafe..1b5098a4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ # Contributing to MineClone 2 -So you want to MineClone 2? +So you want to contribute to MineClone 2? Wow, thank you! :-) But first, some things to note: @@ -7,13 +7,11 @@ But first, some things to note: 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 ***. -MineClone 2 is maintained by two persons. Namely, kay27 and EliasFleckenstein. You can find us -in the Minetest forums (forums.minetest.net), in IRC in the #minetest +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 . -There is **no** guarantee we will accept anything from anybody. - 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. @@ -26,8 +24,7 @@ For small and medium changes: * Fork the repository * Do your change in a new branch -* Upload the repository somewhere where it can be accessed from the Internet and - notify us +* Create a pull request to get your changes merged into master For small changes, sending us a patch is also good. @@ -41,40 +38,52 @@ 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. -Contributors will be credited in `README.md`. +If your code causes bugs and crashes, it is your responsibility to fix them as soon as possible. -## Quality remarks -Again: There is ***no*** guarantee we will accept anything from anybody. -But we will gladly take in code from others when we feel it saves us work -in the long run. +We mostly use plain merging rather than rebasing or squash merging. -### Inclusion criteria -Depending on what you add, the chances for inclusion vary: +Your commit names should be relatively descriptive, e.g. when saying "Fix #issueid", the commit message should also contain the title of the issue. -### High chance for inclusion -* Gameplay features in Minecraft which are missing in MineClone 2 +Contributors will be credited in `CREDITS.md`. -### Medium chance for inclusion (discuss first) -* Features which don't a impact on gameplay -* GUI improvement -* Features from pocket or console edition +## Code Style -### Low chance for inclusion (discuss/optimize first) -* Overhaul of architecture / mod structure -* Mass-itemstring changes all over the place -* Added files have a unusual high file size -* Indentation looks like crazy -* Single commits which add several unrelated things -* Gameplay features which don't exist in Minecraft +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. -### Instant rejection -* Proprietary **anything** -* Code contains `minetest.env` anywhere +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 +``` -## Coding style guide -* Indentations should reflect the code flow -* Use tabs, not spaces for indentation (tab size = 8) -* Never use `minetest.env` + +## Features > 1.12 + +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. + +## What we accept + +* 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. + +## What we reject + +* 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. ## Reporting bugs Report all bugs and missing Minecraft features here: diff --git a/CREDITS.md b/CREDITS.md new file mode 100644 index 00000000..296e7c23 --- /dev/null +++ b/CREDITS.md @@ -0,0 +1,118 @@ +# Credits + +## Creator of MineClone +* davedevils + +## Creator of MineClone2 +* Wuzzy + +## Maintainers +* Fleckenstein +* kay27 +* jordan4ibanez + +## Developers +* bzoss +* AFCMS +* epCode +* ryvnf +* iliekprogrammar +* MysticTempest +* Rootyjr +* Nicu +* aligator +* Code-Sploit +* NO11 + +## Contributors +* 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 +* kay27 +* Debiankaios +* epCode +* NO11 +* j45 + +## Original Mod Authors +* Wuzzy +* Fleckenstein +* BlockMen +* TenPlus1 +* PilzAdam +* ryvnf +* stujones11 +* Arcelmi +* celeron55 +* maikerumine +* GunshipPenguin +* Qwertymine3 +* Rochambeau +* rubenwardy +* stu +* jordan4ibanez +* 4aiman +* Kahrl +* Krock +* UgnilJoZ +* lordfingle +* 22i +* bzoss +* kilbith +* xeranas +* kddekadenz +* sofar +* 4Evergreen4 +* jordan4ibanez +* paramat + +## 3D Models +* 22i +* tobyplowy +* epCode + +## Textures +* XSSheep +* Wuzzy +* kingoscargames +* leorockway +* xMrVizzy +* yutyo +* NO11 + +## Translations +* Wuzzy +* Rocher Laurent +* wuniversales +* kay27 +* pitchum + +## Special thanks +* 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/LEGAL.md b/LEGAL.md new file mode 100644 index 00000000..e54bdc41 --- /dev/null +++ b/LEGAL.md @@ -0,0 +1,52 @@ +# Legal information +This is a fan game, not developed or endorsed by Mojang AB. + +Copying is an act of love. Please copy and share! <3 +Here's the detailed legalese for those who need it: + +## License of source code +MineClone 2 (by kay27, EliasFleckenstein, Wuzzy, davedevils and countless others) +is an imitation of Minecraft. + +MineClone 2 is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License (in the LICENSE.txt file) for more +details. + +In the mods you might find in the read-me or license +text files a different license. This counts as dual-licensing. +You can choose which license applies to you: Either the +license of MineClone 2 (GNU GPLv3) or the mod's license. + +MineClone 2 is a direct continuation of the discontinued MineClone +project by davedevils. + +Mod credits: +See `README.txt` or `README.md` in each mod directory for information about other authors. +For mods that do not have such a file, the license is the source code license +of MineClone 2 and the author is Wuzzy. + +## License of media (textures and sounds) +No non-free licenses are used anywhere. + +The textures, unless otherwise noted, are based on the Pixel Perfection resource pack for Minecraft 1.11, +authored by XSSheep. Most textures are verbatim copies, while some textures have been changed or redone +from scratch. +The glazed terracotta textures have been created by (MysticTempest)[https://github.com/MysticTempest]. +Source: +License: [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/) + +The main menu images are release under: [CC0](https://creativecommons.org/publicdomain/zero/1.0/) + +All other files, unless mentioned otherwise, fall under: +Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +http://creativecommons.org/licenses/by-sa/3.0/ + +See README.txt in each mod directory for detailed information about other authors. + diff --git a/MISSING_ENGINE_FEATURES.md b/MISSING_ENGINE_FEATURES.md deleted file mode 100644 index fddb89f6..00000000 --- a/MISSING_ENGINE_FEATURES.md +++ /dev/null @@ -1,40 +0,0 @@ -# Missing features in Minetest to recreate Minecraft features - -A side goal of the MineClone 2 project is to find any shortcomings of Minetest which make it impossible to recreate a Minecraft feature exactly. -This file lists some of the missing features in Minetest which MineClone 2 would require. - -## No workaround possible -For these features, no easy Lua workaround could be found. - -### Lua API -#### Tools/wielded item -- “Lock” hotbar for a brief time after using an item, making it impossible to switch item or to attach/mine/build until the delay is over (For eating with delay) -- Tool charging: Holding down the mouse and releasing it, applying a “power level” (For bow and arrows, more charge = higher arrow range) ([issue 5212](https://github.com/minetest/minetest/issues/5212)) -- [Dual Wielding](http://minecraft.gamepedia.com/Dual_wield) -- Eating/drinking animation ([issue 2811](https://github.com/minetest/minetest/issues/2811)) - -#### Nodes -- Light level 15 for nodes (not sunlight) -- Nodes makes light level drop by 2 or or more per node ([issue 5209](https://github.com/minetest/minetest/issues/5209)) - -## Interface -- Inventory: Hold down right mouse button while holding an item stack to drop items into the slots as you move the mouse. Makes crafting MUCH faster -- Sneak+Leftclick on crafting output crafts as many items as possible and immediately puts it into the player inventory ([issue 5211](https://github.com/minetest/minetest/issues/5211)) -- Sneak+click puts items in different inventories depending on the item type (maybe group-based)? Required for sneak-clicking to armor slots - -## Workaround theoretically possible -For these features, a workaround (or hack ;-)) by using Lua is theoretically possible. But engine support would be clearly better, more performant, more reliable, etc. - -### Lua API -#### Nodes -- Change walking speed on block (soul sand) -- Change jumping height on block (soul sand), -- Change object movement speed *through* a block, but for non-liquids (for cobweb) -- Add `on_walk_over` event -- Set frequency in which players lose breath. 2 seconds are hardcoded in Minetest, in Minecraft it's 1 second -- Set damage frequency of `damage_per_second`. In Minecraft many things damage players every half-second rather than every second -- Possible to damage players directly when they are with the head inside. This allows to add Minecraft-like suffocation -- Sneak+click on inventory slot should be able to put items into additional “fallback inventories” if the first inventory is full. Useful for large chests - -#### Nice-to-haye -- Utility function to rotate pillar-like nodes, requiring only 3 possible orientations (X, Y, Z). Basically this is `minetest.rotate_node` but with less orientations; the purpur pillar would mess up if a mirrored rotation would be possible. This is already implemented in MCL2, See `mcl_util` for more infos diff --git a/README.md b/README.md index 302c188f..ca4d0195 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ +# (Currently in feature freeze) + # MineClone 2 An unofficial Minecraft-like game for Minetest. Forked from MineClone by davedevils. Developed by many people. Not developed or endorsed by Mojang AB. -Version: 0.71.0 +Version: 0.72.0 (in development) ### Gameplay You start in a randomly-generated world made entirely of cubes. You can explore @@ -65,16 +67,8 @@ map builders. They can not be obtained in-game or in the creative inventory. Use the `/giveme` chat command to obtain them. See the in-game help for an explanation. -#### Incomplete items -These items do not work yet, but you can get them with `/giveme` for testing: - -* Minecart with Chest: `mcl_minecarts:chest_minecart` -* Minecart with Furnace: `mcl_minecarts:furnace_minecart` -* Minecart with Hopper: `mcl_minecarts:hopper_minecart` -* Minecart with Command Block: `mcl_minecarts:command_block_minecart` - ## Installation -This game requires [Minetest](http://minetest.net) to run (version 5.0.0 or +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. @@ -83,23 +77,37 @@ To install MineClone 2 (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: + + + +## Chating 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 -* Features of later Minecraft versions might sneak in, but they have a low priority -* In general, Minecraft is aimed to be cloned as good as Minetest currently permits (no hacks) +* In general, Minecraft is aimed to be cloned as good as possible * Cloning the gameplay has highest priority -* MineClone 2 will use different graphics and sounds, but with a similar style -* Cloning the interface has no priority. It will only be roughly imitated -* Limitations found in Minetest will be written down and reported in the course of development +* 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 ## Completion status -This game is currently in **alpha** stage. -It is playable, but unfinished, many bugs are to be expected. -Backwards-compability is *not* guaranteed, updating your world might cause small and -big bugs (such as “missing node” errors or even crashes). +This game is currently in **beta** stage. +It is playable, but not yet feature-complete. +Backwards-compability is not entirely guaranteed, updating your world might cause small bugs. +If you want to use the git version of MineClone2 in production, consider using the production branch. +It is updated weekly and contains relatively stable code for servers. The following main features are available: @@ -128,7 +136,7 @@ The following main features are available: * Clock * Compass * Sponge -* Slime block (does not interact with redstone) +* Slime block * Small plants and saplings * Dyes * Banners @@ -140,19 +148,19 @@ The following main features are available: * Creative inventory * Farming * Writable books -* A few server commands +* Commands +* Villages +* The End * And more! The following features are incomplete: -* Generated structures (especially villages) * Some monsters and animals * Redstone-related things -* The End * Special minecarts * A couple of non-trivial blocks and items -Bonus features (not found in Minecraft 1.11): +Bonus features (not found in Minecraft 1.12): * Built-in crafting guide which shows you crafting and smelting recipes * In-game help system containing extensive help about gameplay basics, blocks, items and more @@ -177,148 +185,14 @@ Technical differences from Minecraft: * Different textures (Pixel Perfection) * Different sounds (various sources) * Different engine (Minetest) +* Different easter eggs … and finally, MineClone 2 is free software (“free” as in “freedom”)! -## Reporting bugs -Please report all bugs and missing Minecraft features here: - - - -## Chating with the community -Join our discord server at: - - - ## Other readme files * `LICENSE.txt`: The GPLv3 license text * `CONTRIBUTING.md`: Information for those who want to contribute -* `MISSING_ENGINE_FEATURES.md`: List of missing features in Minetest which MineClone 2 would need for improvement * `API.md`: For Minetest modders who want to mod this game - -## Credits -There are so many people to list (sorry). Check out the respective mod directories for details. This section is only a rough overview of the core authors of this game. - -### Coding -* [Wuzzy](https://forum.minetest.net/memberlist.php?mode=viewprofile&u=3082): Main programmer of most mods (retired) -* davedevils: Creator of MineClone on which MineClone 2 is based on -* [ex-bart](https://github.com/ex-bart): Redstone comparators -* [Rootyjr](https://github.com/Rootyjr): Fishing rod and bugfixes -* [aligator](https://github.com/aligator): Improvement of doors -* [ryvnf](https://github.com/ryvnf): Explosion mechanics -* MysticTempest: Bugfixes -* [bzoss](https://github.com/bzoss): Status effects, potions, brewing stand -* kay27 : Experience system, bugfixes, optimizations (Current maintainer) -* [EliasFleckenstein03](https://github.com/EliasFleckenstein03): End crystals, enchanting, burning mobs / players, animated chests, bugfixes (Current maintainer) -* epCode: Better player animations, new logo -* 2mac: Fix bug with powered rail -* Lots of other people: TO BE WRITTEN (see mod directories for details) - -#### Mod credits (summary) - -* `controls`: Arcelmi -* `flowlib`: Qwertymine13 -* `walkover`: lordfingle -* `drippingwater`: kddekadenz -* `mobs_mc`: maikerumine, 22i and others -* `awards`: rubenwardy -* `screwdriver`: RealBadAngel, Maciej Kastakin, Minetest contributors -* `xpanes`: Minetest contributors -* `mesecons` mods: Jeija and contributors -* `wieldview`: Stuart Jones -* `mcl_meshhand`: Based on `newhand` by jordan4ibanez -* `mcl_mobs`: Based on Mobs Redo [`mobs`] by TenPlus1 and contributors -* Most other mods: Wuzzy - -Detailed credits for each mod can be found in the individual mod directories. - -### Graphics -* [XSSheep](http://www.minecraftforum.net/members/XSSheep): Main author; creator of the Pixel Perfection resource pack of Minecraft 1.11 -* [Wuzzy](https://forum.minetest.net/memberlist.php?mode=viewprofile&u=3082): Main menu imagery and various edits and additions of texture pack -* [kingoscargames](https://github.com/kingoscargames): Various edits and additions of existing textures -* [leorockway](https://github.com/leorockway): Some edits of mob textures -* [xMrVizzy](https://minecraft.curseforge.com/members/xMrVizzy): Glazed terracotta (textures are subject to be replaced later) -* yutyo : MineClone 2 logo -* Other authors: GUI images - -### Translations -* Wuzzy: German -* Rocher Laurent : French -* wuniversales: Spanish -* kay27 : Russian - -### Models -* [22i](https://github.com/22i): Creator of all models -* [tobyplowy](https://github.com/tobyplowy): UV-mapping fixes to said models - -### Sounds and music -Various sources. See the respective mod directories for details. - -### Special thanks - -* davedevils for starting MineClone, the original version of this game -* Wuzzy for starting and maintaining MineClone2 for several years -* celeron55 for creating Minetest -* Minetest's modding community for providing a huge selection of mods, some of which ended up in MineClone 2 -* 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 -* XSSheep for creating the Pixel Perfection resource pack -* [22i](https://github.com/22i) for providing great models and support -* [maikerumine](http://github.com/maikerumine) for kicking off mobs and biomes - -## Info for programmers -You find interesting and useful infos in `API.md`. - -## Legal information -This is a fan game, not developed or endorsed by Mojang AB. - -Copying is an act of love. Please copy and share! <3 -Here's the detailed legalese for those who need it: - -### License of source code -MineClone 2 (by kay27, EliasFleckenstein, Wuzzy, davedevils and countless others) -is an imitation of Minecraft. - -MineClone 2 is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License (in the LICENSE.txt file) for more -details. - -In the mods you might find in the read-me or license -text files a different license. This counts as dual-licensing. -You can choose which license applies to you: Either the -license of MineClone 2 (GNU GPLv3) or the mod's license. - -MineClone 2 is a direct continuation of the discontinued MineClone -project by davedevils. - -Mod credits: -See `README.txt` or `README.md` in each mod directory for information about other authors. -For mods that do not have such a file, the license is the source code license -of MineClone 2 and the author is Wuzzy. - -### License of media (textures and sounds) -No non-free licenses are used anywhere. - -The textures, unless otherwise noted, are based on the Pixel Perfection resource pack for Minecraft 1.11, -authored by XSSheep. Most textures are verbatim copies, while some textures have been changed or redone -from scratch. -The glazed terracotta textures have been created by (MysticTempest)[https://github.com/MysticTempest]. -Source: -License: [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/) - -The main menu images are release under: [CC0](https://creativecommons.org/publicdomain/zero/1.0/) - -All other files, unless mentioned otherwise, fall under: -Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) -http://creativecommons.org/licenses/by-sa/3.0/ - -See README.txt in each mod directory for detailed information about other authors. +* `LEGAL.md`: Legal information +* `CREDITS.md`: List of everyone who contributed diff --git a/menu/Header.blend b/menu/Header.blend new file mode 100644 index 00000000..78a9f615 Binary files /dev/null and b/menu/Header.blend differ diff --git a/mods/CORE/_mcl_autogroup/init.lua b/mods/CORE/_mcl_autogroup/init.lua index c8475d0b..ba8b659c 100644 --- a/mods/CORE/_mcl_autogroup/init.lua +++ b/mods/CORE/_mcl_autogroup/init.lua @@ -83,7 +83,7 @@ local function get_hardness_values_for_groups() for _, ndef in pairs(minetest.registered_nodes) do for g, _ in pairs(mcl_autogroup.registered_diggroups) do - if ndef.groups[g] ~= nil then + if ndef.groups[g] then maps[g][ndef._mcl_hardness or 0] = true end end @@ -121,7 +121,7 @@ local hardness_values = get_hardness_values_for_groups() -- hardness_value. Used for quick lookup. local hardness_lookup = get_hardness_lookup_for_groups(hardness_values) -local function compute_creativetimes(group) +--[[local function compute_creativetimes(group) local creativetimes = {} for index, hardness in pairs(hardness_values[group]) do @@ -129,7 +129,7 @@ local function compute_creativetimes(group) end return creativetimes -end +end]] -- Get the list of digging times for using a specific tool on a specific -- diggroup. @@ -239,13 +239,13 @@ function mcl_autogroup.can_harvest(nodename, toolname) end -- Get one groupcap field for using a specific tool on a specific group. -local function get_groupcap(group, can_harvest, multiplier, efficiency, uses) +--[[local function get_groupcap(group, can_harvest, multiplier, efficiency, uses) return { times = get_digtimes(group, can_harvest, multiplier, efficiency), uses = uses, maxlevel = 0, } -end +end]] -- Returns the tool_capabilities from a tool definition or a default set of -- tool_capabilities @@ -271,7 +271,7 @@ end -- toolname - Name of the tool being enchanted (like "mcl_tools:diamond_pickaxe") -- efficiency - The efficiency level the tool is enchanted with (default 0) -- --- NOTE: +-- NOTE: -- This function can only be called after mod initialization. Otherwise a mod -- would have to add _mcl_autogroup as a dependency which would break the mod -- loading order. @@ -288,7 +288,7 @@ end -- toolname - Name of the tool used -- diggroup - The name of the diggroup the tool is used on -- --- NOTE: +-- NOTE: -- This function can only be called after mod initialization. Otherwise a mod -- would have to add _mcl_autogroup as a dependency which would break the mod -- loading order. @@ -298,7 +298,7 @@ function mcl_autogroup.get_wear(toolname, diggroup) return math.ceil(65535 / uses) end -local overwrite = function() +local function overwrite() for nname, ndef in pairs(minetest.registered_nodes) do local newgroups = table.copy(ndef.groups) if (nname ~= "ignore" and ndef.diggable) then @@ -315,12 +315,12 @@ local overwrite = function() newgroups.opaque = 1 end - local creative_breakable = false + --local creative_breakable = false -- Assign groups used for digging this node depending on -- the registered digging groups for g, gdef in pairs(mcl_autogroup.registered_diggroups) do - creative_breakable = true + --creative_breakable = true local index = hardness_lookup[g][ndef._mcl_hardness or 0] if ndef.groups[g] then if gdef.levels then diff --git a/mods/CORE/biomeinfo/init.lua b/mods/CORE/biomeinfo/init.lua index 5013647e..950925f9 100644 --- a/mods/CORE/biomeinfo/init.lua +++ b/mods/CORE/biomeinfo/init.lua @@ -81,11 +81,11 @@ if v6_use_snow_biomes then end local v6_freq_desert = tonumber(minetest.get_mapgen_setting("mgv6_freq_desert") or 0.45) -local NOISE_MAGIC_X = 1619 -local NOISE_MAGIC_Y = 31337 -local NOISE_MAGIC_Z = 52591 -local NOISE_MAGIC_SEED = 1013 -local noise2d = function(x, y, seed) +--local NOISE_MAGIC_X = 1619 +--local NOISE_MAGIC_Y = 31337 +--local NOISE_MAGIC_Z = 52591 +--local NOISE_MAGIC_SEED = 1013 +local function noise2d(x, y, seed) -- TODO: implement noise2d function for biome blend return 0 --[[ diff --git a/mods/CORE/controls/init.lua b/mods/CORE/controls/init.lua index 2ceb7e90..ef57281a 100644 --- a/mods/CORE/controls/init.lua +++ b/mods/CORE/controls/init.lua @@ -1,6 +1,8 @@ local get_connected_players = minetest.get_connected_players local clock = os.clock +local pairs = pairs + controls = {} controls.players = {} @@ -20,15 +22,15 @@ function controls.register_on_hold(func) end local known_controls = { - jump=true, - right=true, - left=true, - LMB=true, - RMB=true, - sneak=true, - aux1=true, - down=true, - up=true, + jump = true, + right = true, + left = true, + LMB = true, + RMB = true, + sneak = true, + aux1 = true, + down = true, + up = true, } minetest.register_on_joinplayer(function(player) @@ -49,27 +51,27 @@ minetest.register_globalstep(function(dtime) local player_name = player:get_player_name() local player_controls = player:get_player_control() if controls.players[player_name] then - for cname, cbool in pairs(player_controls) do - if known_controls[cname] == true then - --Press a key - if cbool==true and controls.players[player_name][cname][1]==false then - for _, func in pairs(controls.registered_on_press) do - func(player, cname) + for cname, cbool in pairs(player_controls) do + if known_controls[cname] == true then + --Press a key + if cbool == true and controls.players[player_name][cname][1] == false then + for _, func in pairs(controls.registered_on_press) do + func(player, cname) + end + controls.players[player_name][cname] = {true, clock()} + elseif cbool == true and controls.players[player_name][cname][1] == true then + for _, func in pairs(controls.registered_on_hold) do + func(player, cname, clock()-controls.players[player_name][cname][2]) + end + --Release a key + elseif cbool == false and controls.players[player_name][cname][1] == true then + for _, func in pairs(controls.registered_on_release) do + func(player, cname, clock()-controls.players[player_name][cname][2]) + end + controls.players[player_name][cname] = {false} + end end - controls.players[player_name][cname] = {true, clock()} - elseif cbool==true and controls.players[player_name][cname][1]==true then - for _, func in pairs(controls.registered_on_hold) do - func(player, cname, clock()-controls.players[player_name][cname][2]) - end - --Release a key - elseif cbool==false and controls.players[player_name][cname][1]==true then - for _, func in pairs(controls.registered_on_release) do - func(player, cname, clock()-controls.players[player_name][cname][2]) - end - controls.players[player_name][cname] = {false} end end - end - end end end) diff --git a/mods/CORE/flowlib/init.lua b/mods/CORE/flowlib/init.lua index e4e22a20..ab710e47 100644 --- a/mods/CORE/flowlib/init.lua +++ b/mods/CORE/flowlib/init.lua @@ -1,95 +1,100 @@ +local math = math + +local get_node = minetest.get_node +local get_item_group = minetest.get_item_group + +local registered_nodes = minetest.registered_nodes + flowlib = {} --sum of direction vectors must match an array index + +--(sum,root) +--(0,1), (1,1+0=1), (2,1+1=2), (3,1+2^2=5), (4,2^2+2^2=8) + +local inv_roots = { + [0] = 1, + [1] = 1, + [2] = 0.70710678118655, + [4] = 0.5, + [5] = 0.44721359549996, + [8] = 0.35355339059327, +} + local function to_unit_vector(dir_vector) - --(sum,root) - -- (0,1), (1,1+0=1), (2,1+1=2), (3,1+2^2=5), (4,2^2+2^2=8) - local inv_roots = {[0] = 1, [1] = 1, [2] = 0.70710678118655, [4] = 0.5 - , [5] = 0.44721359549996, [8] = 0.35355339059327} - local sum = dir_vector.x*dir_vector.x + dir_vector.z*dir_vector.z - return {x=dir_vector.x*inv_roots[sum],y=dir_vector.y - ,z=dir_vector.z*inv_roots[sum]} + local sum = dir_vector.x * dir_vector.x + dir_vector.z * dir_vector.z + return {x = dir_vector.x * inv_roots[sum], y = dir_vector.y, z = dir_vector.z * inv_roots[sum]} end -local is_touching = function(realpos,nodepos,radius) +local function is_touching(realpos,nodepos,radius) local boarder = 0.5 - radius - return (math.abs(realpos - nodepos) > (boarder)) + return math.abs(realpos - nodepos) > (boarder) end flowlib.is_touching = is_touching -local is_water = function(pos) - return (minetest.get_item_group(minetest.get_node( - {x=pos.x,y=pos.y,z=pos.z}).name - , "water") ~= 0) +local function is_water(pos) + return get_item_group(get_node(pos).name, "water") ~= 0 end flowlib.is_water = is_water -local node_is_water = function(node) - return (minetest.get_item_group(node.name, "water") ~= 0) +local function node_is_water(node) + return get_item_group(node.name, "water") ~= 0 end flowlib.node_is_water = node_is_water -local is_lava = function(pos) - return (minetest.get_item_group(minetest.get_node( - {x=pos.x,y=pos.y,z=pos.z}).name - , "lava") ~= 0) +local function is_lava(pos) + return get_item_group(get_node(pos).name, "lava") ~= 0 end flowlib.is_lava = is_lava -local node_is_lava = function(node) - return (minetest.get_item_group(node.name, "lava") ~= 0) +local function node_is_lava(node) + return get_item_group(node.name, "lava") ~= 0 end flowlib.node_is_lava = node_is_lava -local is_liquid = function(pos) - return (minetest.get_item_group(minetest.get_node( - {x=pos.x,y=pos.y,z=pos.z}).name - , "liquid") ~= 0) +local function is_liquid(pos) + return get_item_group(get_node(pos).name, "liquid") ~= 0 end flowlib.is_liquid = is_liquid -local node_is_liquid = function(node) - return (minetest.get_item_group(node.name, "liquid") ~= 0) +local function node_is_liquid(node) + return minetest.get_item_group(node.name, "liquid") ~= 0 end flowlib.node_is_liquid = node_is_liquid --This code is more efficient -local function quick_flow_logic(node,pos_testing,direction) +local function quick_flow_logic(node, pos_testing, direction) local name = node.name - if not minetest.registered_nodes[name] then + if not registered_nodes[name] then return 0 end - if minetest.registered_nodes[name].liquidtype == "source" then - local node_testing = minetest.get_node(pos_testing) - local param2_testing = node_testing.param2 - if not minetest.registered_nodes[node_testing.name] then + if registered_nodes[name].liquidtype == "source" then + local node_testing = get_node(pos_testing) + if not registered_nodes[node_testing.name] then return 0 end - if minetest.registered_nodes[node_testing.name].liquidtype - ~= "flowing" then + if registered_nodes[node_testing.name].liquidtype ~= "flowing" then return 0 else return direction end - elseif minetest.registered_nodes[name].liquidtype == "flowing" then - local node_testing = minetest.get_node(pos_testing) + elseif registered_nodes[name].liquidtype == "flowing" then + local node_testing = get_node(pos_testing) local param2_testing = node_testing.param2 - if not minetest.registered_nodes[node_testing.name] then + if not registered_nodes[node_testing.name] then return 0 end - if minetest.registered_nodes[node_testing.name].liquidtype - == "source" then + if registered_nodes[node_testing.name].liquidtype == "source" then return -direction - elseif minetest.registered_nodes[node_testing.name].liquidtype - == "flowing" then + elseif registered_nodes[node_testing.name].liquidtype == "flowing" then if param2_testing < node.param2 then if (node.param2 - param2_testing) > 6 then return -direction @@ -108,48 +113,41 @@ local function quick_flow_logic(node,pos_testing,direction) return 0 end -local quick_flow = function(pos,node) - local x = 0 - local z = 0 - +local function quick_flow(pos, node) if not node_is_liquid(node) then - return {x=0,y=0,z=0} + return {x = 0, y = 0, z = 0} end - - x = x + quick_flow_logic(node,{x=pos.x-1,y=pos.y,z=pos.z},-1) - x = x + quick_flow_logic(node,{x=pos.x+1,y=pos.y,z=pos.z}, 1) - z = z + quick_flow_logic(node,{x=pos.x,y=pos.y,z=pos.z-1},-1) - z = z + quick_flow_logic(node,{x=pos.x,y=pos.y,z=pos.z+1}, 1) - - return to_unit_vector({x=x,y=0,z=z}) + local x = quick_flow_logic(node,{x = pos.x-1, y = pos.y, z = pos.z},-1) + quick_flow_logic(node,{x = pos.x+1, y = pos.y, z = pos.z}, 1) + local z = quick_flow_logic(node,{x = pos.x, y = pos.y, z = pos.z-1},-1) + quick_flow_logic(node,{x = pos.x, y = pos.y, z = pos.z+1}, 1) + return to_unit_vector({x = x, y = 0, z = z}) end flowlib.quick_flow = quick_flow +--if not in water but touching, move centre to touching block +--x has higher precedence than z +--if pos changes with x, it affects z - --if not in water but touching, move centre to touching block - --x has higher precedence than z - --if pos changes with x, it affects z -local move_centre = function(pos,realpos,node,radius) - if is_touching(realpos.x,pos.x,radius) then - if is_liquid({x=pos.x-1,y=pos.y,z=pos.z}) then - node = minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}) - pos = {x=pos.x-1,y=pos.y,z=pos.z} - elseif is_liquid({x=pos.x+1,y=pos.y,z=pos.z}) then - node = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}) - pos = {x=pos.x+1,y=pos.y,z=pos.z} +local function move_centre(pos, realpos, node, radius) + if is_touching(realpos.x, pos.x, radius) then + if is_liquid({x = pos.x-1, y = pos.y, z = pos.z}) then + node = get_node({x=pos.x-1, y = pos.y, z = pos.z}) + pos = {x = pos.x-1, y = pos.y, z = pos.z} + elseif is_liquid({x = pos.x+1, y = pos.y, z = pos.z}) then + node = get_node({x = pos.x+1, y = pos.y, z = pos.z}) + pos = {x = pos.x+1, y = pos.y, z = pos.z} end end - if is_touching(realpos.z,pos.z,radius) then - if is_liquid({x=pos.x,y=pos.y,z=pos.z-1}) then - node = minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}) - pos = {x=pos.x,y=pos.y,z=pos.z-1} - elseif is_liquid({x=pos.x,y=pos.y,z=pos.z+1}) then - node = minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}) - pos = {x=pos.x,y=pos.y,z=pos.z+1} + if is_touching(realpos.z, pos.z, radius) then + if is_liquid({x = pos.x, y = pos.y, z = pos.z - 1}) then + node = get_node({x = pos.x, y = pos.y, z = pos.z - 1}) + pos = {x = pos.x, y = pos.y, z = pos.z - 1} + elseif is_liquid({x = pos.x, y = pos.y, z = pos.z + 1}) then + node = get_node({x = pos.x, y = pos.y, z = pos.z + 1}) + pos = {x = pos.x, y = pos.y, z = pos.z + 1} end end - return pos,node + return pos, node end flowlib.move_centre = move_centre diff --git a/mods/CORE/mcl_attached/init.lua b/mods/CORE/mcl_attached/init.lua index 146cb225..4f538e10 100644 --- a/mods/CORE/mcl_attached/init.lua +++ b/mods/CORE/mcl_attached/init.lua @@ -1,17 +1,21 @@ +local vector = vector + +local facedir_to_dir = minetest.facedir_to_dir +local get_item_group = minetest.get_item_group +local remove_node = minetest.remove_node +local get_node = minetest.get_node + local original_function = minetest.check_single_for_falling -minetest.check_single_for_falling = function(pos) +function minetest.check_single_for_falling(pos) local ret_o = original_function(pos) - local ret = false local node = minetest.get_node(pos) - if minetest.get_item_group(node.name, "attached_node_facedir") ~= 0 then - local dir = minetest.facedir_to_dir(node.param2) + if get_item_group(node.name, "attached_node_facedir") ~= 0 then + local dir = facedir_to_dir(node.param2) if dir then - local cpos = vector.add(pos, dir) - local cnode = minetest.get_node(cpos) - if minetest.get_item_group(cnode.name, "solid") == 0 then - minetest.remove_node(pos) + if get_item_group(get_node(vector.add(pos, dir)).name, "solid") == 0 then + remove_node(pos) local drops = minetest.get_node_drops(node.name, "") for dr=1, #drops do minetest.add_item(pos, drops[dr]) @@ -20,7 +24,6 @@ minetest.check_single_for_falling = function(pos) end end end - return ret_o or ret end diff --git a/mods/CORE/mcl_damage/init.lua b/mods/CORE/mcl_damage/init.lua new file mode 100644 index 00000000..8b2acbb3 --- /dev/null +++ b/mods/CORE/mcl_damage/init.lua @@ -0,0 +1,169 @@ +mcl_damage = { + modifiers = {}, + damage_callbacks = {}, + death_callbacks = {}, + types = { + in_fire = {is_fire = true}, + lightning_bolt = {is_lightning = true}, + on_fire = {is_fire = true, bypasses_armor = true}, + lava = {is_fire = true}, + hot_floor = {is_fire = true}, + in_wall = {bypasses_armor = true}, + drown = {bypasses_armor = true}, + starve = {bypasses_armor = true, bypasses_magic = true}, + cactus = {}, + fall = {bypasses_armor = true}, + fly_into_wall = {bypasses_armor = true}, -- unused + out_of_world = {bypasses_armor = true, bypasses_magic = true, bypasses_invulnerability = true}, + generic = {bypasses_armor = true}, + magic = {is_magic = true, bypasses_armor = true}, + dragon_breath = {is_magic = true, bypasses_armor = true}, -- this is only used for dragon fireball; dragon fireball does not actually deal impact damage tho, so this is unreachable + wither = {bypasses_armor = true}, -- unused + wither_skull = {is_magic = true, is_explosion = true}, -- this is non-MC but a workaround to get the proper death message + anvil = {}, + falling_node = {}, -- this is falling_block in MC + mob = {}, + player = {}, + arrow = {is_projectile = true}, + fireball = {is_projectile = true, is_fire = true}, + thorns = {is_magic = true}, + explosion = {is_explosion = true}, + cramming = {bypasses_armor = true}, -- unused + fireworks = {is_explosion = true}, -- unused + } +} + +function mcl_damage.register_modifier(func, priority) + table.insert(mcl_damage.modifiers, {func = func, priority = priority or 0}) +end + +function mcl_damage.register_on_damage(func) + table.insert(mcl_damage.damage_callbacks, func) +end + +function mcl_damage.register_on_death(func) + table.insert(mcl_damage.death_callbacks, func) +end + +function mcl_damage.run_modifiers(obj, damage, reason) + for _, modf in ipairs(mcl_damage.modifiers) do + damage = modf.func(obj, damage, reason) or damage + if damage == 0 then + return 0 + end + end + + return damage +end + +local function run_callbacks(funcs, ...) + for _, func in pairs(funcs) do + func(...) + end +end + +function mcl_damage.run_damage_callbacks(obj, damage, reason) + run_callbacks(mcl_damage.damage_callbacks, obj, damage, reason) +end + +function mcl_damage.run_death_callbacks(obj, reason) + run_callbacks(mcl_damage.death_callbacks, obj, reason) +end + +function mcl_damage.from_punch(mcl_reason, object) + mcl_reason.direct = object + local luaentity = mcl_reason.direct:get_luaentity() + if luaentity then + if luaentity._is_arrow then + mcl_reason.type = "arrow" + elseif luaentity._is_fireball then + mcl_reason.type = "fireball" + elseif luaentity._cmi_is_mob then + mcl_reason.type = "mob" + end + mcl_reason.source = mcl_reason.source or luaentity._source_object + else + mcl_reason.type = "player" + end +end + +function mcl_damage.finish_reason(mcl_reason) + mcl_reason.source = mcl_reason.source or mcl_reason.direct + mcl_reason.flags = mcl_damage.types[mcl_reason.type] +end + +function mcl_damage.from_mt(mt_reason) + if mt_reason._mcl_chached_reason then + return mt_reason._mcl_chached_reason + end + + local mcl_reason + + if mt_reason._mcl_reason then + mcl_reason = mt_reason._mcl_reason + else + mcl_reason = {type = "generic"} + + if mt_reason._mcl_type then + mcl_reason.type = mt_reason._mcl_type + elseif mt_reason.type == "fall" then + mcl_reason.type = "fall" + elseif mt_reason.type == "drown" then + mcl_reason.type = "drown" + elseif mt_reason.type == "punch" then + mcl_damage.from_punch(mcl_reason, mt_reason.object) + elseif mt_reason.type == "node_damage" and mt_reason.node then + if minetest.get_item_group(mt_reason.node, "fire") > 0 then + mcl_reason.type = "in_fire" + end + if minetest.get_item_group(mt_reason.node, "lava") > 0 then + mcl_reason.type = "lava" + end + end + + for key, value in pairs(mt_reason) do + if key:find("_mcl_") == 1 then + mcl_reason[key:sub(6, #key)] = value + end + end + end + + mcl_damage.finish_reason(mcl_reason) + mt_reason._mcl_cached_reason = mcl_reason + + return mcl_reason +end + +function mcl_damage.register_type(name, def) + mcl_damage.types[name] = def +end + +minetest.register_on_player_hpchange(function(player, hp_change, mt_reason) + if hp_change < 0 then + if player:get_hp() <= 0 then + return 0 + end + hp_change = -mcl_damage.run_modifiers(player, -hp_change, mcl_damage.from_mt(mt_reason)) + end + return hp_change +end, true) + +minetest.register_on_player_hpchange(function(player, hp_change, mt_reason) + if player:get_hp() > 0 then + mt_reason.approved = true + if hp_change < 0 then + mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason)) + end + end +end, false) + +minetest.register_on_dieplayer(function(player, mt_reason) + if mt_reason.approved then + mcl_damage.run_death_callbacks(player, mcl_damage.from_mt(mt_reason)) + end +end) + +minetest.register_on_mods_loaded(function() + table.sort(mcl_damage.modifiers, function(a, b) return a.priority < b.priority end) +end) + diff --git a/mods/CORE/mcl_damage/mod.conf b/mods/CORE/mcl_damage/mod.conf new file mode 100644 index 00000000..c7d96395 --- /dev/null +++ b/mods/CORE/mcl_damage/mod.conf @@ -0,0 +1,3 @@ +name = mcl_damage +author = Fleckenstein +description = Minecraft-like damage reason system diff --git a/mods/CORE/mcl_explosions/init.lua b/mods/CORE/mcl_explosions/init.lua index 34375248..0132d166 100644 --- a/mods/CORE/mcl_explosions/init.lua +++ b/mods/CORE/mcl_explosions/init.lua @@ -12,11 +12,12 @@ under the LGPLv2.1 license. mcl_explosions = {} -local mod_death_messages = minetest.get_modpath("mcl_death_messages") ~= nil -local mod_fire = minetest.get_modpath("mcl_fire") ~= nil -local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire") +local mod_fire = minetest.get_modpath("mcl_fire") +--local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire") -local S = minetest.get_translator("mcl_explosions") +local math = math +local vector = vector +local table = table local hash_node_position = minetest.hash_node_position local get_objects_inside_radius = minetest.get_objects_inside_radius @@ -27,6 +28,7 @@ local get_voxel_manip = minetest.get_voxel_manip local bulk_set_node = minetest.bulk_set_node local check_for_falling = minetest.check_for_falling local add_item = minetest.add_item +local pos_to_string = minetest.pos_to_string -- Saved sphere explosion shapes for various radiuses local sphere_shapes = {} @@ -67,46 +69,44 @@ local function compute_sphere_rays(radius) local rays = {} local sphere = {} - for i=1, 2 do + local function add_ray(pos) + sphere[hash_node_position(pos)] = pos + end + + for y = -radius, radius do + for z = -radius, radius do + for x = -radius, 0 do + local d = x * x + y * y + z * z + if d <= radius * radius then + add_ray(vector.new(x, y, z)) + add_ray(vector.new(-x, y, z)) + break + end + end + end + end + + for x = -radius, radius do + for z = -radius, radius do + for y = -radius, 0 do + local d = x * x + y * y + z * z + if d <= radius * radius then + add_ray(vector.new(x, y, z)) + add_ray(vector.new(x, -y, z)) + break + end + end + end + end + + for x = -radius, radius do for y = -radius, radius do - for z = -radius, radius do - for x = -radius, 0, 1 do - local d = x * x + y * y + z * z - if d <= radius * radius then - local pos = { x = x, y = y, z = z } - sphere[hash_node_position(pos)] = pos - break - end - end - end - end - end - - for i=1,2 do - for x = -radius, radius do - for z = -radius, radius do - for y = -radius, 0, 1 do - local d = x * x + y * y + z * z - if d <= radius * radius then - local pos = { x = x, y = y, z = z } - sphere[hash_node_position(pos)] = pos - break - end - end - end - end - end - - for i=1,2 do - for x = -radius, radius do - for y = -radius, radius do - for z = -radius, 0, 1 do - local d = x * x + y * y + z * z - if d <= radius * radius then - local pos = { x = x, y = y, z = z } - sphere[hash_node_position(pos)] = pos - break - end + for z = -radius, 0 do + local d = x * x + y * y + z * z + if d <= radius * radius then + add_ray(vector.new(x, y, z)) + add_ray(vector.new(x, y, -z)) + break end end end @@ -150,7 +150,8 @@ end -- raydirs - The directions for each ray -- radius - The maximum distance each ray will go -- info - Table containing information about explosion --- puncher - object that punches other objects (optional) +-- direct - direct source object of the damage (optional) +-- source - indirect source object of the damage (optional) -- -- Values in info: -- drop_chance - The chance that destroyed nodes will drop their items @@ -165,7 +166,7 @@ end -- Note that this function has been optimized, it contains code which has been -- inlined to avoid function calls and unnecessary table creation. This was -- measured to give a significant performance increase. -local function trace_explode(pos, strength, raydirs, radius, info, puncher) +local function trace_explode(pos, strength, raydirs, radius, info, direct, source) local vm = get_voxel_manip() local emin, emax = vm:read_from_map(vector.subtract(pos, radius), @@ -176,14 +177,11 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher) local ystride = (emax.x - emin_x + 1) local zstride = ystride * (emax.y - emin_y + 1) - local pos_x = pos.x - local pos_y = pos.y - local pos_z = pos.z - local area = VoxelArea:new { + --[[local area = VoxelArea:new { MinEdge = emin, MaxEdge = emax - } + }]] local data = vm:get_data() local destroy = {} @@ -212,7 +210,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher) npos_x - emin_x + 1 local cid = data[idx] - local br = node_blastres[cid] + local br = node_blastres[cid] or INDESTRUCT_BLASTRES if br < INDESTRUCT_BLASTRES and br > max_blast_resistance then br = max_blast_resistance end @@ -247,7 +245,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher) local ent = obj:get_luaentity() -- Ignore items to lower lag - if obj:is_player() or (ent and ent.name ~= '__builtin.item') then + if (obj:is_player() or (ent and ent.name ~= "__builtin.item")) and obj:get_hp() > 0 then local opos = obj:get_pos() local collisionbox = nil @@ -260,12 +258,12 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher) if collisionbox then -- Create rays from random points in the collision box - local x1 = collisionbox[1] * 2 - local y1 = collisionbox[2] * 2 - local z1 = collisionbox[3] * 2 - local x2 = collisionbox[4] * 2 - local y2 = collisionbox[5] * 2 - local z2 = collisionbox[6] * 2 + local x1 = collisionbox[1] + local y1 = collisionbox[2] + local z1 = collisionbox[3] + local x2 = collisionbox[4] + local y2 = collisionbox[5] + local z2 = collisionbox[6] local x_len = math.abs(x2 - x1) local y_len = math.abs(y2 - y1) local z_len = math.abs(z2 - z1) @@ -321,7 +319,6 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher) impact = 0 end local damage = math.floor((impact * impact + impact) * 7 * strength + 1) - local source = puncher or obj local sleep_formspec_doesnt_close_mt53 = false if obj:is_player() then @@ -333,26 +330,22 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher) sleep_formspec_doesnt_close_mt53 = true end end - if mod_death_messages then - mcl_death_messages.player_damage(obj, S("@1 was caught in an explosion.", name)) - end - if rawget(_G, "armor") and armor.last_damage_types then - armor.last_damage_types[name] = "explosion" - end end if sleep_formspec_doesnt_close_mt53 then - minetest.after(0.3, function(obj, damage, impact, punch_dir) -- 0.2 is minimum delay for closing old formspec and open died formspec -- TODO: REMOVE THIS IN THE FUTURE - if not obj then return end - obj:punch(obj, 10, { damage_groups = { full_punch_interval = 1, fleshy = damage, knockback = impact * 20.0 } }, punch_dir) - obj:add_velocity(vector.multiply(punch_dir, impact * 20)) - end, obj, damage, impact, vector.new(punch_dir)) - else - obj:punch(source, 10, { damage_groups = { full_punch_interval = 1, fleshy = damage, knockback = impact * 20.0 } }, punch_dir) + minetest.after(0.3, function() -- 0.2 is minimum delay for closing old formspec and open died formspec -- TODO: REMOVE THIS IN THE FUTURE + if not obj:is_player() then + return + end + + mcl_util.deal_damage(obj, damage, {type = "explosion", direct = direct, source = source}) - if obj:is_player() then obj:add_velocity(vector.multiply(punch_dir, impact * 20)) - elseif ent.tnt_knockback then + end) + else + mcl_util.deal_damage(obj, damage, {type = "explosion", direct = direct, source = source}) + + if obj:is_player() or ent.tnt_knockback then obj:add_velocity(vector.multiply(punch_dir, impact * 20)) end end @@ -368,9 +361,9 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher) local on_blast = node_on_blast[data[idx]] local remove = true - if do_drop or on_blast ~= nil then + if do_drop or on_blast then local npos = get_position_from_hash(hash) - if on_blast ~= nil then + if on_blast then on_blast(npos, 1.0, do_drop) remove = false else @@ -412,8 +405,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher) end -- Log explosion - minetest.log('action', 'Explosion at ' .. minetest.pos_to_string(pos) .. - ' with strength ' .. strength .. ' and radius ' .. radius) + minetest.log("action", "Explosion at "..pos_to_string(pos).." with strength "..strength.." and radius "..radius) end -- Create an explosion with strength at pos. @@ -422,7 +414,8 @@ end -- pos - The position where the explosion originates from -- strength - The blast strength of the explosion (a TNT explosion uses 4) -- info - Table containing information about explosion --- puncher - object that is reported as source of punches/damage (optional) +-- direct - direct source object of the damage (optional) +-- source - indirect source object of the damage (optional) -- -- Values in info: -- drop_chance - If specified becomes the drop chance of all nodes in the @@ -436,7 +429,7 @@ end -- griefing - If true, the explosion will destroy nodes (default: true) -- grief_protected - If true, the explosion will also destroy nodes which have -- been protected (default: false) -function mcl_explosions.explode(pos, strength, info, puncher) +function mcl_explosions.explode(pos, strength, info, direct, source) if info == nil then info = {} end @@ -465,7 +458,7 @@ function mcl_explosions.explode(pos, strength, info, puncher) info.drop_chance = 0 end - trace_explode(pos, strength, shape, radius, info, puncher) + trace_explode(pos, strength, shape, radius, info, direct, source) if info.particles then add_particles(pos, radius) diff --git a/mods/CORE/mcl_explosions/locale/mcl_explosions.de.tr b/mods/CORE/mcl_explosions/locale/mcl_explosions.de.tr deleted file mode 100644 index 4abbc64b..00000000 --- a/mods/CORE/mcl_explosions/locale/mcl_explosions.de.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:mcl_explosions -@1 was caught in an explosion.=@1 wurde Opfer einer Explosion. diff --git a/mods/CORE/mcl_explosions/locale/mcl_explosions.fr.tr b/mods/CORE/mcl_explosions/locale/mcl_explosions.fr.tr deleted file mode 100644 index cb9a0f38..00000000 --- a/mods/CORE/mcl_explosions/locale/mcl_explosions.fr.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:mcl_explosions -@1 was caught in an explosion.=@1 a été pris dans une explosion. \ No newline at end of file diff --git a/mods/CORE/mcl_explosions/locale/mcl_explosions.ru.tr b/mods/CORE/mcl_explosions/locale/mcl_explosions.ru.tr deleted file mode 100644 index 2c885845..00000000 --- a/mods/CORE/mcl_explosions/locale/mcl_explosions.ru.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:mcl_explosions -@1 was caught in an explosion.=@1 не удалось пережить взрыва. diff --git a/mods/CORE/mcl_explosions/locale/template.txt b/mods/CORE/mcl_explosions/locale/template.txt deleted file mode 100644 index 6a9348dd..00000000 --- a/mods/CORE/mcl_explosions/locale/template.txt +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:mcl_explosions -@1 was caught in an explosion.= diff --git a/mods/CORE/mcl_loot/init.lua b/mods/CORE/mcl_loot/init.lua index 6db74374..1b2c5080 100644 --- a/mods/CORE/mcl_loot/init.lua +++ b/mods/CORE/mcl_loot/init.lua @@ -40,10 +40,9 @@ function mcl_loot.get_loot(loot_definitions, pr) total_weight = total_weight + (loot_definitions.items[i].weight or 1) end - local stacks_min = loot_definitions.stacks_min - local stacks_max = loot_definitions.stacks_max - if not stacks_min then stacks_min = 1 end - if not stacks_max then stacks_max = 1 end + --local stacks_min = loot_definitions.stacks_min or 1 + --local stacks_max = loot_definitions.stacks_max or 1 + local stacks = pr:next(loot_definitions.stacks_min, loot_definitions.stacks_max) for s=1, stacks do local r = pr:next(1, total_weight) diff --git a/mods/CORE/mcl_particles/init.lua b/mods/CORE/mcl_particles/init.lua index 757c0452..4854afd5 100644 --- a/mods/CORE/mcl_particles/init.lua +++ b/mods/CORE/mcl_particles/init.lua @@ -1,3 +1,12 @@ +local vector = vector +local table = table + +local hash_node_position = minetest.hash_node_position +local add_particlespawner = minetest.add_particlespawner +local delete_particlespawner = minetest.delete_particlespawner + +local ipairs = ipairs + mcl_particles = {} -- Table of particlespawner IDs on a per-node hash basis @@ -32,11 +41,11 @@ function mcl_particles.add_node_particlespawner(pos, particlespawner_definition, if allowed_level == 0 or levels[level] > allowed_level then return end - local poshash = minetest.hash_node_position(pos) + local poshash = hash_node_position(pos) if not poshash then return end - local id = minetest.add_particlespawner(particlespawner_definition) + local id = add_particlespawner(particlespawner_definition) if id == -1 then return end @@ -47,6 +56,8 @@ function mcl_particles.add_node_particlespawner(pos, particlespawner_definition, return id end +local add_node_particlespawner = mcl_particles.add_node_particlespawner + -- Deletes all particlespawners that are assigned to a node position. -- If no particlespawners exist for this position, nothing happens. -- pos: Node positon. MUST use integer values! @@ -55,14 +66,66 @@ function mcl_particles.delete_node_particlespawners(pos) if allowed_level == 0 then return false end - local poshash = minetest.hash_node_position(pos) + local poshash = hash_node_position(pos) local ids = particle_nodes[poshash] if ids then for i=1, #ids do - minetest.delete_particlespawner(ids[i]) + delete_particlespawner(ids[i]) end particle_nodes[poshash] = nil return true end return false end + +-- 3 exptime variants because the animation is not tied to particle expiration time. +-- 3 colorized variants to imitate minecraft's +local smoke_pdef_cached = {} + +function mcl_particles.spawn_smoke(pos, name, smoke_pdef_base) + local new_minpos = vector.add(pos, smoke_pdef_base.minrelpos) + local new_maxpos = vector.add(pos, smoke_pdef_base.maxrelpos) + + -- populate the cache + if smoke_pdef_cached[name] then + for i, smoke_pdef in ipairs(smoke_pdef_cached[name]) do + smoke_pdef.minpos = new_minpos + smoke_pdef.maxpos = new_maxpos + add_node_particlespawner(pos, smoke_pdef, "high") + end + -- cache already populated + else + smoke_pdef_cached[name] = {} + + local smoke_pdef = table.copy(smoke_pdef_base) + smoke_pdef.amount = smoke_pdef_base.amount / 9 + smoke_pdef.time = 0 + smoke_pdef.animation = { + type = "vertical_frames", + aspect_w = 8, + aspect_h = 8, + -- length = 3 exptime variants + } + smoke_pdef.collisiondetection = true + smoke_pdef.minpos = new_minpos + smoke_pdef.maxpos = new_maxpos + + -- the last frame plays for 1/8 * N seconds, so we can take advantage of it + -- to have varying exptime for each variant. + local exptimes = { 0.175, 0.375, 1.0 } + local colorizes = { "199", "209", "243" } -- round(78%, 82%, 90% of 256) - 1 + + for _,exptime in ipairs(exptimes) do + for _,colorize in ipairs(colorizes) do + smoke_pdef.maxexptime = exptime * smoke_pdef_base.maxexptime + smoke_pdef.animation.length = exptime + 0.1 + -- minexptime must be set such that the last frame is actully rendered, + -- even if its very short. Larger exptime -> larger range + smoke_pdef.minexptime = math.min(exptime, (7.0/8.0 * (exptime + 0.1) + 0.1)) + smoke_pdef.texture = "mcl_particles_smoke_anim.png^[colorize:#000000:" ..colorize + add_node_particlespawner(pos, smoke_pdef, "high") + table.insert(smoke_pdef_cached[name], table.copy(smoke_pdef)) + end + end + end +end \ No newline at end of file diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_sponge1.png b/mods/CORE/mcl_particles/textures/mcl_particles_sponge1.png new file mode 100644 index 00000000..e8099a41 Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_sponge1.png differ diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_sponge2.png b/mods/CORE/mcl_particles/textures/mcl_particles_sponge2.png new file mode 100644 index 00000000..0004ce4d Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_sponge2.png differ diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_sponge3.png b/mods/CORE/mcl_particles/textures/mcl_particles_sponge3.png new file mode 100644 index 00000000..62ae83a8 Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_sponge3.png differ diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_sponge4.png b/mods/CORE/mcl_particles/textures/mcl_particles_sponge4.png new file mode 100644 index 00000000..7ee00cbf Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_sponge4.png differ diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_sponge5.png b/mods/CORE/mcl_particles/textures/mcl_particles_sponge5.png new file mode 100644 index 00000000..5278caff Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_sponge5.png differ diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index ac913de3..a7504af0 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -150,7 +150,7 @@ function mcl_util.get_eligible_transfer_item_slot(src_inventory, src_list, dst_i end -- Returns true if itemstack is a shulker box -local is_not_shulker_box = function(itemstack) +local function is_not_shulker_box(itemstack) local g = minetest.get_item_group(itemstack:get_name(), "shulker_box") return g == 0 or g == nil end @@ -212,7 +212,7 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list, end -- Normalize double container by forcing to always use the left segment first - local normalize_double_container = function(pos, node, ctype) + local function normalize_double_container(pos, node, ctype) if ctype == 6 then pos = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") if not pos then @@ -418,3 +418,123 @@ function mcl_util.get_color(colorstr) return colorstr, hex end end + +function mcl_util.call_on_rightclick(itemstack, player, pointed_thing) + -- Call on_rightclick if the pointed node defines it + if pointed_thing and pointed_thing.type == "node" then + local pos = pointed_thing.under + local node = minetest.get_node(pos) + if player and not player:get_player_control().sneak then + local nodedef = minetest.registered_nodes[node.name] + local on_rightclick = nodedef and nodedef.on_rightclick + if on_rightclick then + return on_rightclick(pos, node, player, itemstack, pointed_thing) or itemstack + end + end + end +end + +function mcl_util.calculate_durability(itemstack) + local unbreaking_level = mcl_enchanting.get_enchantment(itemstack, "unbreaking") + local armor_uses = minetest.get_item_group(itemstack:get_name(), "mcl_armor_uses") + + local uses + + if armor_uses > 0 then + uses = armor_uses + if unbreaking_level > 0 then + uses = uses / (0.6 + 0.4 / (unbreaking_level + 1)) + end + else + local def = itemstack:get_definition() + if def then + local fixed_uses = def._mcl_uses + if fixed_uses then + uses = fixed_uses + if unbreaking_level > 0 then + uses = uses * (unbreaking_level + 1) + end + end + end + uses = uses or (next(itemstack:get_tool_capabilities().groupcaps) or {}).uses + end + + return uses or 0 +end + +function mcl_util.use_item_durability(itemstack, n) + local uses = mcl_util.calculate_durability(itemstack) + itemstack:add_wear(65535 / uses * n) +end + +function mcl_util.deal_damage(target, damage, mcl_reason) + local luaentity = target:get_luaentity() + + if luaentity then + if luaentity.deal_damage then + luaentity:deal_damage(damage, mcl_reason or {type = "generic"}) + return + elseif luaentity._cmi_is_mob then + -- local puncher = mcl_reason and mcl_reason.direct or target + -- target:punch(puncher, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy = damage}}, vector.direction(puncher:get_pos(), target:get_pos()), damage) + if luaentity.health > 0 then + luaentity.health = luaentity.health - damage + end + return + end + end + + local hp = target:get_hp() + + if hp > 0 then + target:set_hp(hp - damage, {_mcl_reason = mcl_reason}) + end +end + +function mcl_util.get_hp(obj) + local luaentity = obj:get_luaentity() + + if luaentity and luaentity._cmi_is_mob then + return luaentity.health + else + return obj:get_hp() + end +end + +function mcl_util.get_inventory(object, create) + if object:is_player() then + return object:get_inventory() + else + local luaentity = object:get_luaentity() + local inventory = luaentity.inventory + + if create and not inventory and luaentity.create_inventory then + inventory = luaentity:create_inventory() + end + + return inventory + end +end + +function mcl_util.get_wielded_item(object) + if object:is_player() then + return object:get_wielded_item() + else + -- ToDo: implement getting wielditems from mobs as soon as mobs have wielditems + return ItemStack() + end +end + +function mcl_util.get_object_name(object) + if object:is_player() then + return object:get_player_name() + else + local luaentity = object:get_luaentity() + + if not luaentity then + return tostring(object) + end + + return luaentity.nametag and luaentity.nametag ~= "" and luaentity.nametag or luaentity.description or luaentity.name + end +end diff --git a/mods/CORE/mcl_worlds/API.md b/mods/CORE/mcl_worlds/API.md index a5509431..dd96b01b 100644 --- a/mods/CORE/mcl_worlds/API.md +++ b/mods/CORE/mcl_worlds/API.md @@ -61,20 +61,21 @@ In mc, you cant use clock in the nether and the end. * pos: position -## mcl_worlds.register_on_dimension_change(function(player, dimension)) +## mcl_worlds.register_on_dimension_change(function(player, dimension, last_dimension)) Register a callback function func(player, dimension). It will be called whenever a player changes between dimensions. The void counts as dimension. -* player: player, the player who changed the dimension -* dimension: position, The new dimension of the player ("overworld", "nether", "end", "void"). +* player: player, the player who changed of dimension +* dimension: string, The new dimension of the player ("overworld", "nether", "end", "void"). +* last_dimension: string, The dimension where the player was ("overworld", "nether", "end", "void"). ## mcl_worlds.registered_on_dimension_change Table containing all function registered with mcl_worlds.register_on_dimension_change() ## mcl_worlds.dimension_change(player, dimension) -Notify this mod of a dimmension change of to +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 diff --git a/mods/CORE/mcl_worlds/init.lua b/mods/CORE/mcl_worlds/init.lua index 6cdeaab7..203f6940 100644 --- a/mods/CORE/mcl_worlds/init.lua +++ b/mods/CORE/mcl_worlds/init.lua @@ -1,5 +1,7 @@ mcl_worlds = {} +local get_connected_players = minetest.get_connected_players + -- For a given position, returns a 2-tuple: -- 1st return value: true if pos is in void -- 2nd return value: true if it is in the deadly part of the void @@ -33,60 +35,64 @@ end -- If the Y coordinate is not located in any dimension, it will return: -- nil, "void" function mcl_worlds.y_to_layer(y) - if y >= mcl_vars.mg_overworld_min then - return y - mcl_vars.mg_overworld_min, "overworld" - elseif y >= mcl_vars.mg_nether_min and y <= mcl_vars.mg_nether_max+128 then - return y - mcl_vars.mg_nether_min, "nether" - elseif y >= mcl_vars.mg_end_min and y <= mcl_vars.mg_end_max then - return y - mcl_vars.mg_end_min, "end" - else - return nil, "void" - end + if y >= mcl_vars.mg_overworld_min then + return y - mcl_vars.mg_overworld_min, "overworld" + elseif y >= mcl_vars.mg_nether_min and y <= mcl_vars.mg_nether_max+128 then + return y - mcl_vars.mg_nether_min, "nether" + elseif y >= mcl_vars.mg_end_min and y <= mcl_vars.mg_end_max then + return y - mcl_vars.mg_end_min, "end" + else + return nil, "void" + end end +local y_to_layer = mcl_worlds.y_to_layer + -- Takes a pos and returns the dimension it belongs to (same as above) function mcl_worlds.pos_to_dimension(pos) - local _, dim = mcl_worlds.y_to_layer(pos.y) + local _, dim = y_to_layer(pos.y) return dim end +local pos_to_dimension = mcl_worlds.pos_to_dimension + -- Takes a Minecraft layer and a “dimension” name -- and returns the corresponding Y coordinate for -- MineClone 2. -- mc_dimension is one of "overworld", "nether", "end" (default: "overworld"). function mcl_worlds.layer_to_y(layer, mc_dimension) - if mc_dimension == "overworld" or mc_dimension == nil then - return layer + mcl_vars.mg_overworld_min - elseif mc_dimension == "nether" then - return layer + mcl_vars.mg_nether_min - elseif mc_dimension == "end" then - return layer + mcl_vars.mg_end_min - end + if mc_dimension == "overworld" or mc_dimension == nil then + return layer + mcl_vars.mg_overworld_min + elseif mc_dimension == "nether" then + return layer + mcl_vars.mg_nether_min + elseif mc_dimension == "end" then + return layer + mcl_vars.mg_end_min + end end -- Takes a position and returns true if this position can have weather function mcl_worlds.has_weather(pos) - -- Weather in the Overworld and the high part of the void below - return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 + -- Weather in the Overworld and the high part of the void below + return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 end -- Takes a position and returns true if this position can have Nether dust function mcl_worlds.has_dust(pos) - -- Weather in the Overworld and the high part of the void below - return pos.y <= mcl_vars.mg_nether_max + 138 and pos.y >= mcl_vars.mg_nether_min - 10 + -- Weather in the Overworld and the high part of the void below + return pos.y <= mcl_vars.mg_nether_max + 138 and pos.y >= mcl_vars.mg_nether_min - 10 end -- Takes a position (pos) and returns true if compasses are working here function mcl_worlds.compass_works(pos) - -- It doesn't work in Nether and the End, but it works in the Overworld and in the high part of the void below - local _, dim = mcl_worlds.y_to_layer(pos.y) - if dim == "nether" or dim == "end" then - return false - elseif dim == "void" then - return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 - else - return true - end + -- It doesn't work in Nether and the End, but it works in the Overworld and in the high part of the void below + local _, dim = mcl_worlds.y_to_layer(pos.y) + if dim == "nether" or dim == "end" then + return false + elseif dim == "void" then + return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 + else + return true + end end -- Takes a position (pos) and returns true if clocks are working here @@ -112,12 +118,15 @@ local last_dimension = {} -- * player: Player who changed the dimension -- * dimension: New dimension ("overworld", "nether", "end", "void") function mcl_worlds.dimension_change(player, dimension) + local playername = player:get_player_name() for i=1, #mcl_worlds.registered_on_dimension_change do - mcl_worlds.registered_on_dimension_change[i](player, dimension) - last_dimension[player:get_player_name()] = dimension + mcl_worlds.registered_on_dimension_change[i](player, dimension, last_dimension[playername]) end + last_dimension[playername] = dimension end +local dimension_change = mcl_worlds.dimension_change + ----------------------- INTERNAL STUFF ---------------------- -- Update the dimension callbacks every DIM_UPDATE seconds @@ -125,19 +134,19 @@ local DIM_UPDATE = 1 local dimtimer = 0 minetest.register_on_joinplayer(function(player) - last_dimension[player:get_player_name()] = mcl_worlds.pos_to_dimension(player:get_pos()) + last_dimension[player:get_player_name()] = pos_to_dimension(player:get_pos()) end) minetest.register_globalstep(function(dtime) -- regular updates based on iterval dimtimer = dimtimer + dtime; if dimtimer >= DIM_UPDATE then - local players = minetest.get_connected_players() - for p=1, #players do - local dim = mcl_worlds.pos_to_dimension(players[p]:get_pos()) + local players = get_connected_players() + for p = 1, #players do + local dim = pos_to_dimension(players[p]:get_pos()) local name = players[p]:get_player_name() if dim ~= last_dimension[name] then - mcl_worlds.dimension_change(players[p], dim) + dimension_change(players[p], dim) end end dimtimer = 0 diff --git a/mods/CORE/tga_encoder/README.md b/mods/CORE/tga_encoder/README.md new file mode 100644 index 00000000..9b3293dd --- /dev/null +++ b/mods/CORE/tga_encoder/README.md @@ -0,0 +1,4 @@ +# tga_encoder +A TGA Encoder written in Lua without the use of external Libraries. + +May be used as a Minetest mod. diff --git a/mods/CORE/tga_encoder/init.lua b/mods/CORE/tga_encoder/init.lua new file mode 100644 index 00000000..96afda5e --- /dev/null +++ b/mods/CORE/tga_encoder/init.lua @@ -0,0 +1,78 @@ +tga_encoder = {} + +local image = setmetatable({}, { + __call = function(self, ...) + local t = setmetatable({}, {__index = self}) + t:constructor(...) + return t + end, +}) + +function image:constructor(pixels) + self.data = "" + self.pixels = pixels + self.width = #pixels[1] + self.height = #pixels + + self:encode() +end + +function image:encode_colormap_spec() + self.data = self.data + .. string.char(0, 0) -- first entry index + .. string.char(0, 0) -- number of entries + .. string.char(0) -- bits per pixel +end + +function image:encode_image_spec() + self.data = self.data + .. string.char(0, 0) -- X-origin + .. string.char(0, 0) -- Y-origin + .. string.char(self.width % 256, math.floor(self.width / 256)) -- width + .. string.char(self.height % 256, math.floor(self.height / 256)) -- height + .. string.char(24) -- pixel depth (RGB = 3 bytes = 24 bits) + .. string.char(0) -- image descriptor +end + +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) + self:encode_colormap_spec() -- color map specification + self:encode_image_spec() -- image specification +end + +function image:encode_data() + 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]) + end + end +end + +function image:encode_footer() + self.data = self.data + .. string.char(0, 0, 0, 0) -- extension area offset + .. string.char(0, 0, 0, 0) -- developer area offset + .. "TRUEVISION-XFILE" + .. "." + .. string.char(0) +end + +function image:encode() + self:encode_header() -- header + -- no color map and image id data + self:encode_data() -- encode data + -- no extension or developer area + self:encode_footer() -- footer +end + +function image:save(filename) + local f = assert(io.open(filename, "w")) + f:write(self.data) + f:close() +end + +tga_encoder.image = image diff --git a/mods/CORE/tga_encoder/mod.conf b/mods/CORE/tga_encoder/mod.conf new file mode 100644 index 00000000..e4bfac89 --- /dev/null +++ b/mods/CORE/tga_encoder/mod.conf @@ -0,0 +1,3 @@ +name = tga_encoder +author = Fleckenstein +description = A TGA Encoder written in Lua without the use of external Libraries. diff --git a/mods/CORE/walkover/init.lua b/mods/CORE/walkover/init.lua index 220157c8..4d712c30 100644 --- a/mods/CORE/walkover/init.lua +++ b/mods/CORE/walkover/init.lua @@ -4,6 +4,7 @@ local get_connected_players = minetest.get_connected_players local get_node = minetest.get_node local vector_add = vector.add local ceil = math.ceil +local pairs = pairs walkover = {} walkover.registered_globals = {} @@ -31,24 +32,21 @@ minetest.register_globalstep(function(dtime) timer = timer + dtime; if timer >= 0.3 then for _,player in pairs(get_connected_players()) do - local pp = player:get_pos() - pp.y = ceil(pp.y) - local loc = vector_add(pp, {x=0,y=-1,z=0}) - if loc ~= nil then - - local nodeiamon = get_node(loc) - - if nodeiamon ~= nil then - if on_walk[nodeiamon.name] then - on_walk[nodeiamon.name](loc, nodeiamon, player) - end - for i = 1, #registered_globals do + local pp = player:get_pos() + pp.y = ceil(pp.y) + local loc = vector_add(pp, {x=0,y=-1,z=0}) + if loc then + local nodeiamon = get_node(loc) + if nodeiamon then + if on_walk[nodeiamon.name] then + on_walk[nodeiamon.name](loc, nodeiamon, player) + end + for i = 1, #registered_globals do registered_globals[i](loc, nodeiamon, player) - end - end - end - end - + end + end + end + end timer = 0 end end) diff --git a/mods/ENTITIES/drippingwater/init.lua b/mods/ENTITIES/drippingwater/init.lua index 730cb7b7..e17bdda4 100644 --- a/mods/ENTITIES/drippingwater/init.lua +++ b/mods/ENTITIES/drippingwater/init.lua @@ -1,6 +1,8 @@ --Dripping Water Mod --by kddekadenz +local math = math + -- License of code, textures & sounds: CC0 --Drop entities @@ -20,26 +22,21 @@ minetest.register_entity("drippingwater:drop_water", { 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 - + 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) + self.object:remove() + minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) end end, }) @@ -61,27 +58,21 @@ minetest.register_entity("drippingwater:drop_lava", { 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 - - + 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) + self.object:remove() + minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) end end, }) @@ -90,36 +81,34 @@ minetest.register_entity("drippingwater:drop_lava", { --Create drop -minetest.register_abm( - { +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 + 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, + end, }) --Create lava drop -minetest.register_abm( - { +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 + 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, -}) + end, +}) \ No newline at end of file diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 38e73565..76ace7a4 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_boats") +local S = minetest.get_translator(minetest.get_current_modname()) local boat_visual_size = {x = 1, y = 1, z = 1} local paddling_speed = 22 @@ -188,7 +188,7 @@ function boat.on_punch(self, puncher, time_from_last_punch, tool_capabilities, d end function boat.on_step(self, dtime, moveresult) - mcl_burning.tick(self.object, dtime) + mcl_burning.tick(self.object, dtime, self) self._v = get_v(self.object:get_velocity()) * get_sign(self._v) local v_factor = 1 @@ -328,10 +328,10 @@ function boat.on_step(self, dtime, moveresult) p.y = p.y - boat_y_offset local new_velo - local new_acce = {x = 0, y = 0, z = 0} + local new_acce if not is_water(p) and not on_ice then -- Not on water or inside water: Free fall - local nodedef = minetest.registered_nodes[minetest.get_node(p).name] + --local nodedef = minetest.registered_nodes[minetest.get_node(p).name] new_acce = {x = 0, y = -9.8, z = 0} new_velo = get_velocity(self._v, self.object:get_yaw(), self.object:get_velocity().y) @@ -394,7 +394,7 @@ for b=1, #boat_ids do if b == 1 then help = true longdesc = S("Boats are used to travel on the surface of water.") - usagehelp = S("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.") + usagehelp = S("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.") helpname = S("Boat") end tt_help = S("Water vehicle") @@ -470,6 +470,6 @@ minetest.register_craft({ burntime = 20, }) -if minetest.get_modpath("doc_identifier") ~= nil then +if minetest.get_modpath("doc_identifier") then doc.sub.identifier.register_object("mcl_boats:boat", "craftitems", "mcl_boats:boat") end diff --git a/mods/ENTITIES/mcl_boats/locale/mcl_boats.de.tr b/mods/ENTITIES/mcl_boats/locale/mcl_boats.de.tr index 95066b53..c1864a87 100644 --- a/mods/ENTITIES/mcl_boats/locale/mcl_boats.de.tr +++ b/mods/ENTITIES/mcl_boats/locale/mcl_boats.de.tr @@ -6,6 +6,7 @@ Boats are used to travel on the surface of water.=Boote werden benutzt, um sich Dark Oak Boat=Schwarzeichenboot Jungle Boat=Dschungelboot Oak Boat=Eichenboot -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.=Rechtsklicken Sie auf eine Wasserquelle, um das Boot zu platzieren. Rechtsklicken Sie auf das Boot, um es zu betreten. Mit [Links] und [Rechts] lenken, mit [Vorwärts] und [Rückwärts] Geschwindigkeit regeln oder rückwärts fahren. Rechtsklicken Sie erneut auf das Boot, um es zu verlassen, schlagen Sie das Boot, um es als Gegenstand fallen zu lassen. +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.=Rechtsklicken Sie auf eine Wasserquelle, um das Boot zu platzieren. Rechtsklicken Sie auf das Boot, um es zu betreten. Mit [Links] und [Rechts] lenken, mit [Vorwärts] und [Rückwärts] Geschwindigkeit regeln oder rückwärts fahren. Nutzen sie [Schleichen], um das Boot zu verlassen, schlagen Sie das Boot, um es als Gegenstand fallen zu lassen. Spruce Boat=Fichtenboot Water vehicle=Wasserfahrzeug +Sneak to dismount=Zum Aussteigen schleichen diff --git a/mods/ENTITIES/mcl_boats/locale/template.txt b/mods/ENTITIES/mcl_boats/locale/template.txt index 54f1fd64..ac52bc19 100644 --- a/mods/ENTITIES/mcl_boats/locale/template.txt +++ b/mods/ENTITIES/mcl_boats/locale/template.txt @@ -6,6 +6,7 @@ Boats are used to travel on the surface of water.= Dark Oak Boat= Jungle Boat= Oak Boat= -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.= +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.= Spruce Boat= Water vehicle= +Sneak to dismount= diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index b08a0fb7..4cb19cca 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -1,184 +1,86 @@ -local S = minetest.get_translator("mcl_burning") - -function mcl_burning.get_default(datatype) - local default_table = {string = "", float = 0.0, int = 0, bool = false} - return default_table[datatype] -end - -function mcl_burning.get(obj, datatype, name) - local key - if obj:is_player() then - local meta = obj:get_meta() - return meta["get_" .. datatype](meta, "mcl_burning:" .. name) - else - local luaentity = obj:get_luaentity() - return luaentity and luaentity["mcl_burning_" .. name] or mcl_burning.get_default(datatype) - end -end - -function mcl_burning.set(obj, datatype, name, value) - if obj:is_player() then - local meta = obj:get_meta() - meta["set_" .. datatype](meta, "mcl_burning:" .. name, value or mcl_burning.get_default(datatype)) - else - local luaentity = obj:get_luaentity() - if mcl_burning.get_default(datatype) == value then - value = nil - end - luaentity["mcl_burning_" .. name] = value - end +function mcl_burning.get_storage(obj) + return obj:is_player() and mcl_burning.storage[obj] or obj:get_luaentity() end function mcl_burning.is_burning(obj) - return mcl_burning.get(obj, "float", "burn_time") > 0 + return mcl_burning.get_storage(obj).burn_time end function mcl_burning.is_affected_by_rain(obj) - return mcl_weather and mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos()) + return mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos()) end -function mcl_burning.get_collisionbox(obj, smaller) - local box = obj:get_properties().collisionbox - local minp, maxp = vector.new(box[1], box[2], box[3]), vector.new(box[4], box[5], box[6]) - if smaller then +function mcl_burning.get_collisionbox(obj, smaller, storage) + local cache = storage.collisionbox_cache + if cache then + local box = cache[smaller and 2 or 1] + return box[1], box[2] + else + local box = obj:get_properties().collisionbox + local minp, maxp = vector.new(box[1], box[2], box[3]), vector.new(box[4], box[5], box[6]) local s_vec = vector.new(0.1, 0.1, 0.1) - minp = vector.add(minp, s_vec) - maxp = vector.subtract(maxp, s_vec) + local s_minp = vector.add(minp, s_vec) + local s_maxp = vector.subtract(maxp, s_vec) + storage.collisionbox_cache = {{minp, maxp}, {s_minp, s_maxp}} + return minp, maxp end - return minp, maxp end -function mcl_burning.get_touching_nodes(obj, nodenames) +function mcl_burning.get_touching_nodes(obj, nodenames, storage) local pos = obj:get_pos() - local box = obj:get_properties().collisionbox - local minp, maxp = mcl_burning.get_collisionbox(obj, true) + local minp, maxp = mcl_burning.get_collisionbox(obj, true, storage) local nodes = minetest.find_nodes_in_area(vector.add(pos, minp), vector.add(pos, maxp), nodenames) return nodes end -function mcl_burning.get_highest_group_value(obj, groupname) - local nodes = mcl_burning.get_touching_nodes(obj, "group:" .. groupname, true) - local highest_group_value = 0 - - for _, pos in pairs(nodes) do - local node = minetest.get_node(pos) - local group_value = minetest.get_item_group(node.name, groupname) - if group_value > highest_group_value then - highest_group_value = group_value - end - end - - return highest_group_value -end - -function mcl_burning.damage(obj) - local luaentity = obj:get_luaentity() - local health - - if luaentity then - health = luaentity.health - end - - local hp = health or obj:get_hp() - - if hp <= 0 then - return - end - - local do_damage = true - - if obj:is_player() then - if mcl_potions.player_has_effect(obj, "fire_proof") then - do_damage = false - else - local name = obj:get_player_name() - armor.last_damage_types[name] = "fire" - local deathmsg = S("@1 burned to death.", name) - local reason = mcl_burning.get(obj, "string", "reason") - if reason ~= "" then - deathmsg = S("@1 was burned by @2.", name, reason) - end - mcl_death_messages.player_damage(obj, deathmsg) - end - else - if luaentity.fire_damage_resistant then - do_damage = false - end - end - - if do_damage then - local new_hp = hp - 1 - if health then - luaentity.health = new_hp - else - obj:set_hp(new_hp) - end - end -end - -function mcl_burning.set_on_fire(obj, burn_time, reason) +function mcl_burning.set_on_fire(obj, burn_time) if obj:get_hp() < 0 then return end + local storage = mcl_burning.get_storage(obj) + local luaentity = obj:get_luaentity() if luaentity and luaentity.fire_resistant then return end - local old_burn_time = mcl_burning.get(obj, "float", "burn_time") - local max_fire_prot_lvl = 0 + if obj:is_player() and minetest.is_creative_enabled(obj:get_player_name()) then + burn_time = 0 + else + local max_fire_prot_lvl = 0 + local inv = mcl_util.get_inventory(obj) + local armor_list = inv and inv:get_list("armor") - if obj:is_player() then - if minetest.is_creative_enabled(obj:get_player_name()) then - burn_time = burn_time / 100 - end - - local inv = obj:get_inventory() - - for i = 2, 5 do - local stack = inv:get_stack("armor", i) - - local fire_prot_lvl = mcl_enchanting.get_enchantment(stack, "fire_protection") - max_fire_prot_lvl = math.max(max_fire_prot_lvl, fire_prot_lvl) - end - end - - if max_fire_prot_lvl > 0 then - burn_time = burn_time - math.floor(burn_time * max_fire_prot_lvl * 0.15) - end - - if old_burn_time <= burn_time then - --[[local sound_id = mcl_burning.get(obj, "int", "sound_id") - if sound_id == 0 then - sound_id = minetest.sound_play("fire_fire", { - object = obj, - gain = 0.18, - max_hear_distance = 16, - loop = true, - }) + 1 - end]]-- - - local hud_id - if obj:is_player() then - hud_id = mcl_burning.get(obj, "int", "hud_id") - if hud_id == 0 then - 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, - }) + 1 + if armor_list then + for _, stack in pairs(armor_list) do + local fire_prot_lvl = mcl_enchanting.get_enchantment(stack, "fire_protection") + if fire_prot_lvl > max_fire_prot_lvl then + max_fire_prot_lvl = fire_prot_lvl + end end end - mcl_burning.set(obj, "float", "burn_time", burn_time) - mcl_burning.set(obj, "string", "reason", reason) - mcl_burning.set(obj, "int", "hud_id", hud_id) - --mcl_burning.set(obj, "int", "sound_id", sound_id) + + if max_fire_prot_lvl > 0 then + burn_time = burn_time - math.floor(burn_time * max_fire_prot_lvl * 0.15) + end + 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, + }) + end + storage.burn_time = burn_time + storage.fire_damage_timer = 0 local fire_entity = minetest.add_entity(obj:get_pos(), "mcl_burning:fire") - local minp, maxp = mcl_burning.get_collisionbox(obj) + local minp, maxp = mcl_burning.get_collisionbox(obj, false, storage) local obj_size = obj:get_properties().visual_size local vertical_grow_factor = 1.2 @@ -192,111 +94,53 @@ function mcl_burning.set_on_fire(obj, burn_time, reason) fire_entity:set_properties({visual_size = size}) fire_entity:set_attach(obj, "", offset, {x = 0, y = 0, z = 0}) - mcl_burning.update_animation_frame(obj, fire_entity, 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() + if other_luaentity and other_luaentity.name == "mcl_burning:fire" and other_luaentity ~= fire_luaentity then + other:remove() + break + end + end end end function mcl_burning.extinguish(obj) if mcl_burning.is_burning(obj) then - --local sound_id = mcl_burning.get(obj, "int", "sound_id") - 1 - --minetest.sound_stop(sound_id) - + local storage = mcl_burning.get_storage(obj) if obj:is_player() then - local hud_id = mcl_burning.get(obj, "int", "hud_id") - 1 - obj:hud_remove(hud_id) - end - - mcl_burning.set(obj, "string", "reason") - mcl_burning.set(obj, "float", "burn_time") - mcl_burning.set(obj, "float", "damage_timer") - mcl_burning.set(obj, "int", "hud_id") - --mcl_burning.set(obj, "int", "sound_id") - end -end - -function mcl_burning.catch_fire_tick(obj, dtime) - if mcl_burning.is_affected_by_rain(obj) or #mcl_burning.get_touching_nodes(obj, "group:puts_out_fire") > 0 then - mcl_burning.extinguish(obj) - else - local set_on_fire_value = mcl_burning.get_highest_group_value(obj, "set_on_fire") - - if set_on_fire_value > 0 then - mcl_burning.set_on_fire(obj, set_on_fire_value) + if storage.fire_hud_id then + obj:hud_remove(storage.fire_hud_id) + end + mcl_burning.storage[obj] = {} + else + storage.burn_time = nil + storage.fire_damage_timer = nil end end end -function mcl_burning.tick(obj, dtime) - local burn_time = mcl_burning.get(obj, "float", "burn_time") - dtime +function mcl_burning.tick(obj, dtime, storage) + if storage.burn_time then + storage.burn_time = storage.burn_time - dtime - if burn_time <= 0 then - mcl_burning.extinguish(obj) - else - mcl_burning.set(obj, "float", "burn_time", burn_time) + if storage.burn_time <= 0 or mcl_burning.is_affected_by_rain(obj) or #mcl_burning.get_touching_nodes(obj, "group:puts_out_fire", storage) > 0 then + mcl_burning.extinguish(obj) + return true + else + storage.fire_damage_timer = storage.fire_damage_timer + dtime - local damage_timer = mcl_burning.get(obj, "float", "damage_timer") + dtime + if storage.fire_damage_timer >= 1 then + storage.fire_damage_timer = 0 - if damage_timer >= 1 then - damage_timer = 0 - mcl_burning.damage(obj) - end + local luaentity = obj:get_luaentity() - mcl_burning.set(obj, "float", "damage_timer", damage_timer) - end - - mcl_burning.catch_fire_tick(obj, dtime) -end - -function mcl_burning.update_animation_frame(obj, fire_entity, animation_frame) - local fire_texture = "mcl_burning_entity_flame_animated.png^[opacity:180^[verticalframe:" .. mcl_burning.animation_frames .. ":" .. animation_frame - local fire_HUD_texture = "mcl_burning_hud_flame_animated.png^[opacity:180^[verticalframe:" .. mcl_burning.animation_frames .. ":" .. animation_frame - fire_entity:set_properties({textures = {"blank.png", "blank.png", fire_texture, fire_texture, fire_texture, fire_texture}}) - if obj:is_player() then - local hud_id = mcl_burning.get(obj, "int", "hud_id") - 1 - obj:hud_change(hud_id, "text", fire_HUD_texture) - end -end - -function mcl_burning.fire_entity_step(self, dtime) - if self.removed then - return - end - - local obj = self.object - local parent = obj:get_attach() - local do_remove - - self.doing_step = true - - if not parent or not mcl_burning.is_burning(parent) then - do_remove = true - else - for _, other in pairs(minetest.get_objects_inside_radius(obj:get_pos(), 0)) do - local luaentity = obj:get_luaentity() - if luaentity and luaentity.name == "mcl_burning:fire" and not luaentity.doing_step and not luaentity.removed then - do_remove = true - break + if not luaentity or not luaentity.fire_damage_resistant then + mcl_util.deal_damage(obj, 1, {type = "on_fire"}) + end end end end - - self.doing_step = false - - if do_remove then - self.removed = true - obj:remove() - return - end - - local animation_timer = self.animation_timer + dtime - if animation_timer >= 0.015 then - animation_timer = 0 - local animation_frame = self.animation_frame + 1 - if animation_frame > mcl_burning.animation_frames - 1 then - animation_frame = 0 - end - mcl_burning.update_animation_frame(parent, obj, animation_frame) - self.animation_frame = animation_frame - end - self.animation_timer = animation_timer -end +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index 672036c7..34b7ca2d 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -1,12 +1,69 @@ -local S = minetest.get_translator("mcl_burning") -local modpath = minetest.get_modpath("mcl_burning") +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +local pairs = pairs + +local get_connected_players = minetest.get_connected_players +local get_item_group = minetest.get_item_group mcl_burning = { + storage = {}, animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8 } dofile(modpath .. "/api.lua") +minetest.register_globalstep(function(dtime) + for _, player in pairs(get_connected_players()) do + local storage = mcl_burning.storage[player] + if not mcl_burning.tick(player, dtime, storage) and not mcl_burning.is_affected_by_rain(player) then + local nodes = mcl_burning.get_touching_nodes(player, {"group:puts_out_fire", "group:set_on_fire"}, storage) + local burn_time = 0 + + for _, pos in pairs(nodes) do + local node = minetest.get_node(pos) + if get_item_group(node.name, "puts_out_fire") > 0 then + burn_time = 0 + break + end + + local value = get_item_group(node.name, "set_on_fire") + if value > burn_time then + burn_time = value + end + end + + if burn_time > 0 then + mcl_burning.set_on_fire(player, burn_time) + end + end + end +end) + +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) + end + + mcl_burning.storage[player] = storage +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)) + mcl_burning.storage[player] = nil +end) + + minetest.register_entity("mcl_burning:fire", { initial_properties = { physical = false, @@ -14,23 +71,48 @@ minetest.register_entity("mcl_burning:fire", { visual = "cube", pointable = false, glow = -1, + backface_culling = false, }, - animation_frame = 0, animation_timer = 0, - on_step = mcl_burning.fire_entity_step, + 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 + self.object:remove() + end + end, + sanity_check = function(self) + local parent = self.object:get_attach() + + if not parent then + return + end + + local storage = mcl_burning.get_storage(parent) + + if not storage or not storage.burn_time then + return + 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 + end, }) - -minetest.register_globalstep(function(dtime) - for _, player in pairs(minetest.get_connected_players()) do - mcl_burning.tick(player, dtime) - end -end) - -minetest.register_on_respawnplayer(function(player) - mcl_burning.extinguish(player) -end) - -minetest.register_on_leaveplayer(function(player) - mcl_burning.set(player, "int", "hud_id") -end) diff --git a/mods/ENTITIES/mcl_falling_nodes/init.lua b/mods/ENTITIES/mcl_falling_nodes/init.lua index 6e69f891..01681a15 100644 --- a/mods/ENTITIES/mcl_falling_nodes/init.lua +++ b/mods/ENTITIES/mcl_falling_nodes/init.lua @@ -1,10 +1,4 @@ -local S = minetest.get_translator("mcl_falling_nodes") -local dmes = minetest.get_modpath("mcl_death_messages") ~= nil -local has_mcl_armor = minetest.get_modpath("mcl_armor") - -local is_creative_enabled = minetest.is_creative_enabled - -local get_falling_depth = function(self) +local function get_falling_depth(self) if not self._startpos then -- Fallback self._startpos = self.object:get_pos() @@ -12,7 +6,7 @@ local get_falling_depth = function(self) return self._startpos.y - vector.round(self.object:get_pos()).y end -local deal_falling_damage = function(self, dtime) +local function deal_falling_damage(self, dtime) if minetest.get_item_group(self.node.name, "falling_node_damage") == 0 then return end @@ -23,80 +17,31 @@ local deal_falling_damage = function(self, dtime) -- Fallback self._startpos = pos end - local objs = minetest.get_objects_inside_radius(pos, 1) - for _,v in ipairs(objs) do - if v:is_player() then - local hp = v:get_hp() - local name = v:get_player_name() - if hp ~= 0 then - if not self._hit_players then - self._hit_players = {} - end - local hit = false - for _,v in ipairs(self._hit_players) do - if name == v then - hit = true + 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 + self._hit[obj] = true + local way = self._startpos.y - pos.y + local damage = (way - 1) * 2 + damage = math.min(40, math.max(0, damage)) + if damage >= 1 then + -- Reduce damage if wearing a helmet + local inv = mcl_util.get_inventory(obj) + if inv then + local helmet = inv:get_stack("armor", 2) + if minetest.get_item_group(helmet:get_name(), "combat_armor") > 0 then + damage = damage / 4 * 3 + mcl_util.use_item_durability(helmet, 1) + inv:set_stack("armor", 2, helmet) end end - if not hit then - table.insert(self._hit_players, name) - local way = self._startpos.y - pos.y - local damage = (way - 1) * 2 - damage = math.min(40, math.max(0, damage)) - if damage >= 1 then - hp = hp - damage - if hp < 0 then - hp = 0 - end - -- Reduce damage if wearing a helmet - local inv = v:get_inventory() - local helmet = inv:get_stack("armor", 2) - if has_mcl_armor and not helmet:is_empty() then - hp = hp/4*3 - if not is_creative_enabled(name) then - helmet:add_wear(65535/helmet:get_definition().groups.mcl_armor_uses) --TODO: be sure damage is exactly like mc (informations are missing in the mc wiki) - inv:set_stack("armor", 2, helmet) - end - end - local msg - if minetest.get_item_group(self.node.name, "anvil") ~= 0 then - msg = S("@1 was smashed by a falling anvil.", v:get_player_name()) - else - msg = S("@1 was smashed by a falling block.", v:get_player_name()) - end - if dmes then - mcl_death_messages.player_damage(v, msg) - end - v:set_hp(hp, { type = "punch", from = "mod" }) - end - end - end - else - local hp = v:get_luaentity().health - if hp and hp ~= 0 then - if not self._hit_mobs then - self._hit_mobs = {} - end - local hit = false - for _,mob in ipairs(self._hit_mobs) do - if v == mob then - hit = true - end - end - --TODO: reduce damage for mobs then they will be able to wear armor - if not hit then - table.insert(self._hit_mobs, v) - local way = self._startpos.y - pos.y - local damage = (way - 1) * 2 - damage = math.min(40, math.max(0, damage)) - if damage >= 1 then - hp = hp - damage - if hp < 0 then - hp = 0 - end - v:get_luaentity().health = hp - end + local dmg_type + if minetest.get_item_group(self.node.name, "anvil") ~= 0 then + dmg_type = "anvil" + else + dmg_type = "falling_node" end + mcl_util.deal_damage(obj, damage, {type = dmg_type}) end end end @@ -112,10 +57,8 @@ minetest.register_entity(":__builtin:falling_node", { collide_with_objects = false, collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, }, - node = {}, meta = {}, - set_node = function(self, node, meta) local def = minetest.registered_nodes[node.name] -- Change falling node if definition tells us to @@ -142,7 +85,6 @@ minetest.register_entity(":__builtin:falling_node", { glow = glow, }) end, - get_staticdata = function(self) local meta = self.meta -- Workaround: Save inventory seperately from metadata. @@ -163,10 +105,9 @@ minetest.register_entity(":__builtin:falling_node", { } return minetest.serialize(ds) end, - on_activate = function(self, staticdata) self.object:set_armor_groups({immortal = 1}) - + local ds = minetest.deserialize(staticdata) if ds then self._startpos = ds._startpos @@ -186,7 +127,6 @@ minetest.register_entity(":__builtin:falling_node", { end self._startpos = vector.round(self._startpos) end, - on_step = function(self, dtime) -- Set gravity local acceleration = self.object:get_acceleration() @@ -200,7 +140,7 @@ minetest.register_entity(":__builtin:falling_node", { local np = {x = pos.x, y = pos.y + 0.3, z = pos.z} local n2 = minetest.get_node(np) if n2.name == "mcl_portals:portal_end" then - -- TODO: Teleport falling node. + -- TODO: Teleport falling node. self.object:remove() return end @@ -238,10 +178,9 @@ minetest.register_entity(":__builtin:falling_node", { return end local nd = minetest.registered_nodes[n2.name] - if n2.name == "mcl_portals:portal_end" then - -- TODO: Teleport falling node. - - elseif (nd and nd.buildable_to == true) or minetest.get_item_group(self.node.name, "crush_after_fall") ~= 0 then + --if n2.name == "mcl_portals:portal_end" then + -- TODO: Teleport falling node. + if (nd and nd.buildable_to == true) or minetest.get_item_group(self.node.name, "crush_after_fall") ~= 0 then -- Replace destination node if it's buildable to minetest.remove_node(np) -- Run script hook @@ -308,7 +247,6 @@ minetest.register_entity(":__builtin:falling_node", { self.object:set_pos(npos) end end - deal_falling_damage(self, dtime) end }) diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.de.tr b/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.de.tr deleted file mode 100644 index 71dfa4be..00000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.de.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.=@1 wurde von einem fallenden Amboss zerschmettert. -@1 was smashed by a falling block.=@1 wurde von einem fallenden Block zerschmettert. diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.es.tr b/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.es.tr deleted file mode 100644 index 41cbf61b..00000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.es.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.=@1 fue aplastado por la caída de un yunque. -@1 was smashed by a falling block.=@1 fue aplastado por la caída de un bloque. diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.fr.tr b/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.fr.tr deleted file mode 100644 index 781cd704..00000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.fr.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.=@1 a été écrasé par une enclume qui tombait. -@1 was smashed by a falling block.=@1 a été écrasé par un bloc qui tombait. diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.ru.tr b/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.ru.tr deleted file mode 100644 index 6c8b9375..00000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.ru.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.=@1 придавило падающей наковальней. -@1 was smashed by a falling block.=@1 раздавило падающим блоком. diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/template.txt b/mods/ENTITIES/mcl_falling_nodes/locale/template.txt deleted file mode 100644 index 4adabaf0..00000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/template.txt +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.= -@1 was smashed by a falling block.= diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index b65585a1..ab1ac575 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -1,5 +1,5 @@ --these are lua locals, used for higher performance -local minetest,math,vector,ipairs = minetest,math,vector,ipairs +local minetest, math, vector, ipairs, pairs = minetest, math, vector, ipairs, pairs --this is used for the player pool in the sound buffer local pool = {} @@ -38,7 +38,7 @@ item_drop_settings.drop_single_item = false --if true, the drop control dro item_drop_settings.magnet_time = 0.75 -- how many seconds an item follows the player before giving up -local get_gravity = function() +local function get_gravity() return tonumber(minetest.settings:get("movement_gravity")) or 9.81 end @@ -60,7 +60,7 @@ mcl_item_entity.register_pickup_achievement("mcl_mobitems:blaze_rod", "mcl:blaze mcl_item_entity.register_pickup_achievement("mcl_mobitems:leather", "mcl:killCow") mcl_item_entity.register_pickup_achievement("mcl_core:diamond", "mcl:diamonds") -local check_pickup_achievements = function(object, player) +local function check_pickup_achievements(object, player) if has_awards then local itemname = ItemStack(object:get_luaentity().itemstring):get_name() local playername = player:get_player_name() @@ -72,7 +72,7 @@ local check_pickup_achievements = function(object, player) end end -local enable_physics = function(object, luaentity, ignore_check) +local function enable_physics(object, luaentity, ignore_check) if luaentity.physical_state == false or ignore_check == true then luaentity.physical_state = true object:set_properties({ @@ -83,7 +83,7 @@ local enable_physics = function(object, luaentity, ignore_check) end end -local disable_physics = function(object, luaentity, ignore_check, reset_movement) +local function disable_physics(object, luaentity, ignore_check, reset_movement) if luaentity.physical_state == true or ignore_check == true then luaentity.physical_state = false object:set_properties({ @@ -98,15 +98,13 @@ end minetest.register_globalstep(function(dtime) - tick = not tick for _,player in pairs(minetest.get_connected_players()) do if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then - local name = player:get_player_name() - + local pos = player:get_pos() if tick == true and pool[name] > 0 then @@ -124,7 +122,7 @@ minetest.register_globalstep(function(dtime) end - + local inv = player:get_inventory() local checkpos = {x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z} @@ -235,7 +233,7 @@ function minetest.handle_node_drops(pos, drops, digger) local dug_node = minetest.get_node(pos) local tooldef local tool - if digger ~= nil then + if digger then tool = digger:get_wielded_item() tooldef = minetest.registered_tools[tool:get_name()] @@ -316,7 +314,7 @@ function minetest.handle_node_drops(pos, drops, digger) end -- Spawn item and apply random speed local obj = minetest.add_item(dpos, drop_item) - if obj ~= nil then + if obj then local x = math.random(1, 5) if math.random(1,2) == 1 then x = -x @@ -365,6 +363,17 @@ if not time_to_live then time_to_live = 300 end +local function cxcz(o, cw, one, zero) + if cw < 0 then + table.insert(o, { [one]=1, y=0, [zero]=0 }) + table.insert(o, { [one]=-1, y=0, [zero]=0 }) + else + table.insert(o, { [one]=-1, y=0, [zero]=0 }) + table.insert(o, { [one]=1, y=0, [zero]=0 }) + end + return o +end + minetest.register_entity(":__builtin:item", { initial_properties = { hp_max = 1, @@ -385,7 +394,7 @@ minetest.register_entity(":__builtin:item", { -- The itemstring MUST be set immediately to a non-empty string after creating the entity. -- The hand is NOT permitted as dropped item. ;-) -- Item entities will be deleted if they still have an empty itemstring on their first on_step tick. - itemstring = '', + itemstring = "", -- If true, item will fall physical_state = true, @@ -406,6 +415,14 @@ minetest.register_entity(":__builtin:item", { return end local stack = ItemStack(itemstring) + if minetest.get_item_group(stack:get_name(), "compass") > 0 then + stack:set_name("mcl_compass:16") + itemstring = stack:to_string() + self.itemstring = itemstring + end + if minetest.get_item_group(stack:get_name(), "clock") > 0 then + self.is_clock = true + end local count = stack:get_count() local max_count = stack:get_stack_max() if count > max_count then @@ -418,13 +435,9 @@ minetest.register_entity(":__builtin:item", { if itemtable then itemname = stack:to_table().name end - local item_texture = nil - local item_type = "" local glow local def = minetest.registered_items[itemname] if def then - item_texture = def.inventory_image - item_type = def.type description = def.description glow = def.light_source end @@ -572,7 +585,7 @@ minetest.register_entity(":__builtin:item", { return end self.age = self.age + dtime - if self._collector_timer ~= nil then + if self._collector_timer then self._collector_timer = self._collector_timer + dtime end if time_to_live > 0 and self.age > time_to_live then @@ -593,6 +606,12 @@ minetest.register_entity(":__builtin:item", { local node = minetest.get_node_or_nil(p) local in_unloaded = (node == nil) + if self.is_clock then + self.object:set_properties({ + textures = {"mcl_clock:clock_" .. (mcl_worlds.clock_works(p) and mcl_clock.old_time or mcl_clock.random_frame)} + }) + end + -- If no collector was found for a long enough time, declare the magnet as disabled if self._magnet_active and (self._collector_timer == nil or (self._collector_timer > item_drop_settings.magnet_time)) then self._magnet_active = false @@ -634,16 +653,6 @@ minetest.register_entity(":__builtin:item", { -- 1st: closest -- 2nd: other direction -- 3rd and 4th: other axis - local cxcz = function(o, cw, one, zero) - if cw < 0 then - table.insert(o, { [one]=1, y=0, [zero]=0 }) - table.insert(o, { [one]=-1, y=0, [zero]=0 }) - else - table.insert(o, { [one]=-1, y=0, [zero]=0 }) - table.insert(o, { [one]=1, y=0, [zero]=0 }) - end - return o - end if math.abs(cx) < math.abs(cz) then order = cxcz(order, cx, "x", "z") order = cxcz(order, cz, "z", "x") diff --git a/mods/ENTITIES/mcl_minecarts/functions.lua b/mods/ENTITIES/mcl_minecarts/functions.lua index 42cdecd1..2f0dfe0a 100644 --- a/mods/ENTITIES/mcl_minecarts/functions.lua +++ b/mods/ENTITIES/mcl_minecarts/functions.lua @@ -1,3 +1,5 @@ +local vector = vector + function mcl_minecarts:get_sign(z) if z == 0 then return 0 @@ -38,11 +40,9 @@ end function mcl_minecarts:check_front_up_down(pos, dir_, check_down, railtype) local dir = vector.new(dir_) - local cur = nil - -- Front dir.y = 0 - cur = vector.add(pos, dir) + local cur = vector.add(pos, dir) if mcl_minecarts:is_rail(cur, railtype) then return dir end @@ -65,9 +65,9 @@ end function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) local pos = vector.round(pos_) - local cur = nil + local cur local left_check, right_check = true, true - + -- Check left and right local left = {x=0, y=0, z=0} local right = {x=0, y=0, z=0} @@ -78,7 +78,7 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) left.z = dir.x right.z = -dir.x end - + if ctrl then if old_switch == 1 then left_check = false @@ -100,13 +100,13 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) right_check = true end end - + -- Normal cur = mcl_minecarts:check_front_up_down(pos, dir, true, railtype) if cur then return cur end - + -- Left, if not already checked if left_check then cur = mcl_minecarts:check_front_up_down(pos, left, false, railtype) @@ -114,7 +114,7 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) return cur end end - + -- Right, if not already checked if right_check then cur = mcl_minecarts:check_front_up_down(pos, right, false, railtype) @@ -122,7 +122,6 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) return cur end end - -- Backwards if not old_switch then cur = mcl_minecarts:check_front_up_down(pos, { @@ -134,7 +133,5 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) return cur end end - return {x=0, y=0, z=0} -end - +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index 70bf1647..e33e120a 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -1,9 +1,10 @@ -local S = minetest.get_translator("mcl_minecarts") +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) local has_mcl_wip = minetest.get_modpath("mcl_wip") mcl_minecarts = {} -mcl_minecarts.modpath = minetest.get_modpath("mcl_minecarts") +mcl_minecarts.modpath = minetest.get_modpath(modname) mcl_minecarts.speed_max = 10 mcl_minecarts.check_float_time = 15 @@ -204,7 +205,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o rou_pos = vector.round(pos) node = minetest.get_node(rou_pos) local g = minetest.get_item_group(node.name, "connect_to_raillike") - if g ~= self._railtype and self._railtype ~= nil then + if g ~= self._railtype and self._railtype then -- Detach driver if player then if self._old_pos then @@ -486,7 +487,6 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o if update.pos then self.object:set_pos(pos) end - update = nil end function cart:get_staticdata() @@ -497,7 +497,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o end -- Place a minecart at pointed_thing -mcl_minecarts.place_minecart = function(itemstack, pointed_thing, placer) +function mcl_minecarts.place_minecart(itemstack, pointed_thing, placer) if not pointed_thing.type == "node" then return end @@ -524,7 +524,7 @@ mcl_minecarts.place_minecart = function(itemstack, pointed_thing, placer) local cart = minetest.add_entity(railpos, entity_id) local railtype = minetest.get_item_group(node.name, "connect_to_raillike") local le = cart:get_luaentity() - if le ~= nil then + if le then le._railtype = railtype end local cart_dir = mcl_minecarts:get_rail_direction(railpos, {x=1, y=0, z=0}, nil, nil, railtype) @@ -541,7 +541,7 @@ mcl_minecarts.place_minecart = function(itemstack, pointed_thing, placer) end -local register_craftitem = function(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative) +local function register_craftitem(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative) entity_mapping[itemstring] = entity_id local groups = { minecart = 1, transport = 1 } @@ -607,7 +607,7 @@ Register a minecart local function register_minecart(itemstring, entity_id, description, tt_help, longdesc, usagehelp, mesh, textures, icon, drop, on_rightclick, on_activate_by_rail, creative) register_entity(entity_id, mesh, textures, drop, on_rightclick, on_activate_by_rail) register_craftitem(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative) - if minetest.get_modpath("doc_identifier") ~= nil then + if minetest.get_modpath("doc_identifier") then doc.sub.identifier.register_object(entity_id, "craftitems", itemstring) end end @@ -817,31 +817,30 @@ minetest.register_craft({ }) -- TODO: Re-enable crafting of special minecarts when they have been implemented -if false then - minetest.register_craft({ - output = "mcl_minecarts:furnace_minecart", - recipe = { - {"mcl_furnaces:furnace"}, - {"mcl_minecarts:minecart"}, - }, - }) +--[[minetest.register_craft({ + output = "mcl_minecarts:furnace_minecart", + recipe = { + {"mcl_furnaces:furnace"}, + {"mcl_minecarts:minecart"}, + }, +}) - minetest.register_craft({ - output = "mcl_minecarts:hopper_minecart", - recipe = { - {"mcl_hoppers:hopper"}, - {"mcl_minecarts:minecart"}, - }, - }) +minetest.register_craft({ + output = "mcl_minecarts:hopper_minecart", + recipe = { + {"mcl_hoppers:hopper"}, + {"mcl_minecarts:minecart"}, + }, +}) + +minetest.register_craft({ + output = "mcl_minecarts:chest_minecart", + recipe = { + {"mcl_chests:chest"}, + {"mcl_minecarts:minecart"}, + }, +})]] - minetest.register_craft({ - output = "mcl_minecarts:chest_minecart", - recipe = { - {"mcl_chests:chest"}, - {"mcl_minecarts:minecart"}, - }, - }) -end if has_mcl_wip then mcl_wip.register_wip_item("mcl_minecarts:chest_minecart") diff --git a/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.de.tr b/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.de.tr index 4d9b6c2f..1d270ee6 100644 --- a/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.de.tr +++ b/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.de.tr @@ -33,3 +33,4 @@ Activates minecarts when powered=Aktiviert Loren, wenn bestromt Emits redstone power when a minecart is detected=Gibt ein Redstonesignal aus, wenn eine Lore erfasst wird Vehicle for fast travel on rails=Fahrzeug zum schnellen Transport auf Schienen Can be ignited by tools or powered activator rail=Kann mit Werkzeugen oder bestromten Aktivierungsschienen angezündet werden +Sneak to dismount=Zum Aussteigen schleichen diff --git a/mods/ENTITIES/mcl_minecarts/rails.lua b/mods/ENTITIES/mcl_minecarts/rails.lua index 4c26aea8..91282f25 100644 --- a/mods/ENTITIES/mcl_minecarts/rails.lua +++ b/mods/ENTITIES/mcl_minecarts/rails.lua @@ -1,7 +1,7 @@ -local S = minetest.get_translator("mcl_minecarts") +local S = minetest.get_translator(minetest.get_current_modname()) -- Template rail function -local register_rail = function(itemstring, tiles, def_extras, creative) +local function register_rail(itemstring, tiles, def_extras, creative) local groups = {handy=1,pickaxey=1, attached_node=1,rail=1,connect_to_raillike=minetest.raillike_group("rail"),dig_by_water=1,destroy_by_lava_flow=1, transport=1} if creative == false then groups.not_in_creative_inventory = 1 @@ -206,11 +206,11 @@ register_rail("mcl_minecarts:detector_rail_on", -- Crafting minetest.register_craft({ - output = 'mcl_minecarts:rail 16', + output = "mcl_minecarts:rail 16", recipe = { - {'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:stick', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'}, + {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:stick", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, } }) diff --git a/mods/ENTITIES/mcl_mobs/readme.MD b/mods/ENTITIES/mcl_mobs/README.md similarity index 100% rename from mods/ENTITIES/mcl_mobs/readme.MD rename to mods/ENTITIES/mcl_mobs/README.md diff --git a/mods/ENTITIES/mcl_mobs/api.txt b/mods/ENTITIES/mcl_mobs/api.txt index eda74aeb..2d8cef5b 100644 --- a/mods/ENTITIES/mcl_mobs/api.txt +++ b/mods/ENTITIES/mcl_mobs/api.txt @@ -502,20 +502,6 @@ and damages any entity caught inside the blast radius. Protection will limit node destruction but not entity damage. -mobs:capture_mob ----------------- - -mobs:capture_mob(...) - -Does nothing and returns false. - -This function is provided for compability with Mobs Redo for an attempt to -capture a mob. -Mobs cannot be captured in MineClone 2. - -In Mobs Redo, this is generally called inside the on_rightclick section of the mob -api code, it provides a chance of capturing the mob. See Mobs Redo documentation -of parameters. Feeding and Taming/Breeding --------------------------- @@ -535,19 +521,6 @@ Will return true when mob is fed with item it likes. them up -Protecting Mobs ---------------- - -mobs:protect(self, clicker) - -This function can be used to right-click any tamed mob with mobs:protector item, -this will protect the mob from harm inside of a protected area from other -players. Will return true when mob right-clicked with mobs:protector item. - - 'self' mob information - 'clicker' player information - - Riding Mobs ----------- @@ -605,7 +578,7 @@ Note: animation names above are from the pre-defined animation lists inside mob registry without extensions. -mobs:set_animation(self, name) +mobs.set_mob_animation(self, name) This function sets the current animation for mob, defaulting to "stand" if not found. @@ -781,8 +754,5 @@ mobs:register_mob("mob_horse:horse", { inv:remove_item("main", "mobs:saddle") end end - - -- used to capture horse with magic lasso - mobs:capture_mob(self, clicker, 0, 0, 80, false, nil) end }) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua new file mode 100644 index 00000000..d1840f67 --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -0,0 +1,735 @@ +-- API for Mobs Redo: MineClone 2 Delux 2.0 DRM Free Early Access Super Extreme Edition + +-- mobs library +mobs = {} + +-- lua locals - can grab from this to easily plop them into the api lua files + +--localize minetest functions +local minetest_settings = minetest.settings +local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius +local minetest_get_modpath = minetest.get_modpath +local minetest_registered_nodes = minetest.registered_nodes +local minetest_get_node = minetest.get_node +--local minetest_get_item_group = minetest.get_item_group +local minetest_registered_entities = minetest.registered_entities +--local minetest_line_of_sight = minetest.line_of_sight +--local minetest_after = minetest.after +--local minetest_sound_play = minetest.sound_play +--local minetest_add_particlespawner = minetest.add_particlespawner +--local minetest_registered_items = minetest.registered_items +--local minetest_set_node = minetest.set_node +local minetest_add_item = minetest.add_item +--local minetest_get_craft_result = minetest.get_craft_result +--local minetest_find_path = minetest.find_path +local minetest_is_creative_enabled = minetest.is_creative_enabled +--local minetest_find_node_near = minetest.find_node_near +--local minetest_find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air +--local minetest_raycast = minetest.raycast +--local minetest_get_us_time = minetest.get_us_time +local minetest_add_entity = minetest.add_entity +--local minetest_get_natural_light = minetest.get_natural_light +--local minetest_get_node_or_nil = minetest.get_node_or_nil + +-- localize math functions +local math = math + +-- localize vector functions +local vector = vector + +local string = string + +-- mob constants +--local BREED_TIME = 30 +--local BREED_TIME_AGAIN = 300 +--local CHILD_GROW_TIME = 60*20 +--local DEATH_DELAY = 0.5 +local DEFAULT_FALL_SPEED = -10 +--local FLOP_HEIGHT = 5.0 +--local FLOP_HOR_SPEED = 1.5 +local GRAVITY = minetest_settings:get("movement_gravity")-- + 9.81 + +local MAX_MOB_NAME_LENGTH = 30 + + +--[[local MOB_CAP = {} +MOB_CAP.hostile = 70 +MOB_CAP.passive = 10 +MOB_CAP.ambient = 15 +MOB_CAP.water = 15 +]] + +-- Load main settings +--local damage_enabled = minetest_settings:get_bool("enable_damage") +--local disable_blood = minetest_settings:get_bool("mobs_disable_blood") +--local mobs_drop_items = minetest_settings:get_bool("mobs_drop_items") ~= false +--local mobs_griefing = minetest_settings:get_bool("mobs_griefing") ~= false +--local spawn_protected = minetest_settings:get_bool("mobs_spawn_protected") ~= false +--local remove_far = true +local difficulty = tonumber(minetest_settings:get("mob_difficulty")) or 1.0 +--local show_health = false +--local max_per_block = tonumber(minetest_settings:get("max_objects_per_block") or 64) +---local mobs_spawn_chance = tonumber(minetest_settings:get("mobs_spawn_chance") or 2.5) + +-- pathfinding settings +--local enable_pathfinding = true +--local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching +--local stuck_path_timeout = 10 -- how long will mob follow path before giving up + +-- default nodes +--local node_ice = "mcl_core:ice" +--local node_snowblock = "mcl_core:snowblock" +--local node_snow = "mcl_core:snow" +mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt" + +--local mod_weather = minetest_get_modpath("mcl_weather") +--local mod_explosions = minetest_get_modpath("mcl_explosions") +local mod_mobspawners = minetest_get_modpath("mcl_mobspawners") +--local mod_hunger = minetest_get_modpath("mcl_hunger") +--local mod_worlds = minetest_get_modpath("mcl_worlds") +--local mod_armor = minetest_get_modpath("mcl_armor") +--local mod_experience = minetest_get_modpath("mcl_experience") + + +-- random locals I found +--local los_switcher = false +--local height_switcher = false + +-- Get translator +local S = minetest.get_translator(minetest.get_current_modname()) + +-- CMI support check +--local use_cmi = minetest.global_exists("cmi") + +-- creative check +function mobs.is_creative(name) + return minetest_is_creative_enabled(name) +end + +--[[local function atan(x) + if not x or x ~= x then + return 0 + else + return math.atan(x) + end +end]] + +-- Shows helpful debug info above each mob +--local mobs_debug = minetest_settings:get_bool("mobs_debug", false) + +-- Peaceful mode message so players will know there are no monsters +if minetest_settings:get_bool("only_peaceful_mobs", false) then + minetest.register_on_joinplayer(function(player) + minetest.chat_send_player(player:get_player_name(), + S("Peaceful mode active! No monsters will spawn.")) + end) +end + + +local api_path = minetest.get_modpath(minetest.get_current_modname()).."/api/mob_functions/" + +--ignite all parts of the api +dofile(api_path .. "ai.lua") +dofile(api_path .. "animation.lua") +dofile(api_path .. "collision.lua") +dofile(api_path .. "environment.lua") +dofile(api_path .. "interaction.lua") +dofile(api_path .. "movement.lua") +dofile(api_path .. "set_up.lua") +dofile(api_path .. "attack_type_instructions.lua") +dofile(api_path .. "sound_handling.lua") +dofile(api_path .. "death_logic.lua") +dofile(api_path .. "mob_effects.lua") +dofile(api_path .. "projectile_handling.lua") +dofile(api_path .. "breeding.lua") +dofile(api_path .. "head_logic.lua") + + +mobs.spawning_mobs = {} + + + + +-- register mob entity +function mobs:register_mob(name, def) + + local collisionbox = def.collisionbox or {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25} + + -- Workaround for : + -- Increase upper Y limit to avoid mobs glitching through solid nodes. + -- FIXME: Remove workaround if it's no longer needed. + + if collisionbox[5] < 0.79 then + collisionbox[5] = 0.79 + end + + mobs.spawning_mobs[name] = true + + local function scale_difficulty(value, default, min, special) + if (not value) or (value == default) or (value == special) then + return default + else + return math.max(min, value * difficulty) + end + end + + minetest.register_entity(name, { + description = def.description, + use_texture_alpha = def.use_texture_alpha, + stepheight = def.stepheight or 0.6, + stepheight_backup = def.stepheight or 0.6, + name = name, + type = def.type, + attack_type = def.attack_type, + fly = def.fly, + fly_in = def.fly_in or {"air", "__airlike"}, + owner = def.owner or "", + order = def.order or "", + on_die = def.on_die, + spawn_small_alternative = def.spawn_small_alternative, + do_custom = def.do_custom, + jump_height = def.jump_height or 4, -- was 6 + rotate = def.rotate or 0, -- 0=front, 90=side, 180=back, 270=side2 + hp_min = scale_difficulty(def.hp_min, 5, 1), + hp_max = scale_difficulty(def.hp_max, 10, 1), + xp_min = def.xp_min or 1, + xp_max = def.xp_max or 5, + breath_max = def.breath_max or 6, + breathes_in_water = def.breathes_in_water or false, + physical = true, + collisionbox = collisionbox, + collide_with_objects = def.collide_with_objects or false, + selectionbox = def.selectionbox or def.collisionbox, + visual = def.visual, + visual_size = def.visual_size or {x = 1, y = 1}, + mesh = def.mesh, + makes_footstep_sound = def.makes_footstep_sound or false, + view_range = def.view_range or 16, + walk_velocity = def.walk_velocity or 1, + run_velocity = def.run_velocity or 2, + damage = scale_difficulty(def.damage, 0, 0), + light_damage = def.light_damage or 0, + sunlight_damage = def.sunlight_damage or 0, + water_damage = def.water_damage or 0, + lava_damage = def.lava_damage or 8, + fire_damage = def.fire_damage or 1, + suffocation = def.suffocation or true, + fall_damage = def.fall_damage or 1, + fall_speed = def.fall_speed or DEFAULT_FALL_SPEED, -- must be lower than -2 + drops = def.drops or {}, + armor = def.armor or 100, + on_rightclick = mobs.create_mob_on_rightclick(def.on_rightclick), + arrow = def.arrow, + shoot_interval = def.shoot_interval, + sounds = def.sounds or {}, + animation = def.animation, + jump = def.jump ~= false, + walk_chance = def.walk_chance or 50, + attacks_monsters = def.attacks_monsters or false, + group_attack = def.group_attack or false, + passive = def.passive or false, + knock_back = def.knock_back ~= false, + shoot_offset = def.shoot_offset or 0, + floats = def.floats or 1, -- floats in water by default + floats_on_lava = def.floats_on_lava or 0, + replace_rate = def.replace_rate, + replace_what = def.replace_what, + replace_with = def.replace_with, + replace_offset = def.replace_offset or 0, + on_replace = def.on_replace, + timer = 0, + state_timer = 0, + env_damage_timer = 0, + tamed = false, + pause_timer = 0, + gotten = false, + reach = def.reach or 3, + htimer = 0, + texture_list = def.textures, + child_texture = def.child_texture, + docile_by_day = def.docile_by_day or false, + time_of_day = 0.5, + fear_height = def.fear_height or 0, + runaway = def.runaway, + runaway_timer = 0, + pathfinding = def.pathfinding, + immune_to = def.immune_to or {}, + explosion_radius = def.explosion_radius, -- LEGACY + explosion_damage_radius = def.explosion_damage_radius, -- LEGACY + explosiontimer_reset_radius = def.explosiontimer_reset_radius, + explosion_timer = def.explosion_timer or 3, + allow_fuse_reset = def.allow_fuse_reset ~= false, + stop_to_explode = def.stop_to_explode ~= false, + custom_attack = def.custom_attack, + double_melee_attack = def.double_melee_attack, + dogshoot_switch = def.dogshoot_switch, + dogshoot_count = 0, + dogshoot_count_max = def.dogshoot_count_max or 5, + dogshoot_count2_max = def.dogshoot_count2_max or (def.dogshoot_count_max or 5), + attack_animals = def.attack_animals or false, + specific_attack = def.specific_attack, + runaway_from = def.runaway_from, + owner_loyal = def.owner_loyal, + facing_fence = false, + + _cmi_is_mob = true, + + pushable = def.pushable or true, + + --j4i stuff + yaw = 0, + automatic_face_movement_dir = def.rotate or 0, -- 0=front, 90=side, 180=back, 270=side2 + automatic_face_movement_max_rotation_per_sec = 360, --degrees + backface_culling = true, + walk_timer = 0, + stand_timer = 0, + current_animation = "", + gravity = GRAVITY, + swim = def.swim, + swim_in = def.swim_in or {mobs_mc.items.water_source, "mcl_core:water_flowing", mobs_mc.items.river_water_source}, + pitch_switch = "static", + jump_only = def.jump_only, + hostile = def.hostile, + neutral = def.neutral, + attacking = nil, + visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1}, + punch_timer_cooloff = def.punch_timer_cooloff or 0.5, + death_animation_timer = 0, + hostile_cooldown = def.hostile_cooldown or 15, + tilt_fly = def.tilt_fly, + tilt_swim = def.tilt_swim, + fall_slow = def.fall_slow, + projectile_cooldown_min = def.projectile_cooldown_min or 2, + projectile_cooldown_max = def.projectile_cooldown_max or 6, + skittish = def.skittish, + + minimum_follow_distance = def.minimum_follow_distance or 0.5, --make mobs not freak out when underneath + + memory = 0, -- memory timer if chasing/following + fly_random_while_attack = def.fly_random_while_attack, + + --for spiders + always_climb = def.always_climb, + + --despawn mechanic variables + lifetimer_reset = 30, --30 seconds + lifetimer = 30, --30 seconds + + --breeding stuff + breed_timer = 0, + breed_lookout_timer = 0, + breed_distance = def.breed_distance or 1.5, --how far away mobs have to be to begin actual breeding + breed_lookout_timer_goal = 30, --30 seconds (this timer is for how long the mob looks for a mate) + breed_timer_cooloff = 5*60, -- 5 minutes (this timer is for how long the mob has to wait before being bred again) + bred = false, + follow = def.follow, --this item is also used for the breeding mechanism + follow_distance = def.follow_distance or 2, + baby_size = def.baby_size or 0.5, + baby = false, + grow_up_timer = 0, + grow_up_goal = 20*60, --in 20 minutes the mob grows up + special_breed_timer = 0, --this is used for the AHEM AHEM part of breeding + + backup_visual_size = def.visual_size, + backup_collisionbox = collisionbox, + backup_selectionbox = def.selectionbox or def.collisionbox, + + + --fire timer + burn_timer = 0, + + ignores_cobwebs = def.ignores_cobwebs, + breath = def.breath_max or 6, + + random_sound_timer_min = 3, + random_sound_timer_max = 10, + + --head code variables + --defaults are for the cow's default + --because I don't know what else to set them + --to :P + + --you must use these to adjust the mob's head positions + + --has_head is used as a logic gate (quick easy check) + has_head = def.has_head or false, + --head_bone is the actual bone in the model which the head + --is attached to for animation + head_bone = def.head_bone or "head", + + --this part controls the base position of the head calculations + --localized to the mob's visual yaw when gotten (self.object:get_yaw()) + --you can enable the debug in /mob_functions/head_logic.lua by uncommenting the + --particle spawner code + head_height_offset = def.head_height_offset or 1.0525, + head_direction_offset = def.head_direction_offset or 0.5, + + --this part controls the visual of the head + head_bone_pos_y = def.head_bone_pos_y or 3.6, + head_bone_pos_z = def.head_bone_pos_z or -0.6, + head_pitch_modifier = def.head_pitch_modifier or 0, + + --these variables are switches in case the model + --moves the wrong way + swap_y_with_x = def.swap_y_with_x or false, + reverse_head_yaw = def.reverse_head_yaw or false, + + --END HEAD CODE VARIABLES + + --end j4i stuff + + -- MCL2 extensions + teleport = mobs.teleport, + do_teleport = def.do_teleport, + spawn_class = def.spawn_class, + ignores_nametag = def.ignores_nametag or false, + rain_damage = def.rain_damage or 0, + glow = def.glow, + --can_despawn = can_despawn, + child = def.child or false, + texture_mods = {}, + shoot_arrow = def.shoot_arrow, + sounds_child = def.sounds_child, + explosion_strength = def.explosion_strength, + suffocation_timer = 0, + follow_velocity = def.follow_velocity or 2.4, + instant_death = def.instant_death or false, + fire_resistant = def.fire_resistant or false, + fire_damage_resistant = def.fire_damage_resistant or false, + ignited_by_sunlight = def.ignited_by_sunlight or false, + eye_height = def.eye_height or 1.5, + defuse_reach = def.defuse_reach or 4, + -- End of MCL2 extensions + + on_spawn = def.on_spawn, + + --on_blast = def.on_blast or do_tnt, + + on_step = mobs.mob_step, + + --do_punch = def.do_punch, + + on_punch = mobs.mob_punch, + + --on_breed = def.on_breed, + + --on_grown = def.on_grown, + + --on_detach_child = mob_detach_child, + + on_activate = function(self, staticdata, dtime) + self.object:set_acceleration(vector.new(0,-GRAVITY, 0)) + return mobs.mob_activate(self, staticdata, def, dtime) + end, + + get_staticdata = function(self) + return mobs.mob_staticdata(self) + end, + + --harmed_by_heal = def.harmed_by_heal, + }) + + if minetest_get_modpath("doc_identifier") then + doc.sub.identifier.register_object(name, "basics", "mobs") + end + +end -- END mobs:register_mob function + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-- register arrow for shoot attack +function mobs:register_arrow(name, def) + + -- errorcheck + if not name or not def then + print("failed to register arrow entity") + return + end + + minetest.register_entity(name.."_entity", { + + physical = false, + visual = def.visual, + visual_size = def.visual_size, + textures = def.textures, + velocity = def.velocity, + hit_player = def.hit_player, + hit_node = def.hit_node, + hit_mob = def.hit_mob, + hit_object = def.hit_object, + drop = def.drop or false, -- drops arrow as registered item when true + collisionbox = {0, 0, 0, 0, 0, 0}, -- remove box around arrows + timer = 0, + switch = 0, + owner_id = def.owner_id, + rotate = def.rotate, + speed = def.speed or nil, + on_step = function(self) + + local vel = self.object:get_velocity() + + local pos = self.object:get_pos() + + if self.timer > 150 + or not mobs.within_limits(pos, 0) then + mcl_burning.extinguish(self.object) + self.object:remove(); + return + end + + -- does arrow have a tail (fireball) + if def.tail + and def.tail == 1 + and def.tail_texture then + + --do this to prevent clipping through main entity sprite + local pos_adjustment = vector.multiply(vector.normalize(vel), -1) + local divider = def.tail_distance_divider or 1 + pos_adjustment = vector.divide(pos_adjustment, divider) + local new_pos = vector.add(pos, pos_adjustment) + minetest.add_particle({ + pos = new_pos, + velocity = {x = 0, y = 0, z = 0}, + acceleration = {x = 0, y = 0, z = 0}, + expirationtime = def.expire or 0.25, + collisiondetection = false, + texture = def.tail_texture, + size = def.tail_size or 5, + glow = def.glow or 0, + }) + end + + if self.hit_node then + + local node = minetest_get_node(pos).name + + if minetest_registered_nodes[node].walkable then + + self.hit_node(self, pos, node) + + if self.drop == true then + + pos.y = pos.y + 1 + + self.lastpos = (self.lastpos or pos) + + minetest_add_item(self.lastpos, self.object:get_luaentity().name) + end + + self.object:remove(); + + return + end + end + + if self.hit_player or self.hit_mob or self.hit_object then + + for _,player in pairs(minetest_get_objects_inside_radius(pos, 1.5)) do + + if self.hit_player + and player:is_player() then + + if self.hit_player then + self.hit_player(self, player) + else + mobs.arrow_hit(self, player) + end + + self.object:remove(); + return + end + + --[[ + local entity = player:get_luaentity() + + if entity + and self.hit_mob + and entity._cmi_is_mob == true + and tostring(player) ~= self.owner_id + and entity.name ~= self.object:get_luaentity().name + and (self._shooter and entity.name ~= self._shooter:get_luaentity().name) then + + --self.hit_mob(self, player) + self.object:remove(); + return + end + ]]-- + + --[[ + if entity + and self.hit_object + and (not entity._cmi_is_mob) + and tostring(player) ~= self.owner_id + and entity.name ~= self.object:get_luaentity().name + and (self._shooter and entity.name ~= self._shooter:get_luaentity().name) then + + --self.hit_object(self, player) + self.object:remove(); + return + end + ]]-- + end + end + + self.lastpos = pos + end + }) +end + +-- Register spawn eggs + +-- Note: This also introduces the “spawn_egg” group: +-- * spawn_egg=1: Spawn egg (generic mob, no metadata) +-- * spawn_egg=2: Spawn egg (captured/tamed mob, metadata) +function mobs:register_egg(mob, desc, background, addegg, no_creative) + + local grp = {spawn_egg = 1} + + -- do NOT add this egg to creative inventory (e.g. dungeon master) + if no_creative == true then + grp.not_in_creative_inventory = 1 + end + + local invimg = background + + if addegg == 1 then + invimg = "mobs_chicken_egg.png^(" .. invimg .. + "^[mask:mobs_chicken_egg_overlay.png)" + end + + -- register old stackable mob egg + minetest.register_craftitem(mob, { + + description = desc, + inventory_image = invimg, + groups = grp, + + _doc_items_longdesc = S("This allows you to place a single mob."), + _doc_items_usagehelp = S("Just place it where you want the mob to appear. Animals will spawn tamed, unless you hold down the sneak key while placing. If you place this on a mob spawner, you change the mob it spawns."), + + on_place = function(itemstack, placer, pointed_thing) + + local pos = pointed_thing.above + + -- am I clicking on something with existing on_rightclick function? + local under = minetest_get_node(pointed_thing.under) + local def = minetest_registered_nodes[under.name] + if def and def.on_rightclick then + return def.on_rightclick(pointed_thing.under, under, placer, itemstack) + end + + if pos + --and within_limits(pos, 0) + and not minetest.is_protected(pos, placer:get_player_name()) then + + local name = placer:get_player_name() + local privs = minetest.get_player_privs(name) + if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then + if minetest.is_protected(pointed_thing.under, name) then + minetest.record_protection_violation(pointed_thing.under, name) + return itemstack + end + if not privs.maphack then + minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner.")) + return itemstack + end + mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name()) + if not mobs.is_creative(name) then + itemstack:take_item() + end + return itemstack + end + + if not minetest_registered_entities[mob] then + return itemstack + end + + if minetest_settings:get_bool("only_peaceful_mobs", false) + and minetest_registered_entities[mob].type == "monster" then + minetest.chat_send_player(name, S("Only peaceful mobs allowed!")) + return itemstack + end + + local mob = minetest_add_entity(pos, mob) + minetest.log("action", "Mob spawned: "..name.." at "..minetest.pos_to_string(pos)) + local ent = mob:get_luaentity() + + -- don't set owner if monster or sneak pressed + --[[ + if ent.type ~= "monster" + and not placer:get_player_control().sneak then + ent.owner = placer:get_player_name() + ent.tamed = true + end + ]]-- + + -- set nametag + local nametag = itemstack:get_meta():get_string("name") + if nametag ~= "" then + if string.len(nametag) > MAX_MOB_NAME_LENGTH then + nametag = string.sub(nametag, 1, MAX_MOB_NAME_LENGTH) + end + ent.nametag = nametag + --update_tag(ent) + end + + -- if not in creative then take item + if not mobs.is_creative(placer:get_player_name()) then + itemstack:take_item() + end + end + + return itemstack + end, + }) + +end + + diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua new file mode 100644 index 00000000..d16d2492 --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -0,0 +1,1113 @@ +local math = math +local vector = vector +local string = string + +local tonumber = tonumber + +local minetest_yaw_to_dir = minetest.yaw_to_dir +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 DOUBLE_PI = math.pi * 2 +local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125 + +--a simple helper function which is too small to move into movement.lua +local function quick_rotate(self,dtime) + self.yaw = self.yaw + THIRTY_SECONDTH_PI + if self.yaw > DOUBLE_PI then + self.yaw = self.yaw - DOUBLE_PI + end +end + +--a simple helper function for rounding +--http://lua-users.org/wiki/SimpleRound +local function round2(num, numDecimalPlaces) + return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num)) +end + + +--[[ + _ _ +| | | | +| | __ _ _ __ __| | +| | / _` | '_ \ / _` | +| |___| (_| | | | | (_| | +\_____/\__,_|_| |_|\__,_| +]]-- + +--this is basically reverse jump_check +local function cliff_check(self,dtime) + --mobs will flip out if they are falling without this + if self.object:get_velocity().y ~= 0 then + return false + end + + local pos = self.object:get_pos() + local dir = minetest_yaw_to_dir(self.yaw) + local collisionbox = self.object:get_properties().collisionbox + local radius = collisionbox[4] + 0.5 + + dir = vector.multiply(dir,radius) + + local free_fall = minetest_line_of_sight( + {x = pos.x + dir.x, y = pos.y, z = pos.z + dir.z}, + {x = pos.x + dir.x, y = pos.y - self.fear_height, z = pos.z + dir.z}) + + return free_fall +end + +-- state switching logic (stand, walk, run, attacks) +local land_state_list_wandering = {"stand", "walk"} + +local function land_state_switch(self, dtime) + + --do math before sure not attacking, following, or running away so continue + --doing random walking for mobs if all states are not met + self.state_timer = self.state_timer - dtime + + --only run away + if self.skittish and self.state == "run" then + self.run_timer = self.run_timer - dtime + if self.run_timer > 0 then + return + end + --continue + end + + --ignore everything else if breeding + if self.breed_lookout_timer and self.breed_lookout_timer > 0 then + self.state = "breed" + return + --reset the state timer to get the mob out of + --the breed state + elseif self.state == "breed" then + self.state_timer = 0 + end + + --ignore everything else if following + if mobs.check_following(self) and + (not self.breed_lookout_timer or (self.breed_lookout_timer and self.breed_lookout_timer == 0)) and + (not self.breed_timer or (self.breed_timer and self.breed_timer == 0)) then + self.state = "follow" + return + --reset the state timer to get the mob out of + --the follow state - not the cleanest option + --but the easiest + elseif self.state == "follow" then + self.state_timer = 0 + end + + --only attack + if self.hostile and self.attacking then + self.state = "attack" + return + end + + --if finally reached here then do random wander + if self.state_timer <= 0 then + self.state_timer = math.random(4,10) + math.random() + self.state = land_state_list_wandering[math.random(1,#land_state_list_wandering)] + end + +end + +-- states are executed here +local function land_state_execution(self, dtime) + + --[[ -- this is a debug which shows the timer and makes mobs breed 100 times faster + print(self.breed_timer) + if self.breed_timer > 0 then + self.breed_timer = self.breed_timer - (dtime * 100) + if self.breed_timer <= 0 then + self.breed_timer = 0 + end + end + ]]-- + + --no collisionbox exception + if not self.object:get_properties() then + return + end + + --timer to time out looking for mate + if self.breed_lookout_timer and self.breed_lookout_timer > 0 then + self.breed_lookout_timer = self.breed_lookout_timer - dtime + --looking for mate failed + if self.breed_lookout_timer <= 0 then + self.breed_lookout_timer = 0 + end + end + + --cool off after breeding + if self.breed_timer and self.breed_timer > 0 then + self.breed_timer = self.breed_timer - dtime + --do this to skip the first check, using as switch + if self.breed_timer <= 0 then + self.breed_timer = 0 + end + end + + + local pos = self.object:get_pos() + local collisionbox = self.object:get_properties().collisionbox + --get the center of the mob + pos.y = pos.y + (collisionbox[2] + collisionbox[5] / 2) + local current_node = minetest_get_node(pos).name + local float_now = false + + --recheck if in water or lava + if minetest_get_item_group(current_node, "water") ~= 0 or minetest_get_item_group(current_node, "lava") ~= 0 then + float_now = true + end + + --make slow falling mobs fall slow + if self.fall_slow then + local velocity = self.object:get_velocity() + if velocity then + if velocity.y < 0 then + --lua is acting really weird so we have to help it + if round2(self.object:get_acceleration().y, 1) == -self.gravity then + self.object:set_acceleration(vector.new(0,0,0)) + mobs.mob_fall_slow(self) + end + else + if round2(self.object:get_acceleration().y, 1) == 0 then + self.object:set_acceleration(vector.new(0,-self.gravity,0)) + end + end + end + end + + --calculate fall damage + if self.fall_damage then + mobs.calculate_fall_damage(self) + end + + if self.state == "stand" then + + --do animation + mobs.set_mob_animation(self, "stand") + + --set the velocity of the mob + mobs.set_velocity(self,0) + + --animation fixes for explosive mobs + if self.attack_type == "explode" then + mobs.reverse_explosion_animation(self,dtime) + end + + mobs.lock_yaw(self) + elseif self.state == "follow" then + --always look at players + mobs.set_yaw_while_following(self) + + --check distance + local distance_from_follow_person = vector.distance(self.object:get_pos(), self.following_person:get_pos()) + local distance_2d = mobs.get_2d_distance(self.object:get_pos(), self.following_person:get_pos()) + --don't push the player if too close + --don't spin around randomly + if self.follow_distance < distance_from_follow_person and self.minimum_follow_distance < distance_2d then + mobs.set_mob_animation(self, "run") + mobs.set_velocity(self,self.run_velocity) + + if mobs.jump_check(self) == 1 then + mobs.jump(self) + end + else + mobs.set_mob_animation(self, "stand") + mobs.set_velocity(self,0) + end + + elseif self.state == "walk" then + + self.walk_timer = self.walk_timer - dtime + + --reset the walk timer + if self.walk_timer <= 0 then + + --re-randomize the walk timer + self.walk_timer = math.random(1,6) + math.random() + + --set the mob into a random direction + self.yaw = (math.random() * (math.pi * 2)) + end + + --do animation + mobs.set_mob_animation(self, "walk") + + --enable rotation locking + mobs.movement_rotation_lock(self) + + --check for nodes to jump over + local node_in_front_of = mobs.jump_check(self) + + if node_in_front_of == 1 then + mobs.jump(self) + --turn if on the edge of cliff + --(this is written like this because unlike + --jump_check which simply tells the mob to jump + --this requires a mob to turn, removing the + --ease of a full implementation for it in a single + --function) + elseif node_in_front_of == 2 or (self.fear_height ~= 0 and cliff_check(self,dtime)) then + --turn 45 degrees if so + quick_rotate(self,dtime) + --stop the mob so it doesn't fall off + mobs.set_velocity(self,0) + end + + --only move forward if path is clear + if node_in_front_of == 0 or node_in_front_of == 1 then + --set the velocity of the mob + mobs.set_velocity(self,self.walk_velocity) + end + + --animation fixes for explosive mobs + if self.attack_type == "explode" then + mobs.reverse_explosion_animation(self,dtime) + end + + elseif self.state == "run" then + + --do animation + mobs.set_mob_animation(self, "run") + + --enable rotation locking + mobs.movement_rotation_lock(self) + + --check for nodes to jump over + local node_in_front_of = mobs.jump_check(self) + + if node_in_front_of == 1 then + mobs.jump(self) + --turn if on the edge of cliff + --(this is written like this because unlike + --jump_check which simply tells the mob to jump + --this requires a mob to turn, removing the + --ease of a full implementation for it in a single + --function) + elseif node_in_front_of == 2 or (self.fear_height ~= 0 and cliff_check(self,dtime)) then + --turn 45 degrees if so + quick_rotate(self,dtime) + --stop the mob so it doesn't fall off + mobs.set_velocity(self,0) + end + + --only move forward if path is clear + if node_in_front_of == 0 or node_in_front_of == 1 then + --set the velocity of the mob + mobs.set_velocity(self,self.run_velocity) + end + + elseif self.state == "attack" then + + --execute mob attack type + if self.attack_type == "explode" then + + mobs.explode_attack_walk(self, dtime) + + elseif self.attack_type == "punch" then + + mobs.punch_attack_walk(self,dtime) + + elseif self.attack_type == "projectile" then + + mobs.projectile_attack_walk(self,dtime) + + end + elseif self.state == "breed" then + + mobs.breeding_effect(self) + + local mate = mobs.look_for_mate(self) + + --found a mate + if mate then + mobs.set_yaw_while_breeding(self,mate) + mobs.set_velocity(self, self.walk_velocity) + + --smoosh together basically + if vector.distance(self.object:get_pos(), mate:get_pos()) <= self.breed_distance then + mobs.set_mob_animation(self, "stand") + if self.special_breed_timer == 0 then + self.special_breed_timer = 2 --breeding takes 2 seconds + end + + self.special_breed_timer = self.special_breed_timer - dtime + if self.special_breed_timer <= 0 then + + --pop a baby out, it's a miracle! + local baby_pos = vector.divide(vector.add(self.object:get_pos(), mate:get_pos()), 2) + minetest.add_entity(baby_pos, self.name, minetest.serialize({baby = true, grow_up_timer = self.grow_up_goal, bred = true})) + + mobs.play_sound_specific(self,"item_drop_pickup") + + self.special_breed_timer = 0 + self.breed_lookout_timer = 0 + self.breed_timer = self.breed_timer_cooloff + + mate:get_luaentity().special_breed_timer = 0 + mate:get_luaentity().breed_lookout_timer = 0 + mate:get_luaentity().breed_timer = self.breed_timer_cooloff -- can reuse because it's the same mob + end + else + mobs.set_mob_animation(self, "walk") + end + --couldn't find a mate, just stand there until the player pushes it towards one + --or the timer runs out + else + mobs.set_mob_animation(self, "stand") + mobs.set_velocity(self,0) + end + + end + if float_now then + mobs.float(self) + else + local acceleration = self.object:get_acceleration() + if acceleration and acceleration.y == 0 then + self.object:set_acceleration(vector.new(0,-self.gravity,0)) + end + end +end + + + + +--[[ + _____ _ +/ ___| (_) +\ `--.__ ___ _ __ ___ + `--. \ \ /\ / / | '_ ` _ \ +/\__/ /\ V V /| | | | | | | +\____/ \_/\_/ |_|_| |_| |_| +]]-- + + + +-- state switching logic (stand, walk, run, attacks) +local swim_state_list_wandering = {"stand", "swim"} + +local function swim_state_switch(self, dtime) + self.state_timer = self.state_timer - dtime + if self.state_timer <= 0 then + self.state_timer = math.random(4,10) + math.random() + self.state = swim_state_list_wandering[math.random(1,#swim_state_list_wandering)] + end +end + + +--check if a mob needs to turn while swimming +local function swim_turn_check(self,dtime) + + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + local dir = minetest_yaw_to_dir(self.yaw) + + local collisionbox = self.object:get_properties().collisionbox + local radius = collisionbox[4] + 0.5 + + vector.multiply(dir, radius) + + local test_dir = vector.add(pos,dir) + + local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0 + + return green_flag_1 +end + +--this is to swap the built in engine acceleration modifier +local function swim_physics_swapper(self, inside_swim_node) + --should be swimming, gravity is applied, switch to floating + if inside_swim_node and self.object:get_acceleration().y ~= 0 then + self.object:set_acceleration(vector.new(0,0,0)) + --not be swim, gravity isn't applied, switch to falling + elseif not inside_swim_node and self.object:get_acceleration().y == 0 then + self.pitch = 0 + self.object:set_acceleration(vector.new(0,-self.gravity,0)) + end +end + + +local random_pitch_multiplier = {-1,1} +-- states are executed here +local function swim_state_execution(self, dtime) + + local pos = self.object:get_pos() + + pos.y = pos.y + self.object:get_properties().collisionbox[5] + local current_node = minetest_get_node(pos).name + local inside_swim_node = false + + --quick scan everything to see if inside swim node + for _,id in pairs(self.swim_in) do + if id == current_node then + inside_swim_node = true + break + end + end + + --turn gravity on or off + swim_physics_swapper(self, inside_swim_node) + + --swim properly if inside swim node + if inside_swim_node then + + if self.state == "stand" then + + --do animation + mobs.set_mob_animation(self, "stand") + + mobs.set_swim_velocity(self,0) + + if self.tilt_swim then + mobs.set_static_pitch(self) + end + + mobs.lock_yaw(self) + elseif self.state == "swim" then + self.walk_timer = self.walk_timer - dtime + --reset the walk timer + if self.walk_timer <= 0 then + --re-randomize the walk timer + self.walk_timer = math.random(1,6) + math.random() + --set the mob into a random direction + self.yaw = (math.random() * (math.pi * 2)) + + --create a truly random pitch, since there is no easy access to pitch math that I can find + self.pitch = math.random() * math.random(1,3) * random_pitch_multiplier[math.random(1,2)] + end + + --do animation + mobs.set_mob_animation(self, "walk") + + --do a quick turn to make mob continuously move + --if in a fish tank or something + if swim_turn_check(self,dtime) then + quick_rotate(self,dtime) + end + + mobs.set_swim_velocity(self,self.walk_velocity) + + --only enable tilt swimming if enabled + if self.tilt_swim then + mobs.set_dynamic_pitch(self) + end + + --enable rotation locking + mobs.movement_rotation_lock(self) + end + --flop around if not inside swim node + else + --do animation + mobs.set_mob_animation(self, "stand") + + mobs.flop(self) + + if self.tilt_swim then + mobs.set_static_pitch(self) + end + end + +end + + +--[[ +______ _ +| ___| | +| |_ | |_ _ +| _| | | | | | +| | | | |_| | +\_| |_|\__, | + __/ | + |___/ +]]-- + +-- state switching logic (stand, walk, run, attacks) +local fly_state_list_wandering = {"stand", "fly"} + +local function fly_state_switch(self, dtime) + + if self.hostile and self.attacking then + self.state = "attack" + return + end + + self.state_timer = self.state_timer - dtime + if self.state_timer <= 0 then + self.state_timer = math.random(4,10) + math.random() + self.state = fly_state_list_wandering[math.random(1,#fly_state_list_wandering)] + end +end + + +--check if a mob needs to turn while flying +local function fly_turn_check(self, dtime) + + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + local dir = minetest_yaw_to_dir(self.yaw) + + local collisionbox = self.object:get_properties().collisionbox + local radius = collisionbox[4] + 0.5 + + vector.multiply(dir, radius) + + local test_dir = vector.add(pos,dir) + + local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0 + + return green_flag_1 +end + +--this is to swap the built in engine acceleration modifier +local function fly_physics_swapper(self, inside_fly_node) + + --should be flyming, gravity is applied, switch to floating + if inside_fly_node and self.object:get_acceleration().y ~= 0 then + self.object:set_acceleration(vector.new(0,0,0)) + --not be fly, gravity isn't applied, switch to falling + elseif not inside_fly_node and self.object:get_acceleration().y == 0 then + self.pitch = 0 + self.object:set_acceleration(vector.new(0,-self.gravity,0)) + end +end + + +local random_pitch_multiplier = {-1,1} +-- states are executed here +local function fly_state_execution(self, dtime) + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + local current_node = minetest_get_node(pos).name + local inside_fly_node = minetest_get_item_group(current_node, "solid") == 0 + + local float_now = false + --recheck if in water or lava + if minetest_get_item_group(current_node, "water") ~= 0 or minetest_get_item_group(current_node, "lava") ~= 0 then + inside_fly_node = false + float_now = true + end + + --turn gravity on or off + fly_physics_swapper(self,inside_fly_node) + + --fly properly if inside fly node + if inside_fly_node then + if self.state == "stand" then + + --do animation + mobs.set_mob_animation(self, "stand") + + mobs.set_fly_velocity(self,0) + + if self.tilt_fly then + mobs.set_static_pitch(self) + end + + mobs.lock_yaw(self) + + elseif self.state == "fly" then + + self.walk_timer = self.walk_timer - dtime + + --reset the walk timer + if self.walk_timer <= 0 then + --re-randomize the walk timer + self.walk_timer = math.random(1,6) + math.random() + --set the mob into a random direction + self.yaw = (math.random() * (math.pi * 2)) + + --create a truly random pitch, since there is no easy access to pitch math that I can find + self.pitch = math.random() * math.random(1,3) * random_pitch_multiplier[math.random(1,2)] + end + + --do animation + mobs.set_mob_animation(self, "walk") + + --do a quick turn to make mob continuously move + --if in a bird cage or something + if fly_turn_check(self,dtime) then + quick_rotate(self,dtime) + end + + if self.tilt_fly then + mobs.set_dynamic_pitch(self) + end + + mobs.set_fly_velocity(self,self.walk_velocity) + + --enable rotation locking + mobs.movement_rotation_lock(self) + elseif self.state == "attack" then + --execute mob attack type + --if self.attack_type == "explode" then + + --mobs.explode_attack_fly(self, dtime) + + --elseif self.attack_type == "punch" then + + --mobs.punch_attack_fly(self,dtime) + + if self.attack_type == "projectile" then + + mobs.projectile_attack_fly(self,dtime) + + end + end + else + --make the mob float + if self.floats and float_now then + mobs.set_velocity(self, 0) + + mobs.float(self) + + if self.tilt_fly then + mobs.set_static_pitch(self) + end + end + end +end + + +--[[ + ___ + |_ | + | |_ _ _ __ ___ _ __ + | | | | | '_ ` _ \| '_ \ +/\__/ / |_| | | | | | | |_) | +\____/ \__,_|_| |_| |_| .__/ + | | + |_| +]]-- + + +--check if a mob needs to turn while jumping +--[[local function jump_turn_check(self, dtime) + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + local dir = minetest_yaw_to_dir(self.yaw) + + local collisionbox = self.object:get_properties().collisionbox + local radius = collisionbox[4] + 0.5 + + vector.multiply(dir, radius) + + local test_dir = vector.add(pos,dir) + + local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0 + + return green_flag_1 +end]] + +-- state switching logic (stand, jump, run, attacks) +local jump_state_list_wandering = {"stand", "jump"} + +local function jump_state_switch(self, dtime) + self.state_timer = self.state_timer - dtime + if self.state_timer <= 0 then + self.state_timer = math.random(4,10) + math.random() + self.state = jump_state_list_wandering[math.random(1,#jump_state_list_wandering)] + end +end + +-- states are executed here +local function jump_state_execution(self, dtime) + local node_in_front_of = mobs.jump_check(self) + local pos = self.object:get_pos() + local collisionbox = self.object:get_properties().collisionbox + --get the center of the mob + pos.y = pos.y + (collisionbox[2] + collisionbox[5] / 2) + local current_node = minetest_get_node(pos).name + + local float_now = false + + --recheck if in water or lava + if minetest_get_item_group(current_node, "water") ~= 0 or minetest_get_item_group(current_node, "lava") ~= 0 then + float_now = true + end + + if self.state == "stand" then + + --do animation + mobs.set_mob_animation(self, "stand") + + --set the velocity of the mob + mobs.set_velocity(self,0) + + mobs.lock_yaw(self) + + elseif self.state == "jump" then + + self.walk_timer = self.walk_timer - dtime + + --reset the jump timer + if self.walk_timer <= 0 then + + --re-randomize the jump timer + self.walk_timer = math.random(1,6) + math.random() + + --set the mob into a random direction + self.yaw = (math.random() * (math.pi * 2)) + end + + --do animation + mobs.set_mob_animation(self, "walk") + + --enable rotation locking + mobs.movement_rotation_lock(self) + + --jumping mobs are more loosey goosey + if node_in_front_of == 1 then + quick_rotate(self,dtime) + end + + --only move forward if path is clear + mobs.jump_move(self,self.walk_velocity) + + elseif self.state == "run" then + print("run") + elseif self.state == "attack" then + print("attack") + end + if float_now then + mobs.float(self) + end +end + + + + +--[[ +___ ___ _ _ _ +| \/ | (_) | | (_) +| . . | __ _ _ _ __ | | ___ __ _ _ ___ +| |\/| |/ _` | | '_ \ | | / _ \ / _` | |/ __| +| | | | (_| | | | | | | |___| (_) | (_| | | (__ +\_| |_/\__,_|_|_| |_| \_____/\___/ \__, |_|\___| + __/ | + |___/ +]]-- + +--the main loop +function mobs.mob_step(self, dtime) + + --do not continue if non-existent + if not self or not self.object or not self.object:get_luaentity() then + self.object:remove() + return false + end + + + --DEBUG TIME! + --REMEMBER TO MOVE THIS AFTER DEATH CHECK + + --if self.has_head then + -- mobs.do_head_logic(self,dtime) + --end + + + + --if true then--DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + -- return + --end + + --despawn mechanism + --don't despawned tamed or bred mobs + if not self.tamed and not self.bred then + self.lifetimer = self.lifetimer - dtime + if self.lifetimer <= 0 then + self.lifetimer = self.lifetimer_reset + if not mobs.check_for_player_within_area(self, 64) then + --print("removing in MAIN LOGIC!") + self.object:remove() + return + end + end + end + + --color modifier which coincides with the pause_timer + if self.old_health and self.health < self.old_health then + self.object:set_texture_mod("^[colorize:red:120") + --fix double death sound + if self.health > 0 then + mobs.play_sound(self,"damage") + end + end + self.old_health = self.health + + --do death logic (animation, poof, explosion, etc) + if self.health <= 0 or self.dead then + --play death sound once + if not self.played_death_sound then + self.dead = true + mobs.play_sound(self,"death") + self.played_death_sound = true + end + + mobs.death_logic(self, dtime) + + --this is here because the mob must continue to move + --while stunned before coming to a complete halt even during + --the death tilt + if self.pause_timer > 0 then + self.pause_timer = self.pause_timer - dtime + --perfectly reset pause_timer + if self.pause_timer < 0 then + self.pause_timer = 0 + end + end + + return + end + + mobs.random_sound_handling(self,dtime) + + --mobs drowning mechanic + if not self.breathes_in_water then + + local pos = self.object:get_pos() + + pos.y = pos.y + self.eye_height + + local node = minetest_get_node(pos).name + + if minetest_get_item_group(node, "water") ~= 0 then + self.breath = self.breath - dtime + + --reset breath when drowning + if self.breath <= 0 then + self.health = self.health - 4 + self.breath = 1 + self.pause_timer = 0.5 + end + + elseif self.breath < self.breath_max then + self.breath = self.breath + dtime + --clean timer reset + if self.breath > self.breath_max then + self.breath = self.breath_max + end + end + end + + --set mobs on fire when burned by sunlight + if self.ignited_by_sunlight then + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + + if self.burn_timer > 0 then + self.burn_timer = self.burn_timer - dtime + + if self.burn_timer <= 0 then + self.health = self.health - 4 + self.burn_timer = 0 + end + end + + if self.burn_timer == 0 then + local light_current, light_day = minetest_get_node_light(pos), minetest_get_node_light(pos, 0.5) + if light_current and light_day and light_current > 12 and light_day == 15 then + mcl_burning.set_on_fire(self.object, 1) + self.burn_timer = 1 --1.7 seconds + self.pause_timer = 0.4 + end + end + end + + --baby grows up + if self.baby then + --print(self.grow_up_timer) + --catch missing timer + if not self.grow_up_timer then + self.grow_up_timer = self.grow_up_goal + end + + self.grow_up_timer = self.grow_up_timer - dtime + + --baby grows up! + if self.grow_up_timer <= 0 then + self.grow_up_timer = 0 + mobs.baby_grow_up(self) + end + end + + --do custom mob instructions + if self.do_custom then + -- when false skip going any further + if self.do_custom(self, dtime) == false then + --this needs to be here or the mob becomes immortal + if self.pause_timer > 0 then + self.pause_timer = self.pause_timer - dtime + --perfectly reset pause_timer + if self.pause_timer <= 0 then + self.pause_timer = 0 + self.object:set_texture_mod("") + end + end + --this overrides internal lua collision detection + return + end + end + + local attacking = nil + + --scan for players within eyesight + if self.hostile then + --true for line_of_sight is debug + attacking = mobs.detect_closest_player_within_radius(self,true,self.view_range,self.eye_height) + + --go get the closest player + if attacking then + + self.memory = 6 --6 seconds of memory + + --set initial punch timer + if self.attacking == nil then + if self.attack_type == "punch" then + self.punch_timer = -1 + end + end + self.attacking = attacking + + --no player in area + elseif self.memory > 0 then + --try to remember + self.memory = self.memory - dtime + --get if memory player is within viewing range + if self.attacking and self.attacking:is_player() then + local distance = vector.distance(self.object:get_pos(), self.attacking:get_pos()) + if distance > self.view_range then + self.memory = 0 + end + --out of viewing range, forget em + else + self.memory = 0 + end + + if self.memory <= 0 then + + --reset states when coming out of hostile state + if self.attacking then + self.state_timer = -1 + end + + self.attacking = nil + self.memory = 0 + end + end + end + + --count down hostile cooldown timer when no players in range + if self.neutral and self.hostile and not attacking and self.hostile_cooldown_timer then + + self.hostile_cooldown_timer = self.hostile_cooldown_timer - dtime + + if self.hostile_cooldown_timer <= 0 then + self.hostile = false + self.hostile_cooldown_timer = 0 + end + end + + --mob is stunned after being hit + if self.pause_timer > 0 then + self.pause_timer = self.pause_timer - dtime + --don't break eye contact + if self.hostile and self.attacking then + mobs.set_yaw_while_attacking(self) + end + + --perfectly reset pause_timer + if self.pause_timer <= 0 then + self.pause_timer = 0 + self.object:set_texture_mod("") + end + + --stop walking mobs from falling through the water + if not self.jump_only and not self.swim and not self.fly then + local pos = self.object:get_pos() + local collisionbox = self.object:get_properties().collisionbox + --get the center of the mob + pos.y = pos.y + (collisionbox[2] + collisionbox[5] / 2) + local current_node = minetest_get_node(pos).name + + --recheck if in water or lava + if minetest_get_item_group(current_node, "water") ~= 0 or minetest_get_item_group(current_node, "lava") ~= 0 then + mobs.float(self) + end + end + + --stop projectile mobs from being completely disabled while stunned + if self.projectile_timer and self.projectile_timer > 0.01 then + self.projectile_timer = self.projectile_timer - dtime + if self.projectile_timer < 0.01 then + self.projectile_timer = 0.01 + end + end + + return -- don't allow collision detection + --do normal ai + else + --jump only (like slimes) + if self.jump_only then + jump_state_switch(self, dtime) + jump_state_execution(self, dtime) + --swimming + elseif self.swim then + swim_state_switch(self, dtime) + swim_state_execution(self, dtime) + --flying + elseif self.fly then + fly_state_switch(self, dtime) + fly_state_execution(self,dtime) + --regular mobs that walk around + else + land_state_switch(self, dtime) + land_state_execution(self,dtime) + end + end + + --do not continue if non-existent + if not self or not self.object or not self.object:get_luaentity() then + self.object:remove() + return false + end + + --make it so mobs do not glitch out when walking around/jumping + mobs.swap_auto_step_height_adjust(self) + + + -- can mob be pushed, if so calculate direction -- do this last (overrides everything) + if self.pushable then + mobs.collision(self) + end + + --overrides absolutely everything + --mobs get stuck in cobwebs like players + if not self.ignores_cobwebs then + local pos = self.object:get_pos() + local node = pos and minetest_get_node(pos).name + if node == "mcl_core:cobweb" then + --fight the rest of the api + if self.object:get_acceleration().y ~= 0 then + self.object:set_acceleration(vector.new(0,0,0)) + end + mobs.stick_in_cobweb(self) + self.was_stuck_in_cobweb = true + else + --do not override other functions + if self.was_stuck_in_cobweb == true then + --return the mob back to normal + self.was_stuck_in_cobweb = nil + if self.object:get_acceleration().y == 0 and not self.swim and not self.fly then + self.object:set_acceleration(vector.new(0,-self.gravity,0)) + end + end + end + end + + self.old_velocity = self.object:get_velocity() + self.old_pos = self.object:get_pos() +end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua new file mode 100644 index 00000000..cea6d838 --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua @@ -0,0 +1,257 @@ +local math = math +local vector = vector + +local HALF_PI = math.pi/2 + + +local vector_direction = vector.direction +local vector_distance = vector.distance +local vector_new = vector.new + +local minetest_dir_to_yaw = minetest.dir_to_yaw + +-- set defined animation +mobs.set_mob_animation = function(self, anim, fixed_frame) + + if not self.animation or not anim then + return + end + + if self.state == "die" and anim ~= "die" and anim ~= "stand" then + return + end + + + if (not self.animation[anim .. "_start"] or not self.animation[anim .. "_end"]) then + return + end + + --animations break if they are constantly set + --so we put this return gate to check if it is + --already at the animation we are trying to implement + if self.current_animation == anim then + return + end + + local a_start = self.animation[anim .. "_start"] + local a_end + + if fixed_frame then + a_end = a_start + else + a_end = self.animation[anim .. "_end"] + end + + self.object:set_animation({ + x = a_start, + y = a_end}, + self.animation[anim .. "_speed"] or self.animation.speed_normal or 15, + 0, self.animation[anim .. "_loop"] ~= false) + + self.current_animation = anim +end + + + + +mobs.death_effect = function(pos, yaw, collisionbox, rotate) + local min, max + if collisionbox then + min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]} + max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]} + else + min = { x = -0.5, y = 0, z = -0.5 } + max = { x = 0.5, y = 0.5, z = 0.5 } + end + if rotate then + min = vector.rotate(min, {x=0, y=yaw, z=math.pi/2}) + max = vector.rotate(max, {x=0, y=yaw, z=math.pi/2}) + min, max = vector.sort(min, max) + min = vector.multiply(min, 0.5) + max = vector.multiply(max, 0.5) + end + + minetest.add_particlespawner({ + amount = 50, + time = 0.001, + minpos = vector.add(pos, min), + maxpos = vector.add(pos, max), + minvel = vector_new(-5,-5,-5), + maxvel = vector_new(5,5,5), + minexptime = 1.1, + maxexptime = 1.5, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "mcl_particles_mob_death.png^[colorize:#000000:255", + }) + + minetest.sound_play("mcl_mobs_mob_poof", { + pos = pos, + gain = 1.0, + max_hear_distance = 8, + }, true) +end + + +--this allows auto facedir rotation while making it so mobs +--don't look like wet noodles flopping around +mobs.movement_rotation_lock = function(self) + local current_engine_yaw = self.object:get_yaw() + local current_lua_yaw = self.yaw + + if current_engine_yaw > math.pi * 2 then + current_engine_yaw = current_engine_yaw - (math.pi * 2) + end + + if math.abs(current_engine_yaw - current_lua_yaw) <= 0.05 and self.object:get_properties().automatic_face_movement_dir then + self.object:set_properties{automatic_face_movement_dir = false} + elseif math.abs(current_engine_yaw - current_lua_yaw) > 0.05 and self.object:get_properties().automatic_face_movement_dir == false then + self.object:set_properties{automatic_face_movement_dir = self.rotate} + end +end + + +--this is used when a mob is chasing a player +mobs.set_yaw_while_attacking = function(self) + + if self.object:get_properties().automatic_face_movement_dir then + self.object:set_properties{automatic_face_movement_dir = false} + end + + --turn positions into pseudo 2d vectors + local pos1 = self.object:get_pos() + pos1.y = 0 + + local pos2 = self.attacking:get_pos() + pos2.y = 0 + + local new_direction = vector_direction(pos1,pos2) + local new_yaw = minetest_dir_to_yaw(new_direction) + + self.object:set_yaw(new_yaw) + self.yaw = new_yaw +end + +--this is used to unlock a mob's yaw after attacking +mobs.unlock_yaw = function(self) + if self.object:get_properties().automatic_face_movement_dir == false then + self.object:set_properties{automatic_face_movement_dir = self.rotate} + end +end + +--this is used to lock a mob's yaw when they're standing +mobs.lock_yaw = function(self) + if self.object:get_properties().automatic_face_movement_dir then + self.object:set_properties{automatic_face_movement_dir = false} + end +end + + +local calculate_pitch = function(self) + local pos = self.object:get_pos() + local pos2 = self.old_pos + + if pos == nil or pos2 == nil then + return false + end + + return minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos.x,0,pos.z),vector_new(pos2.x,0,pos2.z)),0,pos.y - pos2.y)) + HALF_PI +end + +--this is a helper function used to make mobs pitch rotation dynamically flow when flying/swimming +mobs.set_dynamic_pitch = function(self) + local pitch = calculate_pitch(self) + + if not pitch then + return + end + + local current_rotation = self.object:get_rotation() + + current_rotation.x = pitch + + self.object:set_rotation(current_rotation) + + self.pitch_switch = "dynamic" +end + +--this is a helper function used to make mobs pitch rotation reset when flying/swimming +mobs.set_static_pitch = function(self) + + if self.pitch_switch == "static" then + return + end + + local current_rotation = self.object:get_rotation() + + current_rotation.x = 0 + + self.object:set_rotation(current_rotation) + self.pitch_switch = "static" +end + +--this is a helper function for mobs explosion animation +mobs.handle_explosion_animation = function(self) + + --secondary catch-all + if not self.explosion_animation then + self.explosion_animation = 0 + end + + --the timer works from 0 for sense of a 0 based counting + --but this just bumps it up so it's usable in here + local explosion_timer_adjust = self.explosion_animation + 1 + + + local visual_size_modified = table.copy(self.visual_size_origin) + + visual_size_modified.x = visual_size_modified.x * (explosion_timer_adjust ^ 3) + visual_size_modified.y = visual_size_modified.y * explosion_timer_adjust + + self.object:set_properties({visual_size = visual_size_modified}) +end + + +--this is used when a mob is following player +mobs.set_yaw_while_following = function(self) + + if self.object:get_properties().automatic_face_movement_dir then + self.object:set_properties{automatic_face_movement_dir = false} + end + + --turn positions into pseudo 2d vectors + local pos1 = self.object:get_pos() + pos1.y = 0 + + local pos2 = self.following_person:get_pos() + pos2.y = 0 + + local new_direction = vector_direction(pos1,pos2) + local new_yaw = minetest_dir_to_yaw(new_direction) + + self.object:set_yaw(new_yaw) + self.yaw = new_yaw +end + +--this is used for when mobs breed +mobs.set_yaw_while_breeding = function(self, mate) + + if self.object:get_properties().automatic_face_movement_dir then + self.object:set_properties{automatic_face_movement_dir = false} + end + + --turn positions into pseudo 2d vectors + local pos1 = self.object:get_pos() + pos1.y = 0 + + local pos2 = mate:get_pos() + pos2.y = 0 + + local new_direction = vector_direction(pos1,pos2) + local new_yaw = minetest_dir_to_yaw(new_direction) + + self.object:set_yaw(new_yaw) + self.yaw = new_yaw +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua new file mode 100644 index 00000000..ac10194e --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua @@ -0,0 +1,347 @@ +local vector_direction = vector.direction +--local minetest_dir_to_yaw = minetest.dir_to_yaw +local vector_distance = vector.distance +local vector_multiply = vector.multiply +local math_random = math.random + +--[[ + _ _ _ _ +| | | | | | | | +| | | | __ _ _ __ __| | | | +| | | | / _` | '_ \ / _` | | | +|_| | |___| (_| | | | | (_| | |_| +(_) \_____/\__,_|_| |_|\__,_| (_) +]]-- + + + +--[[ + _____ _ _ +| ___| | | | | +| |____ ___ __ | | ___ __| | ___ +| __\ \/ / '_ \| |/ _ \ / _` |/ _ \ +| |___> <| |_) | | (_) | (_| | __/ +\____/_/\_\ .__/|_|\___/ \__,_|\___| + | | + |_| +]]-- + +mobs.explode_attack_walk = function(self,dtime) + + --this needs an exception + if self.attacking == nil or not self.attacking:is_player() then + self.attacking = nil + return + end + + mobs.set_yaw_while_attacking(self) + + local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos()) + + --make mob walk up to player within 2 nodes distance then start exploding + if distance_from_attacking >= self.reach and + --don't allow explosion to cancel unless out of the reach boundary + not (self.explosion_animation and self.explosion_animation > 0 and distance_from_attacking <= self.defuse_reach) then + + mobs.set_velocity(self, self.run_velocity) + mobs.set_mob_animation(self,"run") + + mobs.reverse_explosion_animation(self,dtime) + else + mobs.set_velocity(self,0) + + --this is the only way I can reference this without dumping extra data on all mobs + if not self.explosion_animation then + self.explosion_animation = 0 + end + + --play ignite sound + if self.explosion_animation == 0 then + mobs.play_sound(self,"attack") + end + + mobs.set_mob_animation(self,"stand") + + mobs.handle_explosion_animation(self) + + self.explosion_animation = self.explosion_animation + (dtime/2.5) + end + + --make explosive mobs jump + --check for nodes to jump over + --explosive mobs will just ride against walls for now + local node_in_front_of = mobs.jump_check(self) + if node_in_front_of == 1 then + mobs.jump(self) + end + + --do biggening explosion thing + if self.explosion_animation and self.explosion_animation > self.explosion_timer then + mcl_explosions.explode(self.object:get_pos(), self.explosion_strength,{ drop_chance = 1.0 }) + self.object:remove() + end +end + + +--this is a small helper function to make working with explosion animations easier +mobs.reverse_explosion_animation = function(self,dtime) + --if explosion animation was greater than 0 then reverse it + if self.explosion_animation and self.explosion_animation > 0 then + self.explosion_animation = self.explosion_animation - dtime + if self.explosion_animation < 0 then + self.explosion_animation = 0 + end + end + + mobs.handle_explosion_animation(self) +end + + + + +--[[ +______ _ +| ___ \ | | +| |_/ / _ _ __ ___| |__ +| __/ | | | '_ \ / __| '_ \ +| | | |_| | | | | (__| | | | +\_| \__,_|_| |_|\___|_| |_| +]]-- + + + +mobs.punch_attack_walk = function(self,dtime) + --this needs an exception + if self.attacking == nil or not self.attacking:is_player() then + self.attacking = nil + return + end + + local distance_from_attacking = mobs.get_2d_distance(self.object:get_pos(), self.attacking:get_pos()) + + if distance_from_attacking >= self.minimum_follow_distance then + mobs.set_velocity(self, self.run_velocity) + mobs.set_mob_animation(self, "run") + else + mobs.set_velocity(self, 0) + mobs.set_mob_animation(self, "stand") + end + + mobs.set_yaw_while_attacking(self) + + --make punchy mobs jump + --check for nodes to jump over + --explosive mobs will just ride against walls for now + local node_in_front_of = mobs.jump_check(self) + + if node_in_front_of == 1 then + mobs.jump(self) + end + + --mobs that can climb over stuff + if self.always_climb and node_in_front_of > 0 then + mobs.climb(self) + end + + + --auto reset punch_timer + if not self.punch_timer then + self.punch_timer = 0 + end + + if self.punch_timer > 0 then + self.punch_timer = self.punch_timer - dtime + end +end + +mobs.punch_attack = function(self) + + self.attacking:punch(self.object, 1.0, { + full_punch_interval = 1.0, + damage_groups = {fleshy = self.damage} + }, nil) + + self.punch_timer = self.punch_timer_cooloff + + + --knockback + local pos1 = self.object:get_pos() + pos1.y = 0 + local pos2 = self.attacking:get_pos() + pos2.y = 0 + local dir = vector_direction(pos1,pos2) + + dir = vector_multiply(dir,3) + + if self.attacking:get_velocity().y <= 1 then + dir.y = 5 + end + + self.attacking:add_velocity(dir) +end + + + + +--[[ +______ _ _ _ _ +| ___ \ (_) | | (_) | +| |_/ / __ ___ _ ___ ___| |_ _| | ___ +| __/ '__/ _ \| |/ _ \/ __| __| | |/ _ \ +| | | | | (_) | | __/ (__| |_| | | __/ +\_| |_| \___/| |\___|\___|\__|_|_|\___| + _/ | + |__/ +]]-- + + +mobs.projectile_attack_walk = function(self,dtime) + + --this needs an exception + if self.attacking == nil or not self.attacking:is_player() then + self.attacking = nil + return + end + + mobs.set_yaw_while_attacking(self) + + local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos()) + + + if distance_from_attacking >= self.reach then + mobs.set_velocity(self, self.run_velocity) + mobs.set_mob_animation(self,"run") + else + mobs.set_velocity(self,0) + mobs.set_mob_animation(self,"stand") + end + + --do this to not load data into other mobs + if not self.projectile_timer then + self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max) + end + + --run projectile timer + if self.projectile_timer > 0 then + self.projectile_timer = self.projectile_timer - dtime + + --shoot + if self.projectile_timer <= 0 then + --reset timer + self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max) + mobs.shoot_projectile(self) + end + end + + --make shooty mobs jump + --check for nodes to jump over + --explosive mobs will just ride against walls for now + local node_in_front_of = mobs.jump_check(self) + if node_in_front_of == 1 then + mobs.jump(self) + end + +end + + + + + + + + + +--[[ + _ ______ _ _ +| | | ___| | | | +| | | |_ | |_ _ | | +| | | _| | | | | | | | +|_| | | | | |_| | |_| +(_) \_| |_|\__, | (_) + __/ | + |___/ +]]-- + + + + +--[[ +______ _ _ _ _ +| ___ \ (_) | | (_) | +| |_/ / __ ___ _ ___ ___| |_ _| | ___ +| __/ '__/ _ \| |/ _ \/ __| __| | |/ _ \ +| | | | | (_) | | __/ (__| |_| | | __/ +\_| |_| \___/| |\___|\___|\__|_|_|\___| + _/ | + |__/ +]]-- + +local random_pitch_multiplier = {-1,1} + +mobs.projectile_attack_fly = function(self, dtime) + --this needs an exception + if self.attacking == nil or not self.attacking:is_player() then + self.attacking = nil + return + end + + --this is specifically for random ghast movement + if self.fly_random_while_attack then + + --enable rotation locking + mobs.movement_rotation_lock(self) + + self.walk_timer = self.walk_timer - dtime + + --reset the walk timer + if self.walk_timer <= 0 then + --re-randomize the walk timer + self.walk_timer = math.random(1,6) + math.random() + --set the mob into a random direction + self.yaw = (math_random() * (math.pi * 2)) + --create a truly random pitch, since there is no easy access to pitch math that I can find + self.pitch = math_random() * math.random(1,3) * random_pitch_multiplier[math_random(1,2)] + end + + mobs.set_fly_velocity(self, self.run_velocity) + + else + + mobs.set_yaw_while_attacking(self) + + local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos()) + + if distance_from_attacking >= self.reach then + mobs.set_pitch_while_attacking(self) + mobs.set_fly_velocity(self, self.run_velocity) + mobs.set_mob_animation(self,"run") + else + mobs.set_pitch_while_attacking(self) + mobs.set_fly_velocity(self, 0) + mobs.set_mob_animation(self,"stand") + end + end + + + --do this to not load data into other mobs + if not self.projectile_timer then + self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max) + end + + --run projectile timer + if self.projectile_timer > 0 then + self.projectile_timer = self.projectile_timer - dtime + + --shoot + if self.projectile_timer <= 0 then + + if self.fly_random_while_attack then + mobs.set_yaw_while_attacking(self) + self.walk_timer = 0 + end + --reset timer + self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max) + mobs.shoot_projectile(self) + end + end +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.txt similarity index 55% rename from mods/ENTITIES/mcl_mobs/api.lua rename to mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.txt index 6c1a0567..48233d0b 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.txt @@ -1,119 +1,7 @@ +local math = math +local vector = vector --- API for Mobs Redo: MineClone 2 Edition (MRM) - -mobs = {} -mobs.mod = "mrm" -mobs.version = "20210106" -- don't rely too much on this, rarely updated, if ever - -local MAX_MOB_NAME_LENGTH = 30 -local HORNY_TIME = 30 -local HORNY_AGAIN_TIME = 300 -local CHILD_GROW_TIME = 60*20 -local DEATH_DELAY = 0.5 -local DEFAULT_FALL_SPEED = -10 -local FLOP_HEIGHT = 5.0 -local FLOP_HOR_SPEED = 1.5 - -local MOB_CAP = {} -MOB_CAP.hostile = 70 -MOB_CAP.passive = 10 -MOB_CAP.ambient = 15 -MOB_CAP.water = 15 - --- Localize -local S = minetest.get_translator("mcl_mobs") - --- CMI support check -local use_cmi = minetest.global_exists("cmi") - - --- Invisibility mod check -mobs.invis = {} -if minetest.global_exists("invisibility") then - mobs.invis = invisibility -end - - --- creative check -function mobs.is_creative(name) - return minetest.is_creative_enabled(name) -end - - --- localize math functions -local pi = math.pi -local sin = math.sin -local cos = math.cos -local abs = math.abs -local min = math.min -local max = math.max -local atann = math.atan -local random = math.random -local floor = math.floor -local atan = function(x) - if not x or x ~= x then - return 0 - else - return atann(x) - end -end - - --- Load settings -local damage_enabled = minetest.settings:get_bool("enable_damage") -local disable_blood = minetest.settings:get_bool("mobs_disable_blood") -local mobs_drop_items = minetest.settings:get_bool("mobs_drop_items") ~= false -local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false -local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false -local remove_far = true -local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0 -local show_health = false -local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 64) -local mobs_spawn_chance = tonumber(minetest.settings:get("mobs_spawn_chance") or 2.5) - --- Shows helpful debug info above each mob -local mobs_debug = minetest.settings:get_bool("mobs_debug", false) - --- Peaceful mode message so players will know there are no monsters -if minetest.settings:get_bool("only_peaceful_mobs", false) then - minetest.register_on_joinplayer(function(player) - minetest.chat_send_player(player:get_player_name(), - S("Peaceful mode active! No monsters will spawn.")) - end) -end - --- pathfinding settings -local enable_pathfinding = true -local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching -local stuck_path_timeout = 10 -- how long will mob follow path before giving up - --- default nodes -local node_ice = "mcl_core:ice" -local node_snowblock = "mcl_core:snowblock" -local node_snow = "mcl_core:snow" -mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt" - -local mod_weather = minetest.get_modpath("mcl_weather") ~= nil -local mod_explosions = minetest.get_modpath("mcl_explosions") ~= nil -local mod_mobspawners = minetest.get_modpath("mcl_mobspawners") ~= nil -local mod_hunger = minetest.get_modpath("mcl_hunger") ~= nil -local mod_worlds = minetest.get_modpath("mcl_worlds") ~= nil -local mod_armor = minetest.get_modpath("mcl_armor") ~= nil -local mod_experience = minetest.get_modpath("mcl_experience") ~= nil - -----For Water Flowing: -local enable_physics = function(object, luaentity, ignore_check) - if luaentity.physical_state == false or ignore_check == true then - luaentity.physical_state = true - object:set_properties({ - physical = true - }) - object:set_velocity({x=0,y=0,z=0}) - object:set_acceleration({x=0,y=-9.81,z=0}) - end -end - -local disable_physics = function(object, luaentity, ignore_check, reset_movement) +local function disable_physics(object, luaentity, ignore_check, reset_movement) if luaentity.physical_state == true or ignore_check == true then luaentity.physical_state = false object:set_properties({ @@ -126,1919 +14,277 @@ local disable_physics = function(object, luaentity, ignore_check, reset_movement end end - --- play sound -local mob_sound = function(self, soundname, is_opinion, fixed_pitch) - - local soundinfo - if self.sounds_child and self.child then - soundinfo = self.sounds_child - elseif self.sounds then - soundinfo = self.sounds - end - if not soundinfo then - return - end - local sound = soundinfo[soundname] - if sound then - if is_opinion and self.opinion_sound_cooloff > 0 then - return - end - local pitch - if not fixed_pitch then - local base_pitch = soundinfo.base_pitch - if not base_pitch then - base_pitch = 1 - end - if self.child and (not self.sounds_child) then - -- Children have higher pitch - pitch = base_pitch * 1.5 - else - pitch = base_pitch - end - -- randomize the pitch a bit - pitch = pitch + math.random(-10, 10) * 0.005 - end - minetest.sound_play(sound, { - object = self.object, - gain = 1.0, - max_hear_distance = self.sounds.distance, - pitch = pitch, - }, true) - self.opinion_sound_cooloff = 1 +----For Water Flowing: +local function enable_physics(object, luaentity, ignore_check) + if luaentity.physical_state == false or ignore_check == true then + luaentity.physical_state = true + object:set_properties({ + physical = true + }) + object:set_velocity({x=0,y=0,z=0}) + object:set_acceleration({x=0,y=-9.81,z=0}) end end --- Return true if object is in view_range -local function object_in_range(self, object) - if not object then - return false - end - local factor - -- Apply view range reduction for special player armor - if object:is_player() and mod_armor then - factor = armor:get_mob_view_range_factor(object, self.name) - end - -- Distance check - local dist - if factor and factor == 0 then - return false - elseif factor then - dist = self.view_range * factor - else - dist = self.view_range - end - - local p1, p2 = self.object:get_pos(), object:get_pos() - return p1 and p2 and (vector.distance(p1, p2) <= dist) -end - --- attack player/mob -local do_attack = function(self, player) - - if self.state == "attack" or self.state == "die" then - return - end - - self.attack = player - self.state = "attack" - - -- TODO: Implement war_cry sound without being annoying - --if random(0, 100) < 90 then - --mob_sound(self, "war_cry", true) - --end -end - - --- collision function borrowed amended from jordan4ibanez open_ai mod -local collision = function(self) - - local pos = self.object:get_pos() - local vel = self.object:get_velocity() - local x = 0 - local z = 0 - local width = -self.collisionbox[1] + self.collisionbox[4] + 0.5 - - for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do - - if object:is_player() - or (object:get_luaentity()._cmi_is_mob == true and object ~= self.object) then - - local pos2 = object:get_pos() - local vec = {x = pos.x - pos2.x, z = pos.z - pos2.z} - local force = (width + 0.5) - vector.distance( - {x = pos.x, y = 0, z = pos.z}, - {x = pos2.x, y = 0, z = pos2.z}) - - x = x + (vec.x * force) - z = z + (vec.z * force) - end - end - - return({x,z}) -end - --- move mob in facing direction -local set_velocity = function(self, v) - - local c_x, c_y = 0, 0 - - -- can mob be pushed, if so calculate direction - if self.pushable then - c_x, c_y = unpack(collision(self)) - end - - -- halt mob if it has been ordered to stay - if self.order == "stand" then - self.object:set_velocity({x = 0, y = 0, z = 0}) - return - end - - local yaw = (self.object:get_yaw() or 0) + self.rotate - - self.object:set_velocity({ - x = (sin(yaw) * -v) + c_x, - y = self.object:get_velocity().y, - z = (cos(yaw) * v) + c_y, - }) -end - - - --- calculate mob velocity -local get_velocity = function(self) - - local v = self.object:get_velocity() - if v then - return (v.x * v.x + v.z * v.z) ^ 0.5 - end - - return 0 -end - -local function update_roll(self) - local is_Fleckenstein = self.nametag == "Fleckenstein" - local was_Fleckenstein = false - - local rot = self.object:get_rotation() - rot.z = is_Fleckenstein and pi or 0 - self.object:set_rotation(rot) - - local cbox = table.copy(self.collisionbox) - local acbox = self.object:get_properties().collisionbox - - if math.abs(cbox[2] - acbox[2]) > 0.1 then - was_Fleckenstein = true - end - - if is_Fleckenstein ~= was_Fleckenstein then - local pos = self.object:get_pos() - pos.y = pos.y + (acbox[2] + acbox[5]) - self.object:set_pos(pos) - end - - if is_Fleckenstein then - cbox[2], cbox[5] = -cbox[5], -cbox[2] - end - - self.object:set_properties({collisionbox = cbox}) -end - --- set and return valid yaw -local set_yaw = function(self, yaw, delay, dtime) - - if not yaw or yaw ~= yaw then - yaw = 0 - end - - delay = delay or 0 - - if delay == 0 then - if self.shaking and dtime then - yaw = yaw + (math.random() * 2 - 1) * 5 * dtime - end - self.object:set_yaw(yaw) - update_roll(self) - return yaw - end - - self.target_yaw = yaw - self.delay = delay - - return self.target_yaw -end - --- global function to set mob yaw -function mobs:yaw(self, yaw, delay, dtime) - set_yaw(self, yaw, delay, dtime) -end - -local add_texture_mod = function(self, mod) - local full_mod = "" - local already_added = false - for i=1, #self.texture_mods do - if mod == self.texture_mods[i] then - already_added = true - end - full_mod = full_mod .. self.texture_mods[i] - end - if not already_added then - full_mod = full_mod .. mod - table.insert(self.texture_mods, mod) - end - self.object:set_texture_mod(full_mod) -end -local remove_texture_mod = function(self, mod) - local full_mod = "" - local remove = {} - for i=1, #self.texture_mods do - if self.texture_mods[i] ~= mod then - full_mod = full_mod .. self.texture_mods[i] - else - table.insert(remove, i) - end - end - for i=#remove, 1 do - table.remove(self.texture_mods, remove[i]) - end - self.object:set_texture_mod(full_mod) -end - --- set defined animation -local set_animation = function(self, anim, fixed_frame) - if not self.animation or not anim then - return - end - if self.state == "die" and anim ~= "die" and anim ~= "stand" then - return - end - - self.animation.current = self.animation.current or "" - - if (anim == self.animation.current - or not self.animation[anim .. "_start"] - or not self.animation[anim .. "_end"]) and self.state ~= "die" then - return - end - - self.animation.current = anim - - local a_start = self.animation[anim .. "_start"] - local a_end - if fixed_frame then - a_end = a_start - else - a_end = self.animation[anim .. "_end"] - end - - self.object:set_animation({ - x = a_start, - y = a_end}, - self.animation[anim .. "_speed"] or self.animation.speed_normal or 15, - 0, self.animation[anim .. "_loop"] ~= false) -end - - --- above function exported for mount.lua -function mobs:set_animation(self, anim) - set_animation(self, anim) -end - --- Returns true is node can deal damage to self -local is_node_dangerous = function(self, nodename) - local nn = nodename - if self.lava_damage > 0 then - if minetest.get_item_group(nn, "lava") ~= 0 then - return true - end - end - if self.fire_damage > 0 then - if minetest.get_item_group(nn, "fire") ~= 0 then - return true - end - end - if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].damage_per_second and minetest.registered_nodes[nn].damage_per_second > 0 then - return true - end - return false -end - - --- Returns true if node is a water hazard -local is_node_waterhazard = function(self, nodename) - local nn = nodename - if self.water_damage > 0 then - if minetest.get_item_group(nn, "water") ~= 0 then - return true - end - end - if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].drowning and minetest.registered_nodes[nn].drowning > 0 then - if self.breath_max ~= -1 then - -- check if the mob is water-breathing _and_ the block is water; only return true if neither is the case - -- this will prevent water-breathing mobs to classify water or e.g. sand below them as dangerous - if not self.breathes_in_water and minetest.get_item_group(nn, "water") ~= 0 then - return true +--[[ +local timer = 0 +minetest.register_globalstep(function(dtime) + timer = timer + dtime + if timer < 1 then return end + for _, player in pairs(minetest.get_connected_players()) do + local pos = player:get_pos() + for _, obj in pairs(minetest_get_objects_inside_radius(pos, 47)) do + local lua = obj:get_luaentity() + if lua and lua._cmi_is_mob then + lua.lifetimer = math.max(20, lua.lifetimer) + lua.despawn_immediately = false end end end - return false -end + timer = 0 +end) +]]-- +-- compatibility function for old entities to new modpack entities +function mobs:alias_mob(old_name, new_name) --- check line of sight (BrunoMine) -local line_of_sight = function(self, pos1, pos2, stepsize) + -- spawn egg + minetest.register_alias(old_name, new_name) - stepsize = stepsize or 1 + -- entity + minetest.register_entity(":" .. old_name, { - local s, pos = minetest.line_of_sight(pos1, pos2, stepsize) + physical = false, - -- normal walking and flying mobs can see you through air - if s == true then - return true - end + on_step = function(self) - -- New pos1 to be analyzed - local npos1 = {x = pos1.x, y = pos1.y, z = pos1.z} - - local r, pos = minetest.line_of_sight(npos1, pos2, stepsize) - - -- Checks the return - if r == true then return true end - - -- Nodename found - local nn = minetest.get_node(pos).name - - -- Target Distance (td) to travel - local td = vector.distance(pos1, pos2) - - -- Actual Distance (ad) traveled - local ad = 0 - - -- It continues to advance in the line of sight in search of a real - -- obstruction which counts as 'normal' nodebox. - while minetest.registered_nodes[nn] - and minetest.registered_nodes[nn].walkable == false do - - -- Check if you can still move forward - if td < ad + stepsize then - return true -- Reached the target - end - - -- Moves the analyzed pos - local d = vector.distance(pos1, pos2) - - npos1.x = ((pos2.x - pos1.x) / d * stepsize) + pos1.x - npos1.y = ((pos2.y - pos1.y) / d * stepsize) + pos1.y - npos1.z = ((pos2.z - pos1.z) / d * stepsize) + pos1.z - - -- NaN checks - if d == 0 - or npos1.x ~= npos1.x - or npos1.y ~= npos1.y - or npos1.z ~= npos1.z then - return false - end - - ad = ad + stepsize - - -- scan again - r, pos = minetest.line_of_sight(npos1, pos2, stepsize) - - if r == true then return true end - - -- New Nodename found - nn = minetest.get_node(pos).name - - end - - return false -end - - --- are we flying in what we are suppose to? (taikedz) -local flight_check = function(self) - - local nod = self.standing_in - local def = minetest.registered_nodes[nod] - - if not def then return false end -- nil check - - local fly_in - if type(self.fly_in) == "string" then - fly_in = { self.fly_in } - elseif type(self.fly_in) == "table" then - fly_in = self.fly_in - else - return false - end - - for _,checknode in pairs(fly_in) do - if nod == checknode then - return true - elseif checknode == "__airlike" and def.walkable == false and - (def.liquidtype == "none" or minetest.get_item_group(nod, "fake_liquid") == 1) then - return true - end - end - - return false -end - - --- custom particle effects -local effect = function(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down) - - radius = radius or 2 - min_size = min_size or 0.5 - max_size = max_size or 1 - gravity = gravity or -10 - glow = glow or 0 - go_down = go_down or false - - local ym - if go_down then - ym = 0 - else - ym = -radius - end - - minetest.add_particlespawner({ - amount = amount, - time = 0.25, - minpos = pos, - maxpos = pos, - minvel = {x = -radius, y = ym, z = -radius}, - maxvel = {x = radius, y = radius, z = radius}, - minacc = {x = 0, y = gravity, z = 0}, - maxacc = {x = 0, y = gravity, z = 0}, - minexptime = 0.1, - maxexptime = 1, - minsize = min_size, - maxsize = max_size, - texture = texture, - glow = glow, - }) -end - -local damage_effect = function(self, damage) - -- damage particles - if (not disable_blood) and damage > 0 then - - local amount_large = math.floor(damage / 2) - local amount_small = damage % 2 - - local pos = self.object:get_pos() - - pos.y = pos.y + (self.collisionbox[5] - self.collisionbox[2]) * .5 - - local texture = "mobs_blood.png" - -- full heart damage (one particle for each 2 HP damage) - if amount_large > 0 then - effect(pos, amount_large, texture, 2, 2, 1.75, 0, nil, true) - end - -- half heart damage (one additional particle if damage is an odd number) - if amount_small > 0 then - -- TODO: Use "half heart" - effect(pos, amount_small, texture, 1, 1, 1.75, 0, nil, true) - end - end -end - -mobs.death_effect = function(pos, yaw, collisionbox, rotate) - local min, max - if collisionbox then - min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]} - max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]} - else - min = { x = -0.5, y = 0, z = -0.5 } - max = { x = 0.5, y = 0.5, z = 0.5 } - end - if rotate then - min = vector.rotate(min, {x=0, y=yaw, z=pi/2}) - max = vector.rotate(max, {x=0, y=yaw, z=pi/2}) - min, max = vector.sort(min, max) - min = vector.multiply(min, 0.5) - max = vector.multiply(max, 0.5) - end - - minetest.add_particlespawner({ - amount = 50, - time = 0.001, - minpos = vector.add(pos, min), - maxpos = vector.add(pos, max), - minvel = vector.new(-5,-5,-5), - maxvel = vector.new(5,5,5), - minexptime = 1.1, - maxexptime = 1.5, - minsize = 1, - maxsize = 2, - collisiondetection = false, - vertical = false, - texture = "mcl_particles_mob_death.png^[colorize:#000000:255", - }) - - minetest.sound_play("mcl_mobs_mob_poof", { - pos = pos, - gain = 1.0, - max_hear_distance = 8, - }, true) -end - -local update_tag = function(self) - local tag - if mobs_debug then - tag = "nametag = '"..tostring(self.nametag).."'\n".. - "state = '"..tostring(self.state).."'\n".. - "order = '"..tostring(self.order).."'\n".. - "attack = "..tostring(self.attack).."\n".. - "health = "..tostring(self.health).."\n".. - "breath = "..tostring(self.breath).."\n".. - "gotten = "..tostring(self.gotten).."\n".. - "tamed = "..tostring(self.tamed).."\n".. - "horny = "..tostring(self.horny).."\n".. - "hornytimer = "..tostring(self.hornytimer).."\n".. - "runaway_timer = "..tostring(self.runaway_timer).."\n".. - "following = "..tostring(self.following) - else - tag = self.nametag - end - self.object:set_properties({ - nametag = tag, - }) - - update_roll(self) -end - --- drop items -local item_drop = function(self, cooked, looting_level) - - -- no drops if disabled by setting - if not mobs_drop_items then return end - - looting_level = looting_level or 0 - - -- no drops for child mobs (except monster) - if (self.child and self.type ~= "monster") then - return - end - - local obj, item, num - local pos = self.object:get_pos() - - self.drops = self.drops or {} -- nil check - - for n = 1, #self.drops do - local dropdef = self.drops[n] - local chance = 1 / dropdef.chance - local looting_type = dropdef.looting - - if looting_level > 0 then - local chance_function = dropdef.looting_chance_function - if chance_function then - chance = chance_function(looting_level) - elseif looting_type == "rare" then - chance = chance + (dropdef.looting_factor or 0.01) * looting_level - end - end - - local num = 0 - local do_common_looting = (looting_level > 0 and looting_type == "common") - if random() < chance then - num = random(dropdef.min or 1, dropdef.max or 1) - elseif not dropdef.looting_ignore_chance then - do_common_looting = false - end - - if do_common_looting then - num = num + math.floor(math.random(0, looting_level) + 0.5) - end - - if num > 0 then - item = dropdef.name - - -- cook items when true - if cooked then - - local output = minetest.get_craft_result({ - method = "cooking", width = 1, items = {item}}) - - if output and output.item and not output.item:is_empty() then - item = output.item:get_name() - end + if minetest_registered_entities[new_name] then + minetest_add_entity(self.object:get_pos(), new_name) end - -- add item if it exists - for x = 1, num do - obj = minetest.add_item(pos, ItemStack(item .. " " .. 1)) - end - - if obj and obj:get_luaentity() then - - obj:set_velocity({ - x = random(-10, 10) / 9, - y = 6, - z = random(-10, 10) / 9, - }) - elseif obj then - obj:remove() -- item does not exist - end - end - end - - self.drops = {} -end - - --- check if mob is dead or only hurt -local check_for_death = function(self, cause, cmi_cause) - - if self.state == "die" then - return true - end - - -- has health actually changed? - if self.health == self.old_health and self.health > 0 then - return false - end - - local damaged = self.health < self.old_health - self.old_health = self.health - - -- still got some health? - if self.health > 0 then - - -- make sure health isn't higher than max - if self.health > self.hp_max then - self.health = self.hp_max - end - - -- play damage sound if health was reduced and make mob flash red. - if damaged then - add_texture_mod(self, "^[colorize:red:130") - minetest.after(.2, function(self) - if self and self.object then - remove_texture_mod(self, "^[colorize:red:130") - end - end, self) - mob_sound(self, "damage") - end - - -- backup nametag so we can show health stats - if not self.nametag2 then - self.nametag2 = self.nametag or "" - end - - if show_health - and (cmi_cause and cmi_cause.type == "punch") then - - self.htimer = 2 - self.nametag = "♥ " .. self.health .. " / " .. self.hp_max - - update_tag(self) - end - - return false - end - - mob_sound(self, "death") - - local function death_handle(self) - -- dropped cooked item if mob died in fire or lava - if cause == "lava" or cause == "fire" then - item_drop(self, true, 0) - else - local wielditem = ItemStack() - if cause == "hit" then - local puncher = cmi_cause.puncher - if puncher then - wielditem = puncher:get_wielded_item() - end - end - local cooked = mcl_burning.is_burning(self.object) or mcl_enchanting.has_enchantment(wielditem, "fire_aspect") - local looting = mcl_enchanting.get_enchantment(wielditem, "looting") - item_drop(self, cooked, looting) - - if mod_experience and ((not self.child) or self.type ~= "animal") and (minetest.get_us_time() - self.xp_timestamp <= 5000000) then - mcl_experience.throw_experience(self.object:get_pos(), math.random(self.xp_min, self.xp_max)) - end - end - end - - -- execute custom death function - if self.on_die then - - local pos = self.object:get_pos() - local on_die_exit = self.on_die(self, pos, cmi_cause) - if on_die_exit ~= true then - death_handle(self) - end - - if use_cmi then - cmi.notify_die(self.object, cmi_cause) - end - - if on_die_exit == true then - self.state = "die" - mcl_burning.extinguish(self.object) self.object:remove() - return true end + }) +end + +-- Spawn a child +function mobs:spawn_child(pos, mob_type) + local child = minetest_add_entity(pos, mob_type) + if not child then + return end - local collisionbox - if self.collisionbox then - collisionbox = table.copy(self.collisionbox) + local ent = child:get_luaentity() + effect(pos, 15, "mcl_particles_smoke.png", 1, 2, 2, 15, 5) + + ent.child = true + + local textures + -- using specific child texture (if found) + if ent.child_texture then + textures = ent.child_texture[1] end - self.state = "die" - self.attack = nil - self.v_start = false - self.fall_speed = DEFAULT_FALL_SPEED - self.timer = 0 - self.blinktimer = 0 - remove_texture_mod(self, "^[colorize:#FF000040") - remove_texture_mod(self, "^[brighten") - self.passive = true - - self.object:set_properties({ - pointable = false, - collide_with_objects = false, + -- and resize to half height + child:set_properties({ + textures = textures, + visual_size = { + x = ent.base_size.x * .5, + y = ent.base_size.y * .5, + }, + collisionbox = { + ent.base_colbox[1] * .5, + ent.base_colbox[2] * .5, + ent.base_colbox[3] * .5, + ent.base_colbox[4] * .5, + ent.base_colbox[5] * .5, + ent.base_colbox[6] * .5, + }, + selectionbox = { + ent.base_selbox[1] * .5, + ent.base_selbox[2] * .5, + ent.base_selbox[3] * .5, + ent.base_selbox[4] * .5, + ent.base_selbox[5] * .5, + ent.base_selbox[6] * .5, + }, }) - set_velocity(self, 0) - local acc = self.object:get_acceleration() - acc.x, acc.y, acc.z = 0, DEFAULT_FALL_SPEED, 0 - self.object:set_acceleration(acc) - - local length - -- default death function and die animation (if defined) - if self.instant_death then - length = 0 - elseif self.animation - and self.animation.die_start - and self.animation.die_end then - - local frames = self.animation.die_end - self.animation.die_start - local speed = self.animation.die_speed or 15 - length = max(frames / speed, 0) + DEATH_DELAY - set_animation(self, "die") - else - local rot = self.object:get_rotation() - rot.z = pi/2 - self.object:set_rotation(rot) - length = 1 + DEATH_DELAY - set_animation(self, "stand", true) - end - - - -- Remove body after a few seconds and drop stuff - local kill = function(self) - if not self.object:get_luaentity() then - return - end - if use_cmi then - cmi.notify_die(self.object, cmi_cause) - end - - death_handle(self) - local dpos = self.object:get_pos() - local cbox = self.collisionbox - local yaw = self.object:get_rotation().y - mcl_burning.extinguish(self.object) - self.object:remove() - mobs.death_effect(dpos, yaw, cbox, not self.instant_death) - end - if length <= 0 then - kill(self) - else - minetest.after(length, kill, self) - end - - return true + return child end --- check if within physical map limits (-30911 to 30927) -local within_limits, wmin, wmax = nil, -30913, 30928 -within_limits = function(pos, radius) - if mcl_vars then - if mcl_vars.mapgen_edge_min and mcl_vars.mapgen_edge_max then - wmin, wmax = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max - within_limits = function(pos, radius) - return pos - and (pos.x - radius) > wmin and (pos.x + radius) < wmax - and (pos.y - radius) > wmin and (pos.y + radius) < wmax - and (pos.z - radius) > wmin and (pos.z + radius) < wmax - end - end - end - return pos - and (pos.x - radius) > wmin and (pos.x + radius) < wmax - and (pos.y - radius) > wmin and (pos.y + radius) < wmax - and (pos.z - radius) > wmin and (pos.z + radius) < wmax -end - --- is mob facing a cliff or danger -local is_at_cliff_or_danger = function(self) - - if self.fear_height == 0 then -- 0 for no falling protection! +-- feeding, taming and breeding (thanks blert2112) +function mobs:feed_tame(self, clicker, feed_count, breed, tame) + if not self.follow then return false end - if not self.object:get_luaentity() then - return false - end - local yaw = self.object:get_yaw() - local dir_x = -sin(yaw) * (self.collisionbox[4] + 0.5) - local dir_z = cos(yaw) * (self.collisionbox[4] + 0.5) - local pos = self.object:get_pos() - local ypos = pos.y + self.collisionbox[2] -- just above floor + -- can eat/tame with item in hand + if follow_holding(self, clicker) then - local free_fall, blocker = minetest.line_of_sight( - {x = pos.x + dir_x, y = ypos, z = pos.z + dir_z}, - {x = pos.x + dir_x, y = ypos - self.fear_height, z = pos.z + dir_z}) - if free_fall then - return true - else - local bnode = minetest.get_node(blocker) - local danger = is_node_dangerous(self, bnode.name) - if danger then - return true - else - local def = minetest.registered_nodes[bnode.name] - if def and def.walkable then - return false + -- if not in creative then take item + if not mobs.is_creative(clicker:get_player_name()) then + + local item = clicker:get_wielded_item() + + item:take_item() + + clicker:set_wielded_item(item) + end + + mob_sound(self, "eat", nil, true) + + -- increase health + self.health = self.health + 4 + + if self.health >= self.hp_max then + + self.health = self.hp_max + + if self.htimer < 1 then + self.htimer = 5 end end - end - return false -end - - --- copy the 'mob facing cliff_or_danger check' from above, and rework to avoid water -local is_at_water_danger = function(self) - - - if not self.object:get_luaentity() then - return false - end - local yaw = self.object:get_yaw() - local dir_x = -sin(yaw) * (self.collisionbox[4] + 0.5) - local dir_z = cos(yaw) * (self.collisionbox[4] + 0.5) - local pos = self.object:get_pos() - local ypos = pos.y + self.collisionbox[2] -- just above floor - - local free_fall, blocker = minetest.line_of_sight( - {x = pos.x + dir_x, y = ypos, z = pos.z + dir_z}, - {x = pos.x + dir_x, y = ypos - 3, z = pos.z + dir_z}) - if free_fall then - return true - else - local bnode = minetest.get_node(blocker) - local waterdanger = is_node_waterhazard(self, bnode.name) - if - waterdanger and (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) then - return false - elseif waterdanger and (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) == false then - return true - else - local def = minetest.registered_nodes[bnode.name] - if def and def.walkable then - return false - end - end - end - - return false -end - - --- get node but use fallback for nil or unknown -local node_ok = function(pos, fallback) - - fallback = fallback or mobs.fallback_node - - local node = minetest.get_node_or_nil(pos) - - if node and minetest.registered_nodes[node.name] then - return node - end - - return minetest.registered_nodes[fallback] -end - - --- environmental damage (water, lava, fire, light etc.) -local do_env_damage = function(self) - - -- feed/tame text timer (so mob 'full' messages dont spam chat) - if self.htimer > 0 then - self.htimer = self.htimer - 1 - end - - -- reset nametag after showing health stats - if self.htimer < 1 and self.nametag2 then - - self.nametag = self.nametag2 - self.nametag2 = nil + self.object:set_hp(self.health) update_tag(self) - end - local pos = self.object:get_pos() + -- make children grow quicker + if self.child == true then - self.time_of_day = minetest.get_timeofday() + -- deduct 10% of the time to adulthood + self.hornytimer = self.hornytimer + ((CHILD_GROW_TIME - self.hornytimer) * 0.1) + + return true + end + + -- feed and tame + self.food = (self.food or 0) + 1 + if self.food >= feed_count then + + self.food = 0 + + if breed and self.hornytimer == 0 then + self.horny = true + end + + if tame then + + self.tamed = true + + if not self.owner or self.owner == "" then + self.owner = clicker:get_player_name() + end + end + + -- make sound when fed so many times + mob_sound(self, "random", true) + end - -- remove mob if beyond map limits - if not within_limits(pos, 0) then - mcl_burning.extinguish(self.object) - self.object:remove() return true end + return false +end - -- Deal light damage to mob, returns true if mob died - local deal_light_damage = function(self, pos, damage) - if not (mod_weather and (mcl_weather.rain.raining or mcl_weather.state == "snow") and mcl_weather.is_outdoor(pos)) then - self.health = self.health - damage +-- no damage to nodes explosion +function mobs:safe_boom(self, pos, strength) + minetest_sound_play(self.sounds and self.sounds.explode or "tnt_explode", { + pos = pos, + gain = 1.0, + max_hear_distance = self.sounds and self.sounds.distance or 32 + }, true) + local radius = strength + entity_physics(pos, radius) + effect(pos, 32, "mcl_particles_smoke.png", radius * 3, radius * 5, radius, 1, 0) +end - effect(pos, 5, "mcl_particles_smoke.png") - if check_for_death(self, "light", {type = "light"}) then - return true - end - end - end - - -- Use get_node_light for Minetest version 5.3 where get_natural_light - -- does not exist yet. - local get_light = minetest.get_natural_light or minetest.get_node_light - local sunlight = get_light(pos, self.time_of_day) - - -- bright light harms mob - if self.light_damage ~= 0 and (sunlight or 0) > 12 then - if deal_light_damage(self, pos, self.light_damage) then - return true - end - end - local _, dim = nil, "overworld" - if mod_worlds then - _, dim = mcl_worlds.y_to_layer(pos.y) - end - if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then - if self.ignited_by_sunlight then - mcl_burning.set_on_fire(self.object, 10) +-- make explosion with protection and tnt mod check +function mobs:boom(self, pos, strength, fire) + self.object:remove() + if mod_explosions then + if mobs_griefing and not minetest_is_protected(pos, "") then + mcl_explosions.explode(pos, strength, { drop_chance = 1.0, fire = fire }, self.object) else - deal_light_damage(self, pos, self.sunlight_damage) - return true - end - end - - local y_level = self.collisionbox[2] - - if self.child then - y_level = self.collisionbox[2] * 0.5 - end - - -- what is mob standing in? - pos.y = pos.y + y_level + 0.25 -- foot level - local pos2 = {x=pos.x, y=pos.y-1, z=pos.z} - self.standing_in = node_ok(pos, "air").name - self.standing_on = node_ok(pos2, "air").name - - -- don't fall when on ignore, just stand still - if self.standing_in == "ignore" then - self.object:set_velocity({x = 0, y = 0, z = 0}) - end - - local nodef = minetest.registered_nodes[self.standing_in] - - -- rain - if self.rain_damage > 0 and mod_weather then - if mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) then - - self.health = self.health - self.rain_damage - - if check_for_death(self, "rain", {type = "environment", - pos = pos, node = self.standing_in}) then - return true - end - end - end - - pos.y = pos.y + 1 -- for particle effect position - - -- water damage - if self.water_damage > 0 - and nodef.groups.water then - - if self.water_damage ~= 0 then - - self.health = self.health - self.water_damage - - effect(pos, 5, "mcl_particles_smoke.png", nil, nil, 1, nil) - - if check_for_death(self, "water", {type = "environment", - pos = pos, node = self.standing_in}) then - return true - end - end - - -- lava damage - elseif self.lava_damage > 0 - and (nodef.groups.lava) then - - if self.lava_damage ~= 0 then - - self.health = self.health - self.lava_damage - - effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil) - - if check_for_death(self, "lava", {type = "environment", - pos = pos, node = self.standing_in}) then - return true - end - end - - -- fire damage - elseif self.fire_damage > 0 - and (nodef.groups.fire) then - - if self.fire_damage ~= 0 then - - self.health = self.health - self.fire_damage - - effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil) - - if check_for_death(self, "fire", {type = "environment", - pos = pos, node = self.standing_in}) then - return true - end - end - - -- damage_per_second node check - elseif nodef.damage_per_second ~= 0 and not nodef.groups.lava and not nodef.groups.fire then - - self.health = self.health - nodef.damage_per_second - - effect(pos, 5, "mcl_particles_smoke.png") - - if check_for_death(self, "dps", {type = "environment", - pos = pos, node = self.standing_in}) then - return true - end - end - - -- Drowning damage - if self.breath_max ~= -1 then - local drowning = false - if self.breathes_in_water then - if minetest.get_item_group(self.standing_in, "water") == 0 then - drowning = true - end - elseif nodef.drowning > 0 then - drowning = true - end - if drowning then - - self.breath = math.max(0, self.breath - 1) - - effect(pos, 2, "bubble.png", nil, nil, 1, nil) - if self.breath <= 0 then - local dmg - if nodef.drowning > 0 then - dmg = nodef.drowning - else - dmg = 4 - end - damage_effect(self, dmg) - self.health = self.health - dmg - end - if check_for_death(self, "drowning", {type = "environment", - pos = pos, node = self.standing_in}) then - return true - end - else - self.breath = math.min(self.breath_max, self.breath + 1) - end - end - - --- suffocation inside solid node - -- FIXME: Redundant with mcl_playerplus - if (self.suffocation == true) - and (nodef.walkable == nil or nodef.walkable == true) - and (nodef.collision_box == nil or nodef.collision_box.type == "regular") - and (nodef.node_box == nil or nodef.node_box.type == "regular") - and (nodef.groups.disable_suffocation ~= 1) - and (nodef.groups.opaque == 1) then - - -- Short grace period before starting to take suffocation damage. - -- This is different from players, who take damage instantly. - -- This has been done because mobs might briefly be inside solid nodes - -- when e.g. climbing up stairs. - -- This is a bit hacky because it assumes that do_env_damage - -- is called roughly every second only. - self.suffocation_timer = self.suffocation_timer + 1 - if self.suffocation_timer >= 3 then - -- 2 damage per second - -- TODO: Deal this damage once every 1/2 second - self.health = self.health - 2 - - if check_for_death(self, "suffocation", {type = "environment", - pos = pos, node = self.standing_in}) then - return true - end + mobs:safe_boom(self, pos, strength) end else - self.suffocation_timer = 0 - end - - return check_for_death(self, "", {type = "unknown"}) -end - - --- jump if facing a solid node (not fences or gates) -local do_jump = function(self) - - if not self.jump - or self.jump_height == 0 - or self.fly - or (self.child and self.type ~= "monster") - or self.order == "stand" then - return false - end - - self.facing_fence = false - - -- something stopping us while moving? - if self.state ~= "stand" - and get_velocity(self) > 0.5 - and self.object:get_velocity().y ~= 0 then - return false - end - - local pos = self.object:get_pos() - local yaw = self.object:get_yaw() - - -- what is mob standing on? - pos.y = pos.y + self.collisionbox[2] - 0.2 - - local nod = node_ok(pos) - - if minetest.registered_nodes[nod.name].walkable == false then - return false - end - - -- where is front - local dir_x = -sin(yaw) * (self.collisionbox[4] + 0.5) - local dir_z = cos(yaw) * (self.collisionbox[4] + 0.5) - - -- what is in front of mob? - nod = node_ok({ - x = pos.x + dir_x, - y = pos.y + 0.5, - z = pos.z + dir_z - }) - - -- this is used to detect if there's a block on top of the block in front of the mob. - -- If there is, there is no point in jumping as we won't manage. - local nodTop = node_ok({ - x = pos.x + dir_x, - y = pos.y + 1.5, - z = pos.z + dir_z - }, "air") - - -- we don't attempt to jump if there's a stack of blocks blocking - if minetest.registered_nodes[nodTop.name].walkable == true then - return false - end - - -- thin blocks that do not need to be jumped - if nod.name == node_snow then - return false - end - - if self.walk_chance == 0 - or minetest.registered_items[nod.name].walkable then - - if minetest.get_item_group(nod.name, "fence") == 0 - and minetest.get_item_group(nod.name, "fence_gate") == 0 - and minetest.get_item_group(nod.name, "wall") == 0 then - - local v = self.object:get_velocity() - - v.y = self.jump_height - - set_animation(self, "jump") -- only when defined - - self.object:set_velocity(v) - - -- when in air move forward - minetest.after(0.3, function(self, v) - if (not self.object) or (not self.object:get_luaentity()) or (self.state == "die") then - return - end - self.object:set_acceleration({ - x = v.x * 2, - y = -10, - z = v.z * 2, - }) - end, self, v) - - if self.jump_sound_cooloff <= 0 then - mob_sound(self, "jump") - self.jump_sound_cooloff = 0.5 - end - else - self.facing_fence = true - end - - -- if we jumped against a block/wall 4 times then turn - if self.object:get_velocity().x ~= 0 - and self.object:get_velocity().z ~= 0 then - - self.jump_count = (self.jump_count or 0) + 1 - - if self.jump_count == 4 then - - local yaw = self.object:get_yaw() or 0 - - yaw = set_yaw(self, yaw + 1.35, 8) - - self.jump_count = 0 - end - end - - return true - end - - return false -end - - --- blast damage to entities nearby -local entity_physics = function(pos, radius) - - radius = radius * 2 - - local objs = minetest.get_objects_inside_radius(pos, radius) - local obj_pos, dist - - for n = 1, #objs do - - obj_pos = objs[n]:get_pos() - - dist = vector.distance(pos, obj_pos) - if dist < 1 then dist = 1 end - - local damage = floor((4 / dist) * radius) - local ent = objs[n]:get_luaentity() - - -- punches work on entities AND players - objs[n]:punch(objs[n], 1.0, { - full_punch_interval = 1.0, - damage_groups = {fleshy = damage}, - }, pos) + mobs:safe_boom(self, pos, strength) end end +-- falling and fall damage +-- returns true if mob died +local falling = function(self, pos) --- should mob follow what I'm holding ? -local follow_holding = function(self, clicker) - - if mobs.invis[clicker:get_player_name()] then - return false + if self.fly and self.state ~= "die" then + return end - local item = clicker:get_wielded_item() - local t = type(self.follow) - - -- single item - if t == "string" - and item:get_name() == self.follow then - return true - - -- multiple items - elseif t == "table" then - - for no = 1, #self.follow do - - if self.follow[no] == item:get_name() then - return true - end + if mcl_portals ~= nil then + if mcl_portals.nether_portal_cooloff(self.object) then + return false -- mob has teleported through Nether portal - it's 99% not falling end end - return false -end + -- floating in water (or falling) + local v = self.object:get_velocity() + if v.y > 0 then --- find two animals of same type and breed if nearby and horny -local breed = function(self) + -- apply gravity when moving up + self.object:set_acceleration({ + x = 0, + y = -10, + z = 0 + }) - -- child takes a long time before growing into adult - if self.child == true then + elseif v.y <= 0 and v.y > self.fall_speed then - -- When a child, hornytimer is used to count age until adulthood - self.hornytimer = self.hornytimer + 1 + -- fall downwards at set speed + self.object:set_acceleration({ + x = 0, + y = self.fall_speed, + z = 0 + }) + else + -- stop accelerating once max fall speed hit + self.object:set_acceleration({x = 0, y = 0, z = 0}) + end - if self.hornytimer >= CHILD_GROW_TIME then + if minetest_registered_nodes[node_ok(pos).name].groups.lava then - self.child = false - self.hornytimer = 0 + if self.floats_on_lava == 1 then - self.object:set_properties({ - textures = self.base_texture, - mesh = self.base_mesh, - visual_size = self.base_size, - collisionbox = self.base_colbox, - selectionbox = self.base_selbox, + self.object:set_acceleration({ + x = 0, + y = -self.fall_speed / (max(1, v.y) ^ 2), + z = 0 }) - - -- custom function when child grows up - if self.on_grown then - self.on_grown(self) - else - -- jump when fully grown so as not to fall into ground - self.object:set_velocity({ - x = 0, - y = self.jump_height, - z = 0 - }) - end - end - - return - end - - -- horny animal can mate for HORNY_TIME seconds, - -- afterwards horny animal cannot mate again for HORNY_AGAIN_TIME seconds - if self.horny == true - and self.hornytimer < HORNY_TIME + HORNY_AGAIN_TIME then - - self.hornytimer = self.hornytimer + 1 - - if self.hornytimer >= HORNY_TIME + HORNY_AGAIN_TIME then - self.hornytimer = 0 - self.horny = false end end - -- find another same animal who is also horny and mate if nearby - if self.horny == true - and self.hornytimer <= HORNY_TIME then + -- in water then float up + if minetest_registered_nodes[node_ok(pos).name].groups.water then - local pos = self.object:get_pos() + if self.floats == 1 then - effect({x = pos.x, y = pos.y + 1, z = pos.z}, 8, "heart.png", 3, 4, 1, 0.1) - - local objs = minetest.get_objects_inside_radius(pos, 3) - local num = 0 - local ent = nil - - for n = 1, #objs do - - ent = objs[n]:get_luaentity() - - -- check for same animal with different colour - local canmate = false - - if ent then - - if ent.name == self.name then - canmate = true - else - local entname = string.split(ent.name,":") - local selfname = string.split(self.name,":") - - if entname[1] == selfname[1] then - entname = string.split(entname[2],"_") - selfname = string.split(selfname[2],"_") - - if entname[1] == selfname[1] then - canmate = true - end - end - end - end - - if ent - and canmate == true - and ent.horny == true - and ent.hornytimer <= HORNY_TIME then - num = num + 1 - end - - -- found your mate? then have a baby - if num > 1 then - - self.hornytimer = HORNY_TIME + 1 - ent.hornytimer = HORNY_TIME + 1 - - -- spawn baby - minetest.after(5, function(parent1, parent2, pos) - if not parent1.object:get_luaentity() then - return - end - if not parent2.object:get_luaentity() then - return - end - - -- Give XP - if mod_experience then - mcl_experience.throw_experience(pos, math.random(1, 7)) - end - - -- custom breed function - if parent1.on_breed then - -- when false, skip going any further - if parent1.on_breed(parent1, parent2) == false then - return - end - end - - local child = mobs:spawn_child(pos, parent1.name) - - local ent_c = child:get_luaentity() - - - -- Use texture of one of the parents - local p = math.random(1, 2) - if p == 1 then - ent_c.base_texture = parent1.base_texture - else - ent_c.base_texture = parent2.base_texture - end - child:set_properties({ - textures = ent_c.base_texture - }) - - -- tamed and owned by parents' owner - ent_c.tamed = true - ent_c.owner = parent1.owner - end, self, ent, pos) - - num = 0 - - break - end - end - end -end - - --- find and replace what mob is looking for (grass, wheat etc.) -local replace = function(self, pos) - - if not self.replace_rate - or not self.replace_what - or self.child == true - or self.object:get_velocity().y ~= 0 - or random(1, self.replace_rate) > 1 then - return - end - - local what, with, y_offset - - if type(self.replace_what[1]) == "table" then - - local num = random(#self.replace_what) - - what = self.replace_what[num][1] or "" - with = self.replace_what[num][2] or "" - y_offset = self.replace_what[num][3] or 0 - else - what = self.replace_what - with = self.replace_with or "" - y_offset = self.replace_offset or 0 - end - - pos.y = pos.y + y_offset - - local node = minetest.get_node(pos) - if node.name == what then - - local oldnode = {name = what, param2 = node.param2} - local newnode = {name = with, param2 = node.param2} - local on_replace_return - - if self.on_replace then - on_replace_return = self.on_replace(self, pos, oldnode, newnode) - end - - if on_replace_return ~= false then - - if mobs_griefing then - minetest.set_node(pos, newnode) - end - - end - end -end - - --- check if daytime and also if mob is docile during daylight hours -local day_docile = function(self) - - if self.docile_by_day == false then - - return false - - elseif self.docile_by_day == true - and self.time_of_day > 0.2 - and self.time_of_day < 0.8 then - - return true - end -end - - -local los_switcher = false -local height_switcher = false - --- path finding and smart mob routine by rnd, line_of_sight and other edits by Elkien3 -local smart_mobs = function(self, s, p, dist, dtime) - - local s1 = self.path.lastpos - - local target_pos = self.attack:get_pos() - - -- is it becoming stuck? - if abs(s1.x - s.x) + abs(s1.z - s.z) < .5 then - self.path.stuck_timer = self.path.stuck_timer + dtime - else - self.path.stuck_timer = 0 - end - - self.path.lastpos = {x = s.x, y = s.y, z = s.z} - - local use_pathfind = false - local has_lineofsight = minetest.line_of_sight( - {x = s.x, y = (s.y) + .5, z = s.z}, - {x = target_pos.x, y = (target_pos.y) + 1.5, z = target_pos.z}, .2) - - -- im stuck, search for path - if not has_lineofsight then - - if los_switcher == true then - use_pathfind = true - los_switcher = false - end -- cannot see target! - else - if los_switcher == false then - - los_switcher = true - use_pathfind = false - - minetest.after(1, function(self) - if not self.object:get_luaentity() then - return - end - if has_lineofsight then self.path.following = false end - end, self) - end -- can see target! - end - - if (self.path.stuck_timer > stuck_timeout and not self.path.following) then - - use_pathfind = true - self.path.stuck_timer = 0 - - minetest.after(1, function(self) - if not self.object:get_luaentity() then - return - end - if has_lineofsight then self.path.following = false end - end, self) - end - - if (self.path.stuck_timer > stuck_path_timeout and self.path.following) then - - use_pathfind = true - self.path.stuck_timer = 0 - - minetest.after(1, function(self) - if not self.object:get_luaentity() then - return - end - if has_lineofsight then self.path.following = false end - end, self) - end - - if math.abs(vector.subtract(s,target_pos).y) > self.stepheight then - - if height_switcher then - use_pathfind = true - height_switcher = false + self.object:set_acceleration({ + x = 0, + y = -self.fall_speed / (math.max(1, v.y) ^ 2), + z = 0 + }) end else - if not height_switcher then - use_pathfind = false - height_switcher = true - end - end - if use_pathfind then - -- lets try find a path, first take care of positions - -- since pathfinder is very sensitive - local sheight = self.collisionbox[5] - self.collisionbox[2] - - -- round position to center of node to avoid stuck in walls - -- also adjust height for player models! - s.x = floor(s.x + 0.5) - s.z = floor(s.z + 0.5) - - local ssight, sground = minetest.line_of_sight(s, { - x = s.x, y = s.y - 4, z = s.z}, 1) - - -- determine node above ground - if not ssight then - s.y = sground.y + 1 - end - - local p1 = self.attack:get_pos() - - p1.x = floor(p1.x + 0.5) - p1.y = floor(p1.y + 0.5) - p1.z = floor(p1.z + 0.5) - - local dropheight = 12 - if self.fear_height ~= 0 then dropheight = self.fear_height end - local jumpheight = 0 - if self.jump and self.jump_height >= 4 then - jumpheight = math.min(math.ceil(self.jump_height / 4), 4) - elseif self.stepheight > 0.5 then - jumpheight = 1 - end - self.path.way = minetest.find_path(s, p1, 16, jumpheight, dropheight, "A*_noprefetch") - - self.state = "" - do_attack(self, self.attack) - - -- no path found, try something else - if not self.path.way then - - self.path.following = false - - -- lets make way by digging/building if not accessible - if self.pathfinding == 2 and mobs_griefing then - - -- is player higher than mob? - if s.y < p1.y then - - -- build upwards - if not minetest.is_protected(s, "") then - - local ndef1 = minetest.registered_nodes[self.standing_in] - - if ndef1 and (ndef1.buildable_to or ndef1.groups.liquid) then - - minetest.set_node(s, {name = mobs.fallback_node}) - end - end - - local sheight = math.ceil(self.collisionbox[5]) + 1 - - -- assume mob is 2 blocks high so it digs above its head - s.y = s.y + sheight - - -- remove one block above to make room to jump - if not minetest.is_protected(s, "") then - - local node1 = node_ok(s, "air").name - local ndef1 = minetest.registered_nodes[node1] - - if node1 ~= "air" - and node1 ~= "ignore" - and ndef1 - and not ndef1.groups.level - and not ndef1.groups.unbreakable - and not ndef1.groups.liquid then - - minetest.set_node(s, {name = "air"}) - minetest.add_item(s, ItemStack(node1)) - - end - end - - s.y = s.y - sheight - self.object:set_pos({x = s.x, y = s.y + 2, z = s.z}) - - else -- dig 2 blocks to make door toward player direction - - local yaw1 = self.object:get_yaw() + pi / 2 - local p1 = { - x = s.x + cos(yaw1), - y = s.y, - z = s.z + sin(yaw1) - } - - if not minetest.is_protected(p1, "") then - - local node1 = node_ok(p1, "air").name - local ndef1 = minetest.registered_nodes[node1] - - if node1 ~= "air" - and node1 ~= "ignore" - and ndef1 - and not ndef1.groups.level - and not ndef1.groups.unbreakable - and not ndef1.groups.liquid then - - minetest.add_item(p1, ItemStack(node1)) - minetest.set_node(p1, {name = "air"}) - end - - p1.y = p1.y + 1 - node1 = node_ok(p1, "air").name - ndef1 = minetest.registered_nodes[node1] - - if node1 ~= "air" - and node1 ~= "ignore" - and ndef1 - and not ndef1.groups.level - and not ndef1.groups.unbreakable - and not ndef1.groups.liquid then - - minetest.add_item(p1, ItemStack(node1)) - minetest.set_node(p1, {name = "air"}) - end - - end - end - end - - -- will try again in 2 seconds - self.path.stuck_timer = stuck_timeout - 2 - elseif s.y < p1.y and (not self.fly) then - do_jump(self) --add jump to pathfinding - self.path.following = true - -- Yay, I found path! - -- TODO: Implement war_cry sound without being annoying - --mob_sound(self, "war_cry", true) - else - set_velocity(self, self.walk_velocity) - - -- follow path now that it has it - self.path.following = true - end end end --- specific attacks -local specific_attack = function(list, what) - - -- no list so attack default (player, animals etc.) - if list == nil then - return true - end - - -- found entity on list to attack? - for no = 1, #list do - - if list[no] == what then - return true - end - end - - return false -end - --- monster find someone to attack -local monster_attack = function(self) - - if self.type ~= "monster" - or not damage_enabled - or minetest.is_creative_enabled("") - or self.passive - or self.state == "attack" - or day_docile(self) then - return - end - - local s = self.object:get_pos() - local p, sp, dist - local player, obj, min_player - local type, name = "", "" - local min_dist = self.view_range + 1 - local objs = minetest.get_objects_inside_radius(s, self.view_range) - - for n = 1, #objs do - - if objs[n]:is_player() then - - if mobs.invis[ objs[n]:get_player_name() ] or (not object_in_range(self, objs[n])) then - type = "" - else - player = objs[n] - type = "player" - name = "player" - end - else - obj = objs[n]:get_luaentity() - - if obj then - player = obj.object - type = obj.type - name = obj.name or "" - end - end - - -- find specific mob to attack, failing that attack player/npc/animal - if specific_attack(self.specific_attack, name) - and (type == "player" or type == "npc" - or (type == "animal" and self.attack_animals == true)) then - - p = player:get_pos() - sp = s - - dist = vector.distance(p, s) - - -- aim higher to make looking up hills more realistic - p.y = p.y + 1 - sp.y = sp.y + 1 - - - -- choose closest player to attack - if dist < min_dist - and line_of_sight(self, sp, p, 2) == true then - min_dist = dist - min_player = player - end - end - end - - -- attack player - if min_player then - do_attack(self, min_player) - end -end - - --- npc, find closest monster to attack -local npc_attack = function(self) - - if self.type ~= "npc" - or not self.attacks_monsters - or self.state == "attack" then - return - end - - local p, sp, obj, min_player - local s = self.object:get_pos() - local min_dist = self.view_range + 1 - local objs = minetest.get_objects_inside_radius(s, self.view_range) - - for n = 1, #objs do - - obj = objs[n]:get_luaentity() - - if obj and obj.type == "monster" then - - p = obj.object:get_pos() - sp = s - - local dist = vector.distance(p, s) - - -- aim higher to make looking up hills more realistic - p.y = p.y + 1 - sp.y = sp.y + 1 - - if dist < min_dist - and line_of_sight(self, sp, p, 2) == true then - min_dist = dist - min_player = obj.object - end - end - end - - if min_player then - do_attack(self, min_player) - end -end - - --- specific runaway -local specific_runaway = function(list, what) - - -- no list so do not run - if list == nil then - return false - end - - -- found entity on list to attack? - for no = 1, #list do - - if list[no] == what then - return true - end - end - - return false -end -- find someone to runaway from @@ -2053,7 +299,7 @@ local runaway_from = function(self) local player, obj, min_player local type, name = "", "" local min_dist = self.view_range + 1 - local objs = minetest.get_objects_inside_radius(s, self.view_range) + local objs = minetest_get_objects_inside_radius(s, self.view_range) for n = 1, #objs do @@ -2110,10 +356,10 @@ local runaway_from = function(self) z = lp.z - s.z } - local yaw = (atan(vec.z / vec.x) + 3 * pi / 2) - self.rotate + local yaw = (atan(vec.z / vec.x) + 3 * math_pi / 2) - self.rotate if lp.x > s.x then - yaw = yaw + pi + yaw = yaw + math_pi end yaw = set_yaw(self, yaw, 4) @@ -2124,6 +370,26 @@ local runaway_from = function(self) end +-- specific runaway +local specific_runaway = function(list, what) + + -- no list so do not run + if list == nil then + return false + end + + -- found entity on list to attack? + for no = 1, #list do + + if list[no] == what then + return true + end + end + + return false +end + + -- follow player if owner or holding item, if fish outta water then flop local follow_flop = function(self) @@ -2202,9 +468,9 @@ local follow_flop = function(self) z = p.z - s.z } - local yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate + local yaw = (atan(vec.z / vec.x) + math_pi / 2) - self.rotate - if p.x > s.x then yaw = yaw + pi end + if p.x > s.x then yaw = yaw + math_pi end set_yaw(self, yaw, 2.35) @@ -2235,7 +501,7 @@ local follow_flop = function(self) self.state = "flop" self.object:set_acceleration({x = 0, y = DEFAULT_FALL_SPEED, z = 0}) - local sdef = minetest.registered_nodes[self.standing_on] + local sdef = minetest_registered_nodes[self.standing_on] -- Flop on ground if sdef and sdef.walkable then mob_sound(self, "flop") @@ -2258,7 +524,141 @@ local follow_flop = function(self) end --- dogshoot attack switch and counter function +-- npc, find closest monster to attack +local npc_attack = function(self) + + if self.type ~= "npc" + or not self.attacks_monsters + or self.state == "attack" then + return + end + + local p, sp, obj, min_player + local s = self.object:get_pos() + local min_dist = self.view_range + 1 + local objs = minetest_get_objects_inside_radius(s, self.view_range) + + for n = 1, #objs do + + obj = objs[n]:get_luaentity() + + if obj and obj.type == "monster" then + + p = obj.object:get_pos() + sp = s + + local dist = vector.distance(p, s) + + -- aim higher to make looking up hills more realistic + p.y = p.y + 1 + sp.y = sp.y + 1 + + if dist < min_dist + and line_of_sight(self, sp, p, 2) == true then + min_dist = dist + min_player = obj.object + end + end + end + + if min_player then + do_attack(self, min_player) + end +end + + +-- monster find someone to attack +local monster_attack = function(self) + + if self.type ~= "monster" + or not damage_enabled + or minetest_is_creative_enabled("") + or self.passive + or self.state == "attack" + or day_docile(self) then + return + end + + local s = self.object:get_pos() + local p, sp, dist + local player, obj, min_player + local type, name = "", "" + local min_dist = self.view_range + 1 + local objs = minetest_get_objects_inside_radius(s, self.view_range) + + for n = 1, #objs do + + if objs[n]:is_player() then + + if mobs.invis[ objs[n]:get_player_name() ] or (not object_in_range(self, objs[n])) then + type = "" + else + player = objs[n] + type = "player" + name = "player" + end + else + obj = objs[n]:get_luaentity() + + if obj then + player = obj.object + type = obj.type + name = obj.name or "" + end + end + + -- find specific mob to attack, failing that attack player/npc/animal + if specific_attack(self.specific_attack, name) + and (type == "player" or type == "npc" + or (type == "animal" and self.attack_animals == true)) then + + p = player:get_pos() + sp = s + + dist = vector.distance(p, s) + + -- aim higher to make looking up hills more realistic + p.y = p.y + 1 + sp.y = sp.y + 1 + + + -- choose closest player to attack + if dist < min_dist + and line_of_sight(self, sp, p, 2) == true then + min_dist = dist + min_player = player + end + end + end + + -- attack player + if min_player then + do_attack(self, min_player) + end +end + + +-- specific attacks +local specific_attack = function(list, what) + + -- no list so attack default (player, animals etc.) + if list == nil then + return true + end + + -- found entity on list to attack? + for no = 1, #list do + + if list[no] == what then + return true + end + end + + return false +end + + +-- dogfight attack switch and counter function local dogswitch = function(self, dtime) -- switch mode not activated @@ -2286,19 +686,1491 @@ local dogswitch = function(self, dtime) return self.dogshoot_switch end --- execute current state (stand, walk, run, attacks) --- returns true if mob has died -local do_states = function(self, dtime) +-- path finding and smart mob routine by rnd, line_of_sight and other edits by Elkien3 +local smart_mobs = function(self, s, p, dist, dtime) - local yaw = self.object:get_yaw() or 0 + local s1 = self.path.lastpos + + local target_pos = self.attack:get_pos() + + -- is it becoming stuck? + if math_abs(s1.x - s.x) + math_abs(s1.z - s.z) < .5 then + self.path.stuck_timer = self.path.stuck_timer + dtime + else + self.path.stuck_timer = 0 + end + + self.path.lastpos = {x = s.x, y = s.y, z = s.z} + + local use_pathfind = false + local has_lineofsight = minetest_line_of_sight( + {x = s.x, y = (s.y) + .5, z = s.z}, + {x = target_pos.x, y = (target_pos.y) + 1.5, z = target_pos.z}, .2) + + -- im stuck, search for path + if not has_lineofsight then + + if los_switcher == true then + use_pathfind = true + los_switcher = false + end -- cannot see target! + else + if los_switcher == false then + + los_switcher = true + use_pathfind = false + + minetest_after(1, function(self) + if not self.object:get_luaentity() then + return + end + if has_lineofsight then self.path.following = false end + end, self) + end -- can see target! + end + + if (self.path.stuck_timer > stuck_timeout and not self.path.following) then + + use_pathfind = true + self.path.stuck_timer = 0 + + minetest_after(1, function(self) + if not self.object:get_luaentity() then + return + end + if has_lineofsight then self.path.following = false end + end, self) + end + + if (self.path.stuck_timer > stuck_path_timeout and self.path.following) then + + use_pathfind = true + self.path.stuck_timer = 0 + + minetest_after(1, function(self) + if not self.object:get_luaentity() then + return + end + if has_lineofsight then self.path.following = false end + end, self) + end + + if math_abs(vector.subtract(s,target_pos).y) > self.stepheight then + + if height_switcher then + use_pathfind = true + height_switcher = false + end + else + if not height_switcher then + use_pathfind = false + height_switcher = true + end + end + + if use_pathfind then + -- lets try find a path, first take care of positions + -- since pathfinder is very sensitive + local sheight = self.collisionbox[5] - self.collisionbox[2] + + -- round position to center of node to avoid stuck in walls + -- also adjust height for player models! + s.x = math_floor(s.x + 0.5) + s.z = math_floor(s.z + 0.5) + + local ssight, sground = minetest_line_of_sight(s, { + x = s.x, y = s.y - 4, z = s.z}, 1) + + -- determine node above ground + if not ssight then + s.y = sground.y + 1 + end + + local p1 = self.attack:get_pos() + + p1.x = math_floor(p1.x + 0.5) + p1.y = math_floor(p1.y + 0.5) + p1.z = math_floor(p1.z + 0.5) + + local dropheight = 12 + if self.fear_height ~= 0 then dropheight = self.fear_height end + local jumpheight = 0 + if self.jump and self.jump_height >= 4 then + jumpheight = math.min(math.ceil(self.jump_height / 4), 4) + elseif self.stepheight > 0.5 then + jumpheight = 1 + end + self.path.way = minetest_find_path(s, p1, 16, jumpheight, dropheight, "A*_noprefetch") + + self.state = "" + do_attack(self, self.attack) + + -- no path found, try something else + if not self.path.way then + + self.path.following = false + + -- lets make way by digging/building if not accessible + if self.pathfinding == 2 and mobs_griefing then + + -- is player higher than mob? + if s.y < p1.y then + + -- build upwards + if not minetest_is_protected(s, "") then + + local ndef1 = minetest_registered_nodes[self.standing_in] + + if ndef1 and (ndef1.buildable_to or ndef1.groups.liquid) then + + minetest_set_node(s, {name = mobs.fallback_node}) + end + end + + local sheight = math.ceil(self.collisionbox[5]) + 1 + + -- assume mob is 2 blocks high so it digs above its head + s.y = s.y + sheight + + -- remove one block above to make room to jump + if not minetest_is_protected(s, "") then + + local node1 = node_ok(s, "air").name + local ndef1 = minetest_registered_nodes[node1] + + if node1 ~= "air" + and node1 ~= "ignore" + and ndef1 + and not ndef1.groups.level + and not ndef1.groups.unbreakable + and not ndef1.groups.liquid then + + minetest_set_node(s, {name = "air"}) + minetest_add_item(s, ItemStack(node1)) + + end + end + + s.y = s.y - sheight + self.object:set_pos({x = s.x, y = s.y + 2, z = s.z}) + + else -- dig 2 blocks to make door toward player direction + + local yaw1 = self.object:get_yaw() + math_pi / 2 + local p1 = { + x = s.x + math_cos(yaw1), + y = s.y, + z = s.z + math_sin(yaw1) + } + + if not minetest_is_protected(p1, "") then + + local node1 = node_ok(p1, "air").name + local ndef1 = minetest_registered_nodes[node1] + + if node1 ~= "air" + and node1 ~= "ignore" + and ndef1 + and not ndef1.groups.level + and not ndef1.groups.unbreakable + and not ndef1.groups.liquid then + + minetest_add_item(p1, ItemStack(node1)) + minetest_set_node(p1, {name = "air"}) + end + + p1.y = p1.y + 1 + node1 = node_ok(p1, "air").name + ndef1 = minetest_registered_nodes[node1] + + if node1 ~= "air" + and node1 ~= "ignore" + and ndef1 + and not ndef1.groups.level + and not ndef1.groups.unbreakable + and not ndef1.groups.liquid then + + minetest_add_item(p1, ItemStack(node1)) + minetest_set_node(p1, {name = "air"}) + end + + end + end + end + + -- will try again in 2 seconds + self.path.stuck_timer = stuck_timeout - 2 + elseif s.y < p1.y and (not self.fly) then + do_jump(self) --add jump to pathfinding + self.path.following = true + -- Yay, I found path! + -- TODO: Implement war_cry sound without being annoying + --mob_sound(self, "war_cry", true) + else + set_velocity(self, self.walk_velocity) + + -- follow path now that it has it + self.path.following = true + end + end +end + + + + + + +-- check if mob is dead or only hurt +local check_for_death = function(self, cause, cmi_cause) + + if self.state == "die" then + return true + end + + -- has health actually changed? + if self.health == self.old_health and self.health > 0 then + return false + end + + local damaged = self.health < self.old_health + self.old_health = self.health + + -- still got some health? + if self.health > 0 then + + -- make sure health isn't higher than max + if self.health > self.hp_max then + self.health = self.hp_max + end + + -- play damage sound if health was reduced and make mob flash red. + if damaged then + add_texture_mod(self, "^[colorize:red:130") + minetest_after(.2, function(self) + if self and self.object then + remove_texture_mod(self, "^[colorize:red:130") + end + end, self) + mob_sound(self, "damage") + end + + -- backup nametag so we can show health stats + if not self.nametag2 then + self.nametag2 = self.nametag or "" + end + + if show_health + and (cmi_cause and cmi_cause.type == "punch") then + + self.htimer = 2 + self.nametag = "♥ " .. self.health .. " / " .. self.hp_max + + update_tag(self) + end + + return false + end + + mob_sound(self, "death") + + local function death_handle(self) + -- dropped cooked item if mob died in fire or lava + if cause == "lava" or cause == "fire" then + item_drop(self, true, 0) + else + local wielditem = ItemStack() + if cause == "hit" then + local puncher = cmi_cause.puncher + if puncher then + wielditem = puncher:get_wielded_item() + end + end + local cooked = mcl_burning.is_burning(self.object) or mcl_enchanting.has_enchantment(wielditem, "fire_aspect") + local looting = mcl_enchanting.get_enchantment(wielditem, "looting") + item_drop(self, cooked, looting) + + if mod_experience and ((not self.child) or self.type ~= "animal") and (minetest_get_us_time() - self.xp_timestamp <= 5000000) then + mcl_experience.throw_experience(self.object:get_pos(), math.random(self.xp_min, self.xp_max)) + end + end + end + + -- execute custom death function + if self.on_die then + + local pos = self.object:get_pos() + local on_die_exit = self.on_die(self, pos, cmi_cause) + if on_die_exit ~= true then + death_handle(self) + end + + if use_cmi then + cmi.notify_die(self.object, cmi_cause) + end + + if on_die_exit == true then + self.state = "die" + mcl_burning.extinguish(self.object) + self.object:remove() + return true + end + end + + local collisionbox + if self.collisionbox then + collisionbox = table.copy(self.collisionbox) + end + + self.state = "die" + self.attack = nil + self.v_start = false + self.fall_speed = DEFAULT_FALL_SPEED + self.timer = 0 + self.blinktimer = 0 + remove_texture_mod(self, "^[colorize:#FF000040") + remove_texture_mod(self, "^[brighten") + self.passive = true + + self.object:set_properties({ + pointable = false, + collide_with_objects = false, + }) + + set_velocity(self, 0) + local acc = self.object:get_acceleration() + acc.x, acc.y, acc.z = 0, DEFAULT_FALL_SPEED, 0 + self.object:set_acceleration(acc) + + local length + -- default death function and die animation (if defined) + if self.instant_death then + length = 0 + elseif self.animation + and self.animation.die_start + and self.animation.die_end then + + local frames = self.animation.die_end - self.animation.die_start + local speed = self.animation.die_speed or 15 + length = max(frames / speed, 0) + DEATH_DELAY + set_animation(self, "die") + else + local rot = self.object:get_rotation() + rot.z = math_pi/2 + self.object:set_rotation(rot) + length = 1 + DEATH_DELAY + set_animation(self, "stand", true) + end + + + -- Remove body after a few seconds and drop stuff + local kill = function(self) + if not self.object:get_luaentity() then + return + end + if use_cmi then + cmi.notify_die(self.object, cmi_cause) + end + + death_handle(self) + local dpos = self.object:get_pos() + local cbox = self.collisionbox + local yaw = self.object:get_rotation().y + mcl_burning.extinguish(self.object) + self.object:remove() + mobs.death_effect(dpos, yaw, cbox, not self.instant_death) + end + if length <= 0 then + kill(self) + else + minetest_after(length, kill, self) + end + + return true +end + +local damage_effect = function(self, damage) + -- damage particles + if (not disable_blood) and damage > 0 then + + local amount_large = math_floor(damage / 2) + local amount_small = damage % 2 + + local pos = self.object:get_pos() + + pos.y = pos.y + (self.collisionbox[5] - self.collisionbox[2]) * .5 + + local texture = "mobs_blood.png" + -- full heart damage (one particle for each 2 HP damage) + if amount_large > 0 then + effect(pos, amount_large, texture, 2, 2, 1.75, 0, nil, true) + end + -- half heart damage (one additional particle if damage is an odd number) + if amount_small > 0 then + -- TODO: Use "half heart" + effect(pos, amount_small, texture, 1, 1, 1.75, 0, nil, true) + end + end +end + + +-- custom particle effects +local effect = function(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down) + + radius = radius or 2 + min_size = min_size or 0.5 + max_size = max_size or 1 + gravity = gravity or -10 + glow = glow or 0 + go_down = go_down or false + + local ym + if go_down then + ym = 0 + else + ym = -radius + end + + minetest_add_particlespawner({ + amount = amount, + time = 0.25, + minpos = pos, + maxpos = pos, + minvel = {x = -radius, y = ym, z = -radius}, + maxvel = {x = radius, y = radius, z = radius}, + minacc = {x = 0, y = gravity, z = 0}, + maxacc = {x = 0, y = gravity, z = 0}, + minexptime = 0.1, + maxexptime = 1, + minsize = min_size, + maxsize = max_size, + texture = texture, + glow = glow, + }) +end + + +-- are we flying in what we are suppose to? (taikedz) +local flight_check = function(self) + + local nod = self.standing_in + local def = minetest_registered_nodes[nod] + + if not def then return false end -- nil check + + local fly_in + if type(self.fly_in) == "string" then + fly_in = { self.fly_in } + elseif type(self.fly_in) == "table" then + fly_in = self.fly_in + else + return false + end + + for _,checknode in pairs(fly_in) do + if nod == checknode then + return true + elseif checknode == "__airlike" and def.walkable == false and + (def.liquidtype == "none" or minetest_get_item_group(nod, "fake_liquid") == 1) then + return true + end + end + + return false +end + + +-- check line of sight (BrunoMine) +local line_of_sight = function(self, pos1, pos2, stepsize) + + stepsize = stepsize or 1 + + local s, pos = minetest_line_of_sight(pos1, pos2, stepsize) + + -- normal walking and flying mobs can see you through air + if s == true then + return true + end + + -- New pos1 to be analyzed + local npos1 = {x = pos1.x, y = pos1.y, z = pos1.z} + + local r, pos = minetest_line_of_sight(npos1, pos2, stepsize) + + -- Checks the return + if r == true then return true end + + -- Nodename found + local nn = minetest_get_node(pos).name + + -- Target Distance (td) to travel + local td = vector.distance(pos1, pos2) + + -- Actual Distance (ad) traveled + local ad = 0 + + -- It continues to advance in the line of sight in search of a real + -- obstruction which counts as 'normal' nodebox. + while minetest_registered_nodes[nn] + and minetest_registered_nodes[nn].walkable == false do + + -- Check if you can still move forward + if td < ad + stepsize then + return true -- Reached the target + end + + -- Moves the analyzed pos + local d = vector.distance(pos1, pos2) + + npos1.x = ((pos2.x - pos1.x) / d * stepsize) + pos1.x + npos1.y = ((pos2.y - pos1.y) / d * stepsize) + pos1.y + npos1.z = ((pos2.z - pos1.z) / d * stepsize) + pos1.z + + -- NaN checks + if d == 0 + or npos1.x ~= npos1.x + or npos1.y ~= npos1.y + or npos1.z ~= npos1.z then + return false + end + + ad = ad + stepsize + + -- scan again + r, pos = minetest_line_of_sight(npos1, pos2, stepsize) + + if r == true then return true end + + -- New Nodename found + nn = minetest_get_node(pos).name + + end + + return false +end + +-- Returns true if node is a water hazard +local is_node_waterhazard = function(self, nodename) + local nn = nodename + if self.water_damage > 0 then + if minetest_get_item_group(nn, "water") ~= 0 then + return true + end + end + if minetest_registered_nodes[nn] and minetest_registered_nodes[nn].drowning and minetest_registered_nodes[nn].drowning > 0 then + if self.breath_max ~= -1 then + -- check if the mob is water-breathing _and_ the block is water; only return true if neither is the case + -- this will prevent water-breathing mobs to classify water or e.g. sand below them as dangerous + if not self.breathes_in_water and minetest_get_item_group(nn, "water") ~= 0 then + return true + end + end + end + return false +end + + +-- Returns true is node can deal damage to self +local is_node_dangerous = function(self, nodename) + local nn = nodename + if self.lava_damage > 0 then + if minetest_get_item_group(nn, "lava") ~= 0 then + return true + end + end + if self.fire_damage > 0 then + if minetest_get_item_group(nn, "fire") ~= 0 then + return true + end + end + if minetest_registered_nodes[nn] and minetest_registered_nodes[nn].damage_per_second and minetest_registered_nodes[nn].damage_per_second > 0 then + return true + end + return false +end + + +local add_texture_mod = function(self, mod) + local full_mod = "" + local already_added = false + for i=1, #self.texture_mods do + if mod == self.texture_mods[i] then + already_added = true + end + full_mod = full_mod .. self.texture_mods[i] + end + if not already_added then + full_mod = full_mod .. mod + table.insert(self.texture_mods, mod) + end + self.object:set_texture_mod(full_mod) +end + + +local remove_texture_mod = function(self, mod) + local full_mod = "" + local remove = {} + for i=1, #self.texture_mods do + if self.texture_mods[i] ~= mod then + full_mod = full_mod .. self.texture_mods[i] + else + table.insert(remove, i) + end + end + for i=#remove, 1 do + table.remove(self.texture_mods, remove[i]) + end + self.object:set_texture_mod(full_mod) +end + + +-- Return true if object is in view_range +local function object_in_range(self, object) + if not object then + return false + end + local factor + -- Apply view range reduction for special player armor + if not object then + return false + end + local factor + -- Apply view range reduction for special player armor + if object:is_player() and mod_armor then + local factors = mcl_armor.player_view_range_factors[object] + factor = factors and factors[self.name] + end + -- Distance check + local dist + if factor and factor == 0 then + return false + elseif factor then + dist = self.view_range * factor + else + dist = self.view_range + end + + local p1, p2 = self.object:get_pos(), object:get_pos() + return p1 and p2 and (vector.distance(p1, p2) <= dist) +end + +-- attack player/mob +local do_attack = function(self, player) + + if self.state == "attack" or self.state == "die" then + return + end + + self.attack = player + self.state = "attack" + + -- TODO: Implement war_cry sound without being annoying + --if math.random(0, 100) < 90 then + --mob_sound(self, "war_cry", true) + --end +end + + +-- play sound +local mob_sound = function(self, soundname, is_opinion, fixed_pitch) + local soundinfo + if self.sounds_child and self.child then + soundinfo = self.sounds_child + elseif self.sounds then + soundinfo = self.sounds + end + if not soundinfo then + return + end + local sound = soundinfo[soundname] + if sound then + if is_opinion and self.opinion_sound_cooloff > 0 then + return + end + local pitch + if not fixed_pitch then + local base_pitch = soundinfo.base_pitch + if not base_pitch then + base_pitch = 1 + end + if self.child and (not self.sounds_child) then + -- Children have higher pitch + pitch = base_pitch * 1.5 + else + pitch = base_pitch + end + -- randomize the pitch a bit + pitch = pitch + math.random(-10, 10) * 0.005 + end + minetest_sound_play(sound, { + object = self.object, + gain = 1.0, + max_hear_distance = self.sounds.distance, + pitch = pitch, + }, true) + self.opinion_sound_cooloff = 1 + end +end + + +local function update_roll(self) + local is_Fleckenstein = self.nametag == "Fleckenstein" + local was_Fleckenstein = false + + local rot = self.object:get_rotation() + rot.z = is_Fleckenstein and math_pi or 0 + self.object:set_rotation(rot) + + local cbox = table.copy(self.collisionbox) + local acbox = self.object:get_properties().collisionbox + + if math_abs(cbox[2] - acbox[2]) > 0.1 then + was_Fleckenstein = true + end + + if is_Fleckenstein ~= was_Fleckenstein then + local pos = self.object:get_pos() + pos.y = pos.y + (acbox[2] + acbox[5]) + self.object:set_pos(pos) + end + + if is_Fleckenstein then + cbox[2], cbox[5] = -cbox[5], -cbox[2] + end + + self.object:set_properties({collisionbox = cbox}) +end + + + +-- is mob facing a cliff or danger +local is_at_cliff_or_danger = function(self) + + if self.fear_height == 0 then -- 0 for no falling protection! + return false + end + + if not self.object:get_luaentity() then + return false + end + local yaw = self.object:get_yaw() + local dir_x = -math_sin(yaw) * (self.collisionbox[4] + 0.5) + local dir_z = math_cos(yaw) * (self.collisionbox[4] + 0.5) + local pos = self.object:get_pos() + local ypos = pos.y + self.collisionbox[2] -- just above floor + + local free_fall, blocker = minetest_line_of_sight( + {x = pos.x + dir_x, y = ypos, z = pos.z + dir_z}, + {x = pos.x + dir_x, y = ypos - self.fear_height, z = pos.z + dir_z}) + if free_fall then + return true + else + local bnode = minetest_get_node(blocker) + local danger = is_node_dangerous(self, bnode.name) + if danger then + return true + else + local def = minetest_registered_nodes[bnode.name] + if def and def.walkable then + return false + end + end + end + + return false +end + + +-- copy the 'mob facing cliff_or_danger check' from above, and rework to avoid water +local is_at_water_danger = function(self) + + + if not self.object:get_luaentity() then + return false + end + local yaw = self.object:get_yaw() + local dir_x = -math_sin(yaw) * (self.collisionbox[4] + 0.5) + local dir_z = math_cos(yaw) * (self.collisionbox[4] + 0.5) + local pos = self.object:get_pos() + local ypos = pos.y + self.collisionbox[2] -- just above floor + + local free_fall, blocker = minetest_line_of_sight( + {x = pos.x + dir_x, y = ypos, z = pos.z + dir_z}, + {x = pos.x + dir_x, y = ypos - 3, z = pos.z + dir_z}) + if free_fall then + return true + else + local bnode = minetest_get_node(blocker) + local waterdanger = is_node_waterhazard(self, bnode.name) + if + waterdanger and (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) then + return false + elseif waterdanger and (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) == false then + return true + else + local def = minetest_registered_nodes[bnode.name] + if def and def.walkable then + return false + end + end + end + + return false +end + +local function get_light(pos, tod) + local ok, light = pcall(minetest.get_natural_light or minetest.get_node_light, pos, tod) + if ok then + return light + else + return 0 + end +end + +-- environmental damage (water, lava, fire, light etc.) +local do_env_damage = function(self) + + -- feed/tame text timer (so mob 'full' messages dont spam chat) + if self.htimer > 0 then + self.htimer = self.htimer - 1 + end + + -- reset nametag after showing health stats + if self.htimer < 1 and self.nametag2 then + + self.nametag = self.nametag2 + self.nametag2 = nil + + update_tag(self) + end + + local pos = self.object:get_pos() + + self.time_of_day = minetest.get_timeofday() + + -- remove mob if beyond map limits + if not within_limits(pos, 0) then + mcl_burning.extinguish(self.object) + self.object:remove() + return true + end + + + -- Deal light damage to mob, returns true if mob died + local deal_light_damage = function(self, pos, damage) + if not (mod_weather and (mcl_weather.rain.raining or mcl_weather.state == "snow") and mcl_weather.is_outdoor(pos)) then + self.health = self.health - damage + + effect(pos, 5, "mcl_particles_smoke.png") + + if check_for_death(self, "light", {type = "light"}) then + return true + end + end + end + + -- Use get_node_light for Minetest version 5.3 where get_natural_light + -- does not exist yet. + local sunlight = get_light(pos, self.time_of_day) + + -- bright light harms mob + if self.light_damage ~= 0 and (sunlight or 0) > 12 then + if deal_light_damage(self, pos, self.light_damage) then + return true + end + end + local _, dim = nil, "overworld" + if mod_worlds then + _, dim = mcl_worlds.y_to_layer(pos.y) + end + if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then + if self.ignited_by_sunlight then + mcl_burning.set_on_fire(self.object, 10) + else + deal_light_damage(self, pos, self.sunlight_damage) + return true + end + end + + local y_level = self.collisionbox[2] + + if self.child then + y_level = self.collisionbox[2] * 0.5 + end + + -- what is mob standing in? + pos.y = pos.y + y_level + 0.25 -- foot level + local pos2 = {x=pos.x, y=pos.y-1, z=pos.z} + self.standing_in = node_ok(pos, "air").name + self.standing_on = node_ok(pos2, "air").name + + -- don't fall when on ignore, just stand still + if self.standing_in == "ignore" then + self.object:set_velocity({x = 0, y = 0, z = 0}) + end + + local nodef = minetest_registered_nodes[self.standing_in] + + -- rain + if self.rain_damage > 0 and mod_weather then + if mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) then + + self.health = self.health - self.rain_damage + + if check_for_death(self, "rain", {type = "environment", + pos = pos, node = self.standing_in}) then + return true + end + end + end + + pos.y = pos.y + 1 -- for particle effect position + + -- water damage + if self.water_damage > 0 + and nodef.groups.water then + + if self.water_damage ~= 0 then + + self.health = self.health - self.water_damage + + effect(pos, 5, "mcl_particles_smoke.png", nil, nil, 1, nil) + + if check_for_death(self, "water", {type = "environment", + pos = pos, node = self.standing_in}) then + return true + end + end + + -- lava damage + elseif self.lava_damage > 0 + and (nodef.groups.lava) then + + if self.lava_damage ~= 0 then + + self.health = self.health - self.lava_damage + + mcl_burning.set_on_fire(self.object, 15) + + effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil) + + if check_for_death(self, "lava", {type = "environment", + pos = pos, node = self.standing_in}) then + return true + end + end + + -- fire damage + elseif self.fire_damage > 0 + and (nodef.groups.fire) then + + if self.fire_damage ~= 0 then + + self.health = self.health - self.fire_damage + + mcl_burning.set_on_fire(self.object, 8) + + effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil) + + if check_for_death(self, "fire", {type = "environment", + pos = pos, node = self.standing_in}) then + return true + end + end + + -- damage_per_second node check + elseif nodef.damage_per_second ~= 0 and not nodef.groups.lava and not nodef.groups.fire then + + self.health = self.health - nodef.damage_per_second + + effect(pos, 5, "mcl_particles_smoke.png") + + if check_for_death(self, "dps", {type = "environment", + pos = pos, node = self.standing_in}) then + return true + end + end + + -- Drowning damage + if self.breath_max ~= -1 then + local drowning = false + if self.breathes_in_water then + if minetest_get_item_group(self.standing_in, "water") == 0 then + drowning = true + end + elseif nodef.drowning > 0 then + drowning = true + end + if drowning then + + self.breath = math.max(0, self.breath - 1) + + effect(pos, 2, "bubble.png", nil, nil, 1, nil) + if self.breath <= 0 then + local dmg + if nodef.drowning > 0 then + dmg = nodef.drowning + else + dmg = 4 + end + damage_effect(self, dmg) + self.health = self.health - dmg + end + if check_for_death(self, "drowning", {type = "environment", + pos = pos, node = self.standing_in}) then + return true + end + else + self.breath = math_min(self.breath_max, self.breath + 1) + end + end + + --- suffocation inside solid node + -- FIXME: Redundant with mcl_playerplus + if (self.suffocation == true) + and (nodef.walkable == nil or nodef.walkable == true) + and (nodef.collision_box == nil or nodef.collision_box.type == "regular") + and (nodef.node_box == nil or nodef.node_box.type == "regular") + and (nodef.groups.disable_suffocation ~= 1) + and (nodef.groups.opaque == 1) then + + -- Short grace period before starting to take suffocation damage. + -- This is different from players, who take damage instantly. + -- This has been done because mobs might briefly be inside solid nodes + -- when e.g. climbing up stairs. + -- This is a bit hacky because it assumes that do_env_damage + -- is called roughly every second only. + self.suffocation_timer = self.suffocation_timer + 1 + if self.suffocation_timer >= 3 then + -- 2 damage per second + -- TODO: Deal this damage once every 1/2 second + self.health = self.health - 2 + + if check_for_death(self, "suffocation", {type = "environment", + pos = pos, node = self.standing_in}) then + return true + end + end + else + self.suffocation_timer = 0 + end + + return check_for_death(self, "", {type = "unknown"}) +end + + +-- jump if facing a solid node (not fences or gates) +local do_jump = function(self) + + if not self.jump + or self.jump_height == 0 + or self.fly + or (self.child and self.type ~= "monster") + or self.order == "stand" then + return false + end + + self.facing_fence = false + + -- something stopping us while moving? + if self.state ~= "stand" + and get_velocity(self) > 0.5 + and self.object:get_velocity().y ~= 0 then + return false + end + + local pos = self.object:get_pos() + local yaw = self.object:get_yaw() + + -- what is mob standing on? + pos.y = pos.y + self.collisionbox[2] - 0.2 + + local nod = node_ok(pos) + + if minetest_registered_nodes[nod.name].walkable == false then + return false + end + + -- where is front + local dir_x = -math_sin(yaw) * (self.collisionbox[4] + 0.5) + local dir_z = math_cos(yaw) * (self.collisionbox[4] + 0.5) + + -- what is in front of mob? + nod = node_ok({ + x = pos.x + dir_x, + y = pos.y + 0.5, + z = pos.z + dir_z + }) + + -- this is used to detect if there's a block on top of the block in front of the mob. + -- If there is, there is no point in jumping as we won't manage. + local nodTop = node_ok({ + x = pos.x + dir_x, + y = pos.y + 1.5, + z = pos.z + dir_z + }, "air") + + -- we don't attempt to jump if there's a stack of blocks blocking + if minetest_registered_nodes[nodTop.name].walkable == true then + return false + end + + -- thin blocks that do not need to be jumped + if nod.name == node_snow then + return false + end + + if self.walk_chance == 0 + or minetest_registered_items[nod.name].walkable then + + if minetest_get_item_group(nod.name, "fence") == 0 + and minetest_get_item_group(nod.name, "fence_gate") == 0 + and minetest_get_item_group(nod.name, "wall") == 0 then + + local v = self.object:get_velocity() + + v.y = self.jump_height + + set_animation(self, "jump") -- only when defined + + self.object:set_velocity(v) + + -- when in air move forward + minetest_after(0.3, function(self, v) + if (not self.object) or (not self.object:get_luaentity()) or (self.state == "die") then + return + end + self.object:set_acceleration({ + x = v.x * 2, + y = -10, + z = v.z * 2, + }) + end, self, v) + + if self.jump_sound_cooloff <= 0 then + mob_sound(self, "jump") + self.jump_sound_cooloff = 0.5 + end + else + self.facing_fence = true + end + + -- if we jumped against a block/wall 4 times then turn + if self.object:get_velocity().x ~= 0 + and self.object:get_velocity().z ~= 0 then + + self.jump_count = (self.jump_count or 0) + 1 + + if self.jump_count == 4 then + + local yaw = self.object:get_yaw() or 0 + + yaw = set_yaw(self, yaw + 1.35, 8) + + self.jump_count = 0 + end + end + + return true + end + + return false +end + + +-- blast damage to entities nearby +local entity_physics = function(pos, radius) + + radius = radius * 2 + + local objs = minetest_get_objects_inside_radius(pos, radius) + local obj_pos, dist + + for n = 1, #objs do + + obj_pos = objs[n]:get_pos() + + dist = vector.distance(pos, obj_pos) + if dist < 1 then dist = 1 end + + local damage = math_floor((4 / dist) * radius) + local ent = objs[n]:get_luaentity() + + -- punches work on entities AND players + objs[n]:punch(objs[n], 1.0, { + full_punch_interval = 1.0, + damage_groups = {fleshy = damage}, + }, pos) + end +end + + +-- should mob follow what I'm holding ? +local follow_holding = function(self, clicker) + + if mobs.invis[clicker:get_player_name()] then + return false + end + + local item = clicker:get_wielded_item() + local t = type(self.follow) + + -- single item + if t == "string" + and item:get_name() == self.follow then + return true + + -- multiple items + elseif t == "table" then + + for no = 1, #self.follow do + + if self.follow[no] == item:get_name() then + return true + end + end + end + + return false +end + + +-- find two animals of same type and breed if nearby and horny +local breed = function(self) + + -- child takes a long time before growing into adult + if self.child == true then + + -- When a child, hornytimer is used to count age until adulthood + self.hornytimer = self.hornytimer + 1 + + if self.hornytimer >= CHILD_GROW_TIME then + + self.child = false + self.hornytimer = 0 + + self.object:set_properties({ + textures = self.base_texture, + mesh = self.base_mesh, + visual_size = self.base_size, + collisionbox = self.base_colbox, + selectionbox = self.base_selbox, + }) + + -- custom function when child grows up + if self.on_grown then + self.on_grown(self) + else + -- jump when fully grown so as not to fall into ground + self.object:set_velocity({ + x = 0, + y = self.jump_height, + z = 0 + }) + end + end + + return + end + + -- horny animal can mate for BREED_TIME seconds, + -- afterwards horny animal cannot mate again for BREED_TIME_AGAIN seconds + if self.horny == true + and self.hornytimer < BREED_TIME + BREED_TIME_AGAIN then + + self.hornytimer = self.hornytimer + 1 + + if self.hornytimer >= BREED_TIME + BREED_TIME_AGAIN then + self.hornytimer = 0 + self.horny = false + end + end + + -- find another same animal who is also horny and mate if nearby + if self.horny == true + and self.hornytimer <= BREED_TIME then + + local pos = self.object:get_pos() + + effect({x = pos.x, y = pos.y + 1, z = pos.z}, 8, "heart.png", 3, 4, 1, 0.1) + + local objs = minetest_get_objects_inside_radius(pos, 3) + local num = 0 + local ent = nil + + for n = 1, #objs do + + ent = objs[n]:get_luaentity() + + -- check for same animal with different colour + local canmate = false + + if ent then + + if ent.name == self.name then + canmate = true + else + local entname = string.split(ent.name,":") + local selfname = string.split(self.name,":") + + if entname[1] == selfname[1] then + entname = string.split(entname[2],"_") + selfname = string.split(selfname[2],"_") + + if entname[1] == selfname[1] then + canmate = true + end + end + end + end + + if ent + and canmate == true + and ent.horny == true + and ent.hornytimer <= BREED_TIME then + num = num + 1 + end + + -- found your mate? then have a baby + if num > 1 then + + self.hornytimer = BREED_TIME + 1 + ent.hornytimer = BREED_TIME + 1 + + -- spawn baby + minetest_after(5, function(parent1, parent2, pos) + if not parent1.object:get_luaentity() then + return + end + if not parent2.object:get_luaentity() then + return + end + + -- Give XP + if mod_experience then + mcl_experience.throw_experience(pos, math.random(1, 7)) + end + + -- custom breed function + if parent1.on_breed then + -- when false, skip going any further + if parent1.on_breed(parent1, parent2) == false then + return + end + end + + local child = mobs:spawn_child(pos, parent1.name) + + local ent_c = child:get_luaentity() + + + -- Use texture of one of the parents + local p = math.random(1, 2) + if p == 1 then + ent_c.base_texture = parent1.base_texture + else + ent_c.base_texture = parent2.base_texture + end + child:set_properties({ + textures = ent_c.base_texture + }) + + -- tamed and owned by parents' owner + ent_c.tamed = true + ent_c.owner = parent1.owner + end, self, ent, pos) + + num = 0 + + break + end + end + end +end + +-- find and replace what mob is looking for (grass, wheat etc.) +local replace = function(self, pos) + + if not self.replace_rate + or not self.replace_what + or self.child == true + or self.object:get_velocity().y ~= 0 + or math.random(1, self.replace_rate) > 1 then + return + end + + local what, with, y_offset + + if type(self.replace_what[1]) == "table" then + + local num = math.random(#self.replace_what) + + what = self.replace_what[num][1] or "" + with = self.replace_what[num][2] or "" + y_offset = self.replace_what[num][3] or 0 + else + what = self.replace_what + with = self.replace_with or "" + y_offset = self.replace_offset or 0 + end + + pos.y = pos.y + y_offset + + local node = minetest_get_node(pos) + if node.name == what then + + local oldnode = {name = what, param2 = node.param2} + local newnode = {name = with, param2 = node.param2} + local on_replace_return + + if self.on_replace then + on_replace_return = self.on_replace(self, pos, oldnode, newnode) + end + + if on_replace_return ~= false then + + if mobs_griefing then + minetest_set_node(pos, newnode) + end + + end + end +end + + +-- check if daytime and also if mob is docile during daylight hours +local day_docile = function(self) + + if self.docile_by_day == false then + + return false + + elseif self.docile_by_day == true + and self.time_of_day > 0.2 + and self.time_of_day < 0.8 then + + return true + end +end + + + +local mob_detach_child = function(self, child) + + if self.driver == child then + self.driver = nil + end + +end + +function do_states(self) if self.state == "stand" then - if random(1, 4) == 1 then + if math.random(1, 4) == 1 then local lp = nil local s = self.object:get_pos() - local objs = minetest.get_objects_inside_radius(s, 3) + local objs = minetest_get_objects_inside_radius(s, 3) for n = 1, #objs do @@ -2316,11 +2188,11 @@ local do_states = function(self, dtime) z = lp.z - s.z } - yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate + yaw = (atan(vec.z / vec.x) + math_pi / 2) - self.rotate - if lp.x > s.x then yaw = yaw + pi end + if lp.x > s.x then yaw = yaw + math_pi end else - yaw = yaw + random(-0.5, 0.5) + yaw = yaw + math.random(-0.5, 0.5) end yaw = set_yaw(self, yaw, 8) @@ -2335,7 +2207,7 @@ local do_states = function(self, dtime) if self.walk_chance ~= 0 and self.facing_fence ~= true - and random(1, 100) <= self.walk_chance + and math.random(1, 100) <= self.walk_chance and is_at_cliff_or_danger(self) == false then set_velocity(self, self.walk_velocity) @@ -2354,19 +2226,19 @@ local do_states = function(self, dtime) and self.lava_damage > 0) or self.breath_max ~= -1 then - lp = minetest.find_node_near(s, 1, {"group:water", "group:lava"}) + lp = minetest_find_node_near(s, 1, {"group:water", "group:lava"}) elseif self.water_damage > 0 then - lp = minetest.find_node_near(s, 1, {"group:water"}) + lp = minetest_find_node_near(s, 1, {"group:water"}) elseif self.lava_damage > 0 then - lp = minetest.find_node_near(s, 1, {"group:lava"}) + lp = minetest_find_node_near(s, 1, {"group:lava"}) elseif self.fire_damage > 0 then - lp = minetest.find_node_near(s, 1, {"group:fire"}) + lp = minetest_find_node_near(s, 1, {"group:fire"}) end @@ -2380,12 +2252,12 @@ local do_states = function(self, dtime) -- If mob in or on dangerous block, look for land if is_in_danger then -- Better way to find shore - copied from upstream - lp = minetest.find_nodes_in_area_under_air( + lp = minetest_find_nodes_in_area_under_air( {x = s.x - 5, y = s.y - 0.5, z = s.z - 5}, {x = s.x + 5, y = s.y + 1, z = s.z + 5}, {"group:solid"}) - lp = #lp > 0 and lp[random(#lp)] + lp = #lp > 0 and lp[math.random(#lp)] -- did we find land? if lp then @@ -2395,10 +2267,10 @@ local do_states = function(self, dtime) z = lp.z - s.z } - yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate + yaw = (atan(vec.z / vec.x) + math_pi / 2) - self.rotate - if lp.x > s.x then yaw = yaw + pi end + if lp.x > s.x then yaw = yaw + math_pi end -- look towards land and move in that direction yaw = set_yaw(self, yaw, 6) @@ -2411,8 +2283,8 @@ local do_states = function(self, dtime) else -- Randomly turn - if random(1, 100) <= 30 then - yaw = yaw + random(-0.5, 0.5) + if math.random(1, 100) <= 30 then + yaw = yaw + math.random(-0.5, 0.5) yaw = set_yaw(self, yaw, 8) end end @@ -2420,9 +2292,9 @@ local do_states = function(self, dtime) yaw = set_yaw(self, yaw, 8) -- otherwise randomly turn - elseif random(1, 100) <= 30 then + elseif math.random(1, 100) <= 30 then - yaw = yaw + random(-0.5, 0.5) + yaw = yaw + math.random(-0.5, 0.5) yaw = set_yaw(self, yaw, 8) end @@ -2433,7 +2305,7 @@ local do_states = function(self, dtime) end if self.facing_fence == true or cliff_or_danger - or random(1, 100) <= 30 then + or math.random(1, 100) <= 30 then set_velocity(self, 0) self.state = "stand" @@ -2508,9 +2380,9 @@ local do_states = function(self, dtime) z = p.z - s.z } - yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate + yaw = (atan(vec.z / vec.x) + math_pi / 2) - self.rotate - if p.x > s.x then yaw = yaw + pi end + if p.x > s.x then yaw = yaw + math_pi end yaw = set_yaw(self, yaw, 0, dtime) @@ -2576,10 +2448,10 @@ local do_states = function(self, dtime) local pos = self.object:get_pos() if mod_explosions then - if mobs_griefing and not minetest.is_protected(pos, "") then + if mobs_griefing and not minetest_is_protected(pos, "") then mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { drop_chance = 1.0 }, self.object) else - minetest.sound_play(self.sounds.explode, { + minetest_sound_play(self.sounds.explode, { pos = pos, gain = 1.0, max_hear_distance = self.sounds.distance or 32 @@ -2604,9 +2476,9 @@ local do_states = function(self, dtime) and dist > self.reach then local p1 = s - local me_y = floor(p1.y) + local me_y = math_floor(p1.y) local p2 = p - local p_y = floor(p2.y + 1) + local p_y = math_floor(p2.y + 1) local v = self.object:get_velocity() if flight_check(self, s) then @@ -2667,7 +2539,7 @@ local do_states = function(self, dtime) return end - if abs(p1.x-s.x) + abs(p1.z - s.z) < 0.6 then + if math_abs(p1.x-s.x) + math_abs(p1.z - s.z) < 0.6 then -- reached waypoint, remove it from queue table.remove(self.path.way, 1) end @@ -2681,9 +2553,9 @@ local do_states = function(self, dtime) z = p.z - s.z } - yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate + yaw = (atan(vec.z / vec.x) + math_pi / 2) - self.rotate - if p.x > s.x then yaw = yaw + pi end + if p.x > s.x then yaw = yaw + math_pi end yaw = set_yaw(self, yaw, 0, dtime) @@ -2733,7 +2605,7 @@ local do_states = function(self, dtime) self.timer = 0 if self.double_melee_attack - and random(1, 2) == 1 then + and math.random(1, 2) == 1 then set_animation(self, "punch2") else set_animation(self, "punch") @@ -2786,9 +2658,9 @@ local do_states = function(self, dtime) z = p.z - s.z } - yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate + yaw = (atan(vec.z / vec.x) + math_pi / 2) - self.rotate - if p.x > s.x then yaw = yaw + pi end + if p.x > s.x then yaw = yaw + math_pi end yaw = set_yaw(self, yaw, 0, dtime) @@ -2799,8 +2671,8 @@ local do_states = function(self, dtime) if self.shoot_interval and self.timer > self.shoot_interval - and not minetest.raycast(p, self.attack:get_pos(), false, false):next() - and random(1, 100) <= 60 then + and not minetest_raycast(p, self.attack:get_pos(), false, false):next() + and math.random(1, 100) <= 60 then self.timer = 0 set_animation(self, "shoot") @@ -2809,16 +2681,16 @@ local do_states = function(self, dtime) mob_sound(self, "shoot_attack") -- Shoot arrow - if minetest.registered_entities[self.arrow] then + if minetest_registered_entities[self.arrow] then local arrow, ent local v = 1 if not self.shoot_arrow then self.firing = true - minetest.after(1, function() + minetest_after(1, function() self.firing = false end) - arrow = minetest.add_entity(p, self.arrow) + arrow = minetest_add_entity(p, self.arrow) ent = arrow:get_luaentity() if ent.velocity then v = ent.velocity @@ -2846,807 +2718,251 @@ local do_states = function(self, dtime) end --- falling and fall damage --- returns true if mob died -local falling = function(self, pos) - if self.fly and self.state ~= "die" then + +-- above function exported for mount.lua +function mobs:set_animation(self, anim) + set_animation(self, anim) +end + + +-- set defined animation +local set_animation = function(self, anim, fixed_frame) + if not self.animation or not anim then + return + end + if self.state == "die" and anim ~= "die" and anim ~= "stand" then return end - if mcl_portals ~= nil then - if mcl_portals.nether_portal_cooloff(self.object) then - return false -- mob has teleported through Nether portal - it's 99% not falling - end + self.animation.current = self.animation.current or "" + + if (anim == self.animation.current + or not self.animation[anim .. "_start"] + or not self.animation[anim .. "_end"]) and self.state ~= "die" then + return end - -- floating in water (or falling) - local v = self.object:get_velocity() + self.animation.current = anim - if v.y > 0 then - - -- apply gravity when moving up - self.object:set_acceleration({ - x = 0, - y = -10, - z = 0 - }) - - elseif v.y <= 0 and v.y > self.fall_speed then - - -- fall downwards at set speed - self.object:set_acceleration({ - x = 0, - y = self.fall_speed, - z = 0 - }) + local a_start = self.animation[anim .. "_start"] + local a_end + if fixed_frame then + a_end = a_start else - -- stop accelerating once max fall speed hit - self.object:set_acceleration({x = 0, y = 0, z = 0}) + a_end = self.animation[anim .. "_end"] end - if minetest.registered_nodes[node_ok(pos).name].groups.lava then - - if self.floats_on_lava == 1 then - - self.object:set_acceleration({ - x = 0, - y = -self.fall_speed / (max(1, v.y) ^ 2), - z = 0 - }) - end - end - - -- in water then float up - if minetest.registered_nodes[node_ok(pos).name].groups.water then - - if self.floats == 1 then - - self.object:set_acceleration({ - x = 0, - y = -self.fall_speed / (max(1, v.y) ^ 2), - z = 0 - }) - end - else - - -- fall damage onto solid ground - if self.fall_damage == 1 - and self.object:get_velocity().y == 0 then - - local d = (self.old_y or 0) - self.object:get_pos().y - - if d > 5 then - - local add = minetest.get_item_group(self.standing_on, "fall_damage_add_percent") - local damage = d - 5 - if add ~= 0 then - damage = damage + damage * (add/100) - end - damage = floor(damage) - if damage > 0 then - self.health = self.health - damage - - effect(pos, 5, "mcl_particles_smoke.png", 1, 2, 2, nil) - - if check_for_death(self, "fall", {type = "fall"}) then - return true - end - end - end - - self.old_y = self.object:get_pos().y - end - end -end - -local teleport = function(self, target) - if self.do_teleport then - if self.do_teleport(self, target) == false then - return - end - end + self.object:set_animation({ + x = a_start, + y = a_end}, + self.animation[anim .. "_speed"] or self.animation.speed_normal or 15, + 0, self.animation[anim .. "_loop"] ~= false) end --- deal damage and effects when mob punched -local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) +-- Code to execute before custom on_rightclick handling +local function on_rightclick_prefix(self, clicker) + local item = clicker:get_wielded_item() - -- custom punch function - if self.do_punch then + -- Name mob with nametag + if not self.ignores_nametag and item:get_name() == "mcl_mobs:nametag" then - -- when false skip going any further - if self.do_punch(self, hitter, tflp, tool_capabilities, dir) == false then - return - end - end - - -- error checking when mod profiling is enabled - if not tool_capabilities then - minetest.log("warning", "[mobs] Mod profiling enabled, damage not enabled") - return - end - - local is_player = hitter:is_player() - - if is_player then - -- is mob protected? - if self.protected and minetest.is_protected(self.object:get_pos(), hitter:get_player_name()) then - return - end - - -- set/update 'drop xp' timestamp if hitted by player - self.xp_timestamp = minetest.get_us_time() - end - - - -- punch interval - local weapon = hitter:get_wielded_item() - local punch_interval = 1.4 - - -- exhaust attacker - if mod_hunger and is_player then - mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK) - end - - -- calculate mob damage - local damage = 0 - local armor = self.object:get_armor_groups() or {} - local tmp - - -- quick error check incase it ends up 0 (serialize.h check test) - if tflp == 0 then - tflp = 0.2 - end - - if use_cmi then - damage = cmi.calculate_damage(self.object, hitter, tflp, tool_capabilities, dir) - else - - for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do - - tmp = tflp / (tool_capabilities.full_punch_interval or 1.4) - - if tmp < 0 then - tmp = 0.0 - elseif tmp > 1 then - tmp = 1.0 + local tag = item:get_meta():get_string("name") + if tag ~= "" then + if string.len(tag) > MAX_MOB_NAME_LENGTH then + tag = string.sub(tag, 1, MAX_MOB_NAME_LENGTH) end + self.nametag = tag - damage = damage + (tool_capabilities.damage_groups[group] or 0) - * tmp * ((armor[group] or 0) / 100.0) - end - end + update_tag(self) - if weapon then - local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect") - if fire_aspect_level > 0 then - mcl_burning.set_on_fire(self.object, fire_aspect_level * 4) - end - end - - -- check for tool immunity or special damage - for n = 1, #self.immune_to do - - if self.immune_to[n][1] == weapon:get_name() then - - damage = self.immune_to[n][2] or 0 - break - end - end - - -- healing - if damage <= -1 then - self.health = self.health - floor(damage) - return - end - - if use_cmi then - - local cancel = cmi.notify_punch(self.object, hitter, tflp, tool_capabilities, dir, damage) - - if cancel then return end - end - - if tool_capabilities then - punch_interval = tool_capabilities.full_punch_interval or 1.4 - end - - -- add weapon wear manually - -- Required because we have custom health handling ("health" property) - if minetest.is_creative_enabled("") ~= true - and tool_capabilities then - if tool_capabilities.punch_attack_uses then - -- Without this delay, the wear does not work. Quite hacky ... - minetest.after(0, function(name) - local player = minetest.get_player_by_name(name) - if not player then return end - local weapon = hitter:get_wielded_item(player) - local def = weapon:get_definition() - if def.tool_capabilities and def.tool_capabilities.punch_attack_uses then - local wear = floor(65535/tool_capabilities.punch_attack_uses) - weapon:add_wear(wear) - hitter:set_wielded_item(weapon) - end - end, hitter:get_player_name()) - end - end - - local die = false - - -- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately. - if damage >= 0.1 then - - -- weapon sounds - if weapon:get_definition().sounds ~= nil then - - local s = random(0, #weapon:get_definition().sounds) - - minetest.sound_play(weapon:get_definition().sounds[s], { - object = self.object, --hitter, - max_hear_distance = 8 - }, true) - else - minetest.sound_play("default_punch", { - object = self.object, - max_hear_distance = 5 - }, true) - end - - damage_effect(self, damage) - - -- do damage - self.health = self.health - damage - - -- skip future functions if dead, except alerting others - if check_for_death(self, "hit", {type = "punch", puncher = hitter}) then - die = true - end - - -- knock back effect (only on full punch) - if not die - and self.knock_back - and tflp >= punch_interval then - - local v = self.object:get_velocity() - local r = 1.4 - min(punch_interval, 1.4) - local kb = r * 2.0 - local up = 2 - - -- if already in air then dont go up anymore when hit - if v.y ~= 0 - or self.fly then - up = 0 + if not mobs.is_creative(clicker:get_player_name()) then + item:take_item() + clicker:set_wielded_item(item) end - - -- direction error check - dir = dir or {x = 0, y = 0, z = 0} - - -- check if tool already has specific knockback value - if tool_capabilities.damage_groups["knockback"] then - kb = tool_capabilities.damage_groups["knockback"] - else - kb = kb * 1.5 - end - - - local luaentity - if hitter then - luaentity = hitter:get_luaentity() - end - if hitter and is_player then - local wielditem = hitter:get_wielded_item() - kb = kb + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback") - elseif luaentity and luaentity._knockback then - kb = kb + luaentity._knockback - end - - self.object:set_velocity({ - x = dir.x * kb, - y = dir.y * kb + up * 2, - z = dir.z * kb - }) - - self.pause_timer = 0.25 - end - end -- END if damage - - -- if skittish then run away - if not die and self.runaway == true and self.state ~= "flop" then - - local lp = hitter:get_pos() - local s = self.object:get_pos() - local vec = { - x = lp.x - s.x, - y = lp.y - s.y, - z = lp.z - s.z - } - - local yaw = (atan(vec.z / vec.x) + 3 * pi / 2) - self.rotate - - if lp.x > s.x then - yaw = yaw + pi + return true end - yaw = set_yaw(self, yaw, 6) - self.state = "runaway" - self.runaway_timer = 0 - self.following = nil - end - - local name = hitter:get_player_name() or "" - - -- attack puncher and call other mobs for help - if self.passive == false - and self.state ~= "flop" - and (self.child == false or self.type == "monster") - and hitter:get_player_name() ~= self.owner - and not mobs.invis[ name ] then - - if not die then - -- attack whoever punched mob - self.state = "" - do_attack(self, hitter) - end - - -- alert others to the attack - local objs = minetest.get_objects_inside_radius(hitter:get_pos(), self.view_range) - local obj = nil - - for n = 1, #objs do - - obj = objs[n]:get_luaentity() - - if obj then - - -- only alert members of same mob or friends - if obj.group_attack - and obj.state ~= "attack" - and obj.owner ~= name then - if obj.name == self.name then - do_attack(obj, hitter) - elseif type(obj.group_attack) == "table" then - for i=1, #obj.group_attack do - if obj.name == obj.group_attack[i] then - do_attack(obj, hitter) - break - end - end - end - end - - -- have owned mobs attack player threat - if obj.owner == name and obj.owner_loyal then - do_attack(obj, self.object) - end - end - end end + return false end -local mob_detach_child = function(self, child) - - if self.driver == child then - self.driver = nil - end - -end - --- get entity staticdata -local mob_staticdata = function(self) - ---[[ - -- remove mob when out of range unless tamed - if remove_far - and self.can_despawn - and self.remove_ok - and ((not self.nametag) or (self.nametag == "")) - and self.lifetimer <= 20 then - - minetest.log("action", "Mob "..name.." despawns in mob_staticdata at "..minetest.pos_to_string(self.object.get_pos(), 1)) - mcl_burning.extinguish(self.object) - self.object:remove() - - return ""-- nil - end ---]] - self.remove_ok = true - self.attack = nil - self.following = nil - self.state = "stand" - - if use_cmi then - self.serialized_cmi_components = cmi.serialize_components(self._cmi_components) - end - - local tmp = {} - - for _,stat in pairs(self) do - - local t = type(stat) - - if t ~= "function" - and t ~= "nil" - and t ~= "userdata" - and _ ~= "_cmi_components" then - tmp[_] = self[_] +--[[local function create_mob_on_rightclick(on_rightclick) + return function(self, clicker) + local stop = on_rightclick_prefix(self, clicker) + if (not stop) and (on_rightclick) then + on_rightclick(self, clicker) end end +end]] - return minetest.serialize(tmp) -end +-- set and return valid yaw +local function set_yaw(self, yaw, delay, dtime) - --- activate mob and reload settings -local mob_activate = function(self, staticdata, def, dtime) - - -- remove monsters in peaceful mode - if self.type == "monster" - and minetest.settings:get_bool("only_peaceful_mobs", false) then - mcl_burning.extinguish(self.object) - self.object:remove() - - return + if not yaw or yaw ~= yaw then + yaw = 0 end - -- load entity variables - local tmp = minetest.deserialize(staticdata) + delay = delay or 0 - if tmp then - for _,stat in pairs(tmp) do - self[_] = stat - end - end - - -- select random texture, set model and size - if not self.base_texture then - - -- compatiblity with old simple mobs textures - if type(def.textures[1]) == "string" then - def.textures = {def.textures} - end - - self.base_texture = def.textures[random(1, #def.textures)] - self.base_mesh = def.mesh - self.base_size = self.visual_size - self.base_colbox = self.collisionbox - self.base_selbox = self.selectionbox - end - - -- for current mobs that dont have this set - if not self.base_selbox then - self.base_selbox = self.selectionbox or self.base_colbox - end - - -- set texture, model and size - local textures = self.base_texture - local mesh = self.base_mesh - local vis_size = self.base_size - local colbox = self.base_colbox - local selbox = self.base_selbox - - -- specific texture if gotten - if self.gotten == true - and def.gotten_texture then - textures = def.gotten_texture - end - - -- specific mesh if gotten - if self.gotten == true - and def.gotten_mesh then - mesh = def.gotten_mesh - end - - -- set child objects to half size - if self.child == true then - - vis_size = { - x = self.base_size.x * .5, - y = self.base_size.y * .5, - } - - if def.child_texture then - textures = def.child_texture[1] - end - - colbox = { - self.base_colbox[1] * .5, - self.base_colbox[2] * .5, - self.base_colbox[3] * .5, - self.base_colbox[4] * .5, - self.base_colbox[5] * .5, - self.base_colbox[6] * .5 - } - selbox = { - self.base_selbox[1] * .5, - self.base_selbox[2] * .5, - self.base_selbox[3] * .5, - self.base_selbox[4] * .5, - self.base_selbox[5] * .5, - self.base_selbox[6] * .5 - } - end - - if self.health == 0 then - self.health = random (self.hp_min, self.hp_max) - end - if self.breath == nil then - self.breath = self.breath_max - end - - -- pathfinding init - self.path = {} - self.path.way = {} -- path to follow, table of positions - self.path.lastpos = {x = 0, y = 0, z = 0} - self.path.stuck = false - self.path.following = false -- currently following path? - self.path.stuck_timer = 0 -- if stuck for too long search for path - - -- Armor groups - -- immortal=1 because we use custom health - -- handling (using "health" property) - local armor - if type(self.armor) == "table" then - armor = table.copy(self.armor) - armor.immortal = 1 - else - armor = {immortal=1, fleshy = self.armor} - end - self.object:set_armor_groups(armor) - self.old_y = self.object:get_pos().y - self.old_health = self.health - self.sounds.distance = self.sounds.distance or 10 - self.textures = textures - self.mesh = mesh - self.collisionbox = colbox - self.selectionbox = selbox - self.visual_size = vis_size - self.standing_in = "ignore" - self.standing_on = "ignore" - self.jump_sound_cooloff = 0 -- used to prevent jump sound from being played too often in short time - self.opinion_sound_cooloff = 0 -- used to prevent sound spam of particular sound types - - self.texture_mods = {} - self.object:set_texture_mod("") - - self.v_start = false - self.timer = 0 - self.blinktimer = 0 - self.blinkstatus = false - - -- check existing nametag - if not self.nametag then - self.nametag = def.nametag - end - - -- set anything changed above - self.object:set_properties(self) - set_yaw(self, (random(0, 360) - 180) / 180 * pi, 6) - update_tag(self) - set_animation(self, "stand") - - -- run on_spawn function if found - if self.on_spawn and not self.on_spawn_run then - if self.on_spawn(self) then - self.on_spawn_run = true -- if true, set flag to run once only - end - end - - -- run after_activate - if def.after_activate then - def.after_activate(self, staticdata, def, dtime) - end - - if use_cmi then - self._cmi_components = cmi.activate_components(self.serialized_cmi_components) - cmi.notify_activate(self.object, dtime) - end -end - - --- main mob function -local mob_step = function(self, dtime) - - if not self.fire_resistant then - mcl_burning.tick(self.object, dtime) - end - - if use_cmi then - cmi.notify_step(self.object, dtime) - end - - local pos = self.object:get_pos() - local yaw = 0 - - if mobs_debug then - update_tag(self) - end - - if self.state == "die" then - return - end - - if self.jump_sound_cooloff > 0 then - self.jump_sound_cooloff = self.jump_sound_cooloff - dtime - end - if self.opinion_sound_cooloff > 0 then - self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime - end - if falling(self, pos) then - -- Return if mob died after falling - return - end - - -- smooth rotation by ThomasMonroe314 - - if self.delay and self.delay > 0 then - - local yaw = self.object:get_yaw() or 0 - - if self.delay == 1 then - yaw = self.target_yaw - else - local dif = abs(yaw - self.target_yaw) - - if yaw > self.target_yaw then - - if dif > pi then - dif = 2 * pi - dif -- need to add - yaw = yaw + dif / self.delay - else - yaw = yaw - dif / self.delay -- need to subtract - end - - elseif yaw < self.target_yaw then - - if dif > pi then - dif = 2 * pi - dif - yaw = yaw - dif / self.delay -- need to subtract - else - yaw = yaw + dif / self.delay -- need to add - end - end - - if yaw > (pi * 2) then yaw = yaw - (pi * 2) end - if yaw < 0 then yaw = yaw + (pi * 2) end - end - - self.delay = self.delay - 1 - if self.shaking then + if delay == 0 then + if self.shaking and dtime then yaw = yaw + (math.random() * 2 - 1) * 5 * dtime end - self.object:set_yaw(yaw) + self.yaw(yaw) update_roll(self) + return yaw end - -- end rotation + self.target_yaw = yaw + self.delay = delay + + return self.target_yaw +end + + +-- global function to set mob yaw +function mobs:yaw(self, yaw, delay, dtime) + set_yaw(self, yaw, delay, dtime) +end + + +--mob_step = function() + --if self.state == "die" then + -- print("need custom die stop moving thing") + -- return + --end + + --if not self.fire_resistant then + -- mcl_burning.tick(self.object, dtime, self) + --end + + --if use_cmi then + --cmi.notify_step(self.object, dtime) + --end + + --local pos = self.object:get_pos() + --local yaw = 0 + + --if mobs_debug then + --update_tag(self) + --end + + + + --if self.jump_sound_cooloff > 0 then + -- self.jump_sound_cooloff = self.jump_sound_cooloff - dtime + --end + + --if self.opinion_sound_cooloff > 0 then + -- self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime + --end + + --if falling(self, pos) then + -- Return if mob died after falling + -- return + --end + -- run custom function (defined in mob lua file) - if self.do_custom then + --if self.do_custom then -- when false skip going any further - if self.do_custom(self, dtime) == false then - return - end - end + --if self.do_custom(self, dtime) == false then + -- return + --end + --end -- knockback timer - if self.pause_timer > 0 then + --if self.pause_timer > 0 then - self.pause_timer = self.pause_timer - dtime + -- self.pause_timer = self.pause_timer - dtime - return - end + -- return + --end -- attack timer - self.timer = self.timer + dtime + --self.timer = self.timer + dtime + --[[ if self.state ~= "attack" then if self.timer < 1 then + print("returning>>error code 1") return end self.timer = 0 end + ]]-- -- never go over 100 - if self.timer > 100 then - self.timer = 1 - end + --if self.timer > 100 then + -- self.timer = 1 + --end -- mob plays random sound at times - if random(1, 70) == 1 then - mob_sound(self, "random", true) - end + --if math.random(1, 70) == 1 then + -- mob_sound(self, "random", true) + --end -- environmental damage timer (every 1 second) - self.env_damage_timer = self.env_damage_timer + dtime - - if (self.state == "attack" and self.env_damage_timer > 1) - or self.state ~= "attack" then - - self.env_damage_timer = 0 - - -- check for environmental damage (water, fire, lava etc.) - if do_env_damage(self) then - return - end + --self.env_damage_timer = self.env_damage_timer + dtime + --if (self.state == "attack" and self.env_damage_timer > 1) + --or self.state ~= "attack" then + -- + -- self.env_damage_timer = 0 + -- + -- -- check for environmental damage (water, fire, lava etc.) + -- if do_env_damage(self) then + -- return + -- end + -- -- node replace check (cow eats grass etc.) - replace(self, pos) - end + -- replace(self, pos) + --end - monster_attack(self) + --monster_attack(self) - npc_attack(self) + --npc_attack(self) - breed(self) + --breed(self) - if do_states(self, dtime) then + --do_jump(self) + + --runaway_from(self) + + + --if is_at_water_danger(self) and self.state ~= "attack" then + -- if math.random(1, 10) <= 6 then + -- set_velocity(self, 0) + -- self.state = "stand" + -- set_animation(self, "stand") + -- yaw = yaw + math.random(-0.5, 0.5) + -- yaw = set_yaw(self, yaw, 8) + -- end + --end + + + -- Add water flowing for mobs from mcl_item_entity + --[[ + local p, node, nn, def + p = self.object:get_pos() + node = minetest_get_node_or_nil(p) + if node then + nn = node.name + def = minetest_registered_nodes[nnenable_physicss if not on/in flowing liquid + self._flowing = false + enable_physics(self.object, self, true) return end - if not self.object:get_luaentity() then - return false - end - - do_jump(self) - - runaway_from(self) - - if is_at_water_danger(self) and self.state ~= "attack" then - if random(1, 10) <= 6 then - set_velocity(self, 0) - self.state = "stand" - set_animation(self, "stand") - yaw = yaw + random(-0.5, 0.5) - yaw = set_yaw(self, yaw, 8) - end - end - - -- Add water flowing for mobs from mcl_item_entity - local p, node, nn, def - p = self.object:get_pos() - node = minetest.get_node_or_nil(p) - if node then - nn = node.name - def = minetest.registered_nodes[nn] - end - - -- Move item around on flowing liquids - if def and def.liquidtype == "flowing" then - - --[[ Get flowing direction (function call from flowlib), if there's a liquid. - NOTE: According to Qwertymine, flowlib.quickflow is only reliable for liquids with a flowing distance of 7. - Luckily, this is exactly what we need if we only care about water, which has this flowing distance. ]] - local vec = flowlib.quick_flow(p, node) - -- Just to make sure we don't manipulate the speed for no reason - if vec.x ~= 0 or vec.y ~= 0 or vec.z ~= 0 then - -- Minecraft Wiki: Flowing speed is "about 1.39 meters per second" - local f = 1.39 - -- Set new item moving speed into the direciton of the liquid - local newv = vector.multiply(vec, f) - self.object:set_acceleration({x = 0, y = 0, z = 0}) - self.object:set_velocity({x = newv.x, y = -0.22, z = newv.z}) - - self.physical_state = true - self._flowing = true - self.object:set_properties({ - physical = true - }) - return - end - elseif self._flowing == true then - -- Disable flowing physics if not on/in flowing liquid - self._flowing = false - enable_physics(self.object, self, true) - return - end - --Mob following code. follow_flop(self) + if is_at_cliff_or_danger(self) then set_velocity(self, 0) self.state = "stand" @@ -3675,696 +2991,6 @@ local mob_step = function(self, dtime) end end end -end + ]]-- - --- default function when mobs are blown up with TNT -local do_tnt = function(obj, damage) - - obj.object:punch(obj.object, 1.0, { - full_punch_interval = 1.0, - damage_groups = {fleshy = damage}, - }, nil) - - return false, true, {} -end - - -mobs.spawning_mobs = {} - --- Code to execute before custom on_rightclick handling -local on_rightclick_prefix = function(self, clicker) - local item = clicker:get_wielded_item() - - -- Name mob with nametag - if not self.ignores_nametag and item:get_name() == "mcl_mobs:nametag" then - - local tag = item:get_meta():get_string("name") - if tag ~= "" then - if string.len(tag) > MAX_MOB_NAME_LENGTH then - tag = string.sub(tag, 1, MAX_MOB_NAME_LENGTH) - end - self.nametag = tag - - update_tag(self) - - if not mobs.is_creative(clicker:get_player_name()) then - item:take_item() - clicker:set_wielded_item(item) - end - return true - end - - end - return false -end - -local create_mob_on_rightclick = function(on_rightclick) - return function(self, clicker) - local stop = on_rightclick_prefix(self, clicker) - if (not stop) and (on_rightclick) then - on_rightclick(self, clicker) - end - end -end - --- register mob entity -function mobs:register_mob(name, def) - - mobs.spawning_mobs[name] = true - -local can_despawn -if def.can_despawn ~= nil then - can_despawn = def.can_despawn -elseif def.spawn_class == "passive" then - can_despawn = false -else - can_despawn = true -end - -local function scale_difficulty(value, default, min, special) - if (not value) or (value == default) or (value == special) then - return default - else - return max(min, value * difficulty) - end -end - -local collisionbox = def.collisionbox or {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25} --- Workaround for : --- Increase upper Y limit to avoid mobs glitching through solid nodes. --- FIXME: Remove workaround if it's no longer needed. -if collisionbox[5] < 0.79 then - collisionbox[5] = 0.79 -end - -minetest.register_entity(name, { - - use_texture_alpha = def.use_texture_alpha, - stepheight = def.stepheight or 0.6, - name = name, - type = def.type, - attack_type = def.attack_type, - fly = def.fly, - fly_in = def.fly_in or {"air", "__airlike"}, - owner = def.owner or "", - order = def.order or "", - on_die = def.on_die, - spawn_small_alternative = def.spawn_small_alternative, - do_custom = def.do_custom, - jump_height = def.jump_height or 4, -- was 6 - rotate = math.rad(def.rotate or 0), -- 0=front, 90=side, 180=back, 270=side2 - lifetimer = def.lifetimer or 57.73, - hp_min = scale_difficulty(def.hp_min, 5, 1), - hp_max = scale_difficulty(def.hp_max, 10, 1), - xp_min = def.xp_min or 0, - xp_max = def.xp_max or 0, - xp_timestamp = 0, - breath_max = def.breath_max or 15, - breathes_in_water = def.breathes_in_water or false, - physical = true, - collisionbox = collisionbox, - selectionbox = def.selectionbox or def.collisionbox, - visual = def.visual, - visual_size = def.visual_size or {x = 1, y = 1}, - mesh = def.mesh, - makes_footstep_sound = def.makes_footstep_sound or false, - view_range = def.view_range or 16, - walk_velocity = def.walk_velocity or 1, - run_velocity = def.run_velocity or 2, - damage = scale_difficulty(def.damage, 0, 0), - light_damage = def.light_damage or 0, - sunlight_damage = def.sunlight_damage or 0, - water_damage = def.water_damage or 0, - lava_damage = def.lava_damage or 8, - fire_damage = def.fire_damage or 1, - suffocation = def.suffocation or true, - fall_damage = def.fall_damage or 1, - fall_speed = def.fall_speed or DEFAULT_FALL_SPEED, -- must be lower than -2 - drops = def.drops or {}, - armor = def.armor or 100, - on_rightclick = create_mob_on_rightclick(def.on_rightclick), - arrow = def.arrow, - shoot_interval = def.shoot_interval, - sounds = def.sounds or {}, - animation = def.animation, - follow = def.follow, - jump = def.jump ~= false, - walk_chance = def.walk_chance or 50, - attacks_monsters = def.attacks_monsters or false, - group_attack = def.group_attack or false, - passive = def.passive or false, - knock_back = def.knock_back ~= false, - shoot_offset = def.shoot_offset or 0, - floats = def.floats or 1, -- floats in water by default - floats_on_lava = def.floats_on_lava or 0, - replace_rate = def.replace_rate, - replace_what = def.replace_what, - replace_with = def.replace_with, - replace_offset = def.replace_offset or 0, - on_replace = def.on_replace, - timer = 0, - env_damage_timer = 0, - tamed = false, - pause_timer = 0, - horny = false, - hornytimer = 0, - gotten = false, - health = 0, - reach = def.reach or 3, - htimer = 0, - texture_list = def.textures, - child_texture = def.child_texture, - docile_by_day = def.docile_by_day or false, - time_of_day = 0.5, - fear_height = def.fear_height or 0, - runaway = def.runaway, - runaway_timer = 0, - pathfinding = def.pathfinding, - immune_to = def.immune_to or {}, - explosion_radius = def.explosion_radius, -- LEGACY - explosion_damage_radius = def.explosion_damage_radius, -- LEGACY - explosiontimer_reset_radius = def.explosiontimer_reset_radius, - explosion_timer = def.explosion_timer or 3, - allow_fuse_reset = def.allow_fuse_reset ~= false, - stop_to_explode = def.stop_to_explode ~= false, - custom_attack = def.custom_attack, - double_melee_attack = def.double_melee_attack, - dogshoot_switch = def.dogshoot_switch, - dogshoot_count = 0, - dogshoot_count_max = def.dogshoot_count_max or 5, - dogshoot_count2_max = def.dogshoot_count2_max or (def.dogshoot_count_max or 5), - attack_animals = def.attack_animals or false, - specific_attack = def.specific_attack, - runaway_from = def.runaway_from, - owner_loyal = def.owner_loyal, - facing_fence = false, - _cmi_is_mob = true, - pushable = def.pushable or true, - - - -- MCL2 extensions - teleport = teleport, - do_teleport = def.do_teleport, - spawn_class = def.spawn_class, - ignores_nametag = def.ignores_nametag or false, - rain_damage = def.rain_damage or 0, - glow = def.glow, - can_despawn = can_despawn, - child = def.child or false, - texture_mods = {}, - shoot_arrow = def.shoot_arrow, - sounds_child = def.sounds_child, - explosion_strength = def.explosion_strength, - suffocation_timer = 0, - follow_velocity = def.follow_velocity or 2.4, - instant_death = def.instant_death or false, - fire_resistant = def.fire_resistant or false, - fire_damage_resistant = def.fire_damage_resistant or false, - ignited_by_sunlight = def.ignited_by_sunlight or false, - -- End of MCL2 extensions - - on_spawn = def.on_spawn, - - on_blast = def.on_blast or do_tnt, - - on_step = mob_step, - - do_punch = def.do_punch, - - on_punch = mob_punch, - - on_breed = def.on_breed, - - on_grown = def.on_grown, - - on_detach_child = mob_detach_child, - - on_activate = function(self, staticdata, dtime) - --this is a temporary hack so mobs stop - --glitching and acting really weird with the - --default built in engine collision detection - self.object:set_properties({ - collide_with_objects = false, - }) - return mob_activate(self, staticdata, def, dtime) - end, - - get_staticdata = function(self) - return mob_staticdata(self) - end, - - harmed_by_heal = def.harmed_by_heal, - -}) - -if minetest.get_modpath("doc_identifier") ~= nil then - doc.sub.identifier.register_object(name, "basics", "mobs") -end - -end -- END mobs:register_mob function - - --- register arrow for shoot attack -function mobs:register_arrow(name, def) - - if not name or not def then return end -- errorcheck - - minetest.register_entity(name, { - - physical = false, - visual = def.visual, - visual_size = def.visual_size, - textures = def.textures, - velocity = def.velocity, - hit_player = def.hit_player, - hit_node = def.hit_node, - hit_mob = def.hit_mob, - hit_object = def.hit_object, - drop = def.drop or false, -- drops arrow as registered item when true - collisionbox = {0, 0, 0, 0, 0, 0}, -- remove box around arrows - timer = 0, - switch = 0, - owner_id = def.owner_id, - rotate = def.rotate, - on_punch = function(self) - local vel = self.object:get_velocity() - self.object:set_velocity({x=vel.x * -1, y=vel.y * -1, z=vel.z * -1}) - end, - collisionbox = def.collisionbox or {0, 0, 0, 0, 0, 0}, - automatic_face_movement_dir = def.rotate - and (def.rotate - (pi / 180)) or false, - - on_activate = def.on_activate, - - on_step = def.on_step or function(self, dtime) - - self.timer = self.timer + 1 - - local pos = self.object:get_pos() - - if self.switch == 0 - or self.timer > 150 - or not within_limits(pos, 0) then - mcl_burning.extinguish(self.object) - self.object:remove(); - - return - end - - -- does arrow have a tail (fireball) - if def.tail - and def.tail == 1 - and def.tail_texture then - - minetest.add_particle({ - pos = pos, - velocity = {x = 0, y = 0, z = 0}, - acceleration = {x = 0, y = 0, z = 0}, - expirationtime = def.expire or 0.25, - collisiondetection = false, - texture = def.tail_texture, - size = def.tail_size or 5, - glow = def.glow or 0, - }) - end - - if self.hit_node then - - local node = node_ok(pos).name - - if minetest.registered_nodes[node].walkable then - - self.hit_node(self, pos, node) - - if self.drop == true then - - pos.y = pos.y + 1 - - self.lastpos = (self.lastpos or pos) - - minetest.add_item(self.lastpos, self.object:get_luaentity().name) - end - - self.object:remove(); - - return - end - end - - if self.hit_player or self.hit_mob or self.hit_object then - - for _,player in pairs(minetest.get_objects_inside_radius(pos, 1.5)) do - - if self.hit_player - and player:is_player() then - - self.hit_player(self, player) - self.object:remove(); - return - end - - local entity = player:get_luaentity() - - if entity - and self.hit_mob - and entity._cmi_is_mob == true - and tostring(player) ~= self.owner_id - and entity.name ~= self.object:get_luaentity().name then - self.hit_mob(self, player) - self.object:remove(); - return - end - - if entity - and self.hit_object - and (not entity._cmi_is_mob) - and tostring(player) ~= self.owner_id - and entity.name ~= self.object:get_luaentity().name then - self.hit_object(self, player) - self.object:remove(); - return - end - end - end - - self.lastpos = pos - end - }) -end - - --- no damage to nodes explosion -function mobs:safe_boom(self, pos, strength) - minetest.sound_play(self.sounds and self.sounds.explode or "tnt_explode", { - pos = pos, - gain = 1.0, - max_hear_distance = self.sounds and self.sounds.distance or 32 - }, true) - local radius = strength - entity_physics(pos, radius) - effect(pos, 32, "mcl_particles_smoke.png", radius * 3, radius * 5, radius, 1, 0) -end - - --- make explosion with protection and tnt mod check -function mobs:boom(self, pos, strength, fire) - self.object:remove() - if mod_explosions then - if mobs_griefing and not minetest.is_protected(pos, "") then - mcl_explosions.explode(pos, strength, { drop_chance = 1.0, fire = fire }, self.object) - else - mobs:safe_boom(self, pos, strength) - end - else - mobs:safe_boom(self, pos, strength) - end -end - - --- Register spawn eggs - --- Note: This also introduces the “spawn_egg” group: --- * spawn_egg=1: Spawn egg (generic mob, no metadata) --- * spawn_egg=2: Spawn egg (captured/tamed mob, metadata) -function mobs:register_egg(mob, desc, background, addegg, no_creative) - - local grp = {spawn_egg = 1} - - -- do NOT add this egg to creative inventory (e.g. dungeon master) - if no_creative == true then - grp.not_in_creative_inventory = 1 - end - - local invimg = background - - if addegg == 1 then - invimg = "mobs_chicken_egg.png^(" .. invimg .. - "^[mask:mobs_chicken_egg_overlay.png)" - end - - -- register old stackable mob egg - minetest.register_craftitem(mob, { - - description = desc, - inventory_image = invimg, - groups = grp, - - _doc_items_longdesc = S("This allows you to place a single mob."), - _doc_items_usagehelp = S("Just place it where you want the mob to appear. Animals will spawn tamed, unless you hold down the sneak key while placing. If you place this on a mob spawner, you change the mob it spawns."), - - on_place = function(itemstack, placer, pointed_thing) - - local pos = pointed_thing.above - - -- am I clicking on something with existing on_rightclick function? - local under = minetest.get_node(pointed_thing.under) - local def = minetest.registered_nodes[under.name] - if def and def.on_rightclick then - return def.on_rightclick(pointed_thing.under, under, placer, itemstack) - end - - if pos - and within_limits(pos, 0) - and not minetest.is_protected(pos, placer:get_player_name()) then - - local name = placer:get_player_name() - local privs = minetest.get_player_privs(name) - if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then - if minetest.is_protected(pointed_thing.under, name) then - minetest.record_protection_violation(pointed_thing.under, name) - return itemstack - end - if not privs.maphack then - minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner.")) - return itemstack - end - mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name()) - if not mobs.is_creative(name) then - itemstack:take_item() - end - return itemstack - end - - if not minetest.registered_entities[mob] then - return itemstack - end - - if minetest.settings:get_bool("only_peaceful_mobs", false) - and minetest.registered_entities[mob].type == "monster" then - minetest.chat_send_player(name, S("Only peaceful mobs allowed!")) - return itemstack - end - - pos.y = pos.y - 0.5 - - local mob = minetest.add_entity(pos, mob) - minetest.log("action", "Mob spawned: "..name.." at "..minetest.pos_to_string(pos)) - local ent = mob:get_luaentity() - - -- don't set owner if monster or sneak pressed - if ent.type ~= "monster" - and not placer:get_player_control().sneak then - ent.owner = placer:get_player_name() - ent.tamed = true - end - - -- set nametag - local nametag = itemstack:get_meta():get_string("name") - if nametag ~= "" then - if string.len(nametag) > MAX_MOB_NAME_LENGTH then - nametag = string.sub(nametag, 1, MAX_MOB_NAME_LENGTH) - end - ent.nametag = nametag - update_tag(ent) - end - - -- if not in creative then take item - if not mobs.is_creative(placer:get_player_name()) then - itemstack:take_item() - end - end - - return itemstack - end, - }) - -end - - --- No-op in MCL2 (capturing mobs is not possible). --- Provided for compability with Mobs Redo -function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso, force_take, replacewith) - return false -end - - --- No-op in MCL2 (protecting mobs is not possible). -function mobs:protect(self, clicker) - return false -end - - --- feeding, taming and breeding (thanks blert2112) -function mobs:feed_tame(self, clicker, feed_count, breed, tame) - if not self.follow then - return false - end - - -- can eat/tame with item in hand - if follow_holding(self, clicker) then - - -- if not in creative then take item - if not mobs.is_creative(clicker:get_player_name()) then - - local item = clicker:get_wielded_item() - - item:take_item() - - clicker:set_wielded_item(item) - end - - mob_sound(self, "eat", nil, true) - - -- increase health - self.health = self.health + 4 - - if self.health >= self.hp_max then - - self.health = self.hp_max - - if self.htimer < 1 then - self.htimer = 5 - end - end - - self.object:set_hp(self.health) - - update_tag(self) - - -- make children grow quicker - if self.child == true then - - -- deduct 10% of the time to adulthood - self.hornytimer = self.hornytimer + ((CHILD_GROW_TIME - self.hornytimer) * 0.1) - - return true - end - - -- feed and tame - self.food = (self.food or 0) + 1 - if self.food >= feed_count then - - self.food = 0 - - if breed and self.hornytimer == 0 then - self.horny = true - end - - if tame then - - self.tamed = true - - if not self.owner or self.owner == "" then - self.owner = clicker:get_player_name() - end - end - - -- make sound when fed so many times - mob_sound(self, "random", true) - end - - return true - end - - return false -end - --- Spawn a child -function mobs:spawn_child(pos, mob_type) - local child = minetest.add_entity(pos, mob_type) - if not child then - return - end - - local ent = child:get_luaentity() - effect(pos, 15, "mcl_particles_smoke.png", 1, 2, 2, 15, 5) - - ent.child = true - - local textures - -- using specific child texture (if found) - if ent.child_texture then - textures = ent.child_texture[1] - end - - -- and resize to half height - child:set_properties({ - textures = textures, - visual_size = { - x = ent.base_size.x * .5, - y = ent.base_size.y * .5, - }, - collisionbox = { - ent.base_colbox[1] * .5, - ent.base_colbox[2] * .5, - ent.base_colbox[3] * .5, - ent.base_colbox[4] * .5, - ent.base_colbox[5] * .5, - ent.base_colbox[6] * .5, - }, - selectionbox = { - ent.base_selbox[1] * .5, - ent.base_selbox[2] * .5, - ent.base_selbox[3] * .5, - ent.base_selbox[4] * .5, - ent.base_selbox[5] * .5, - ent.base_selbox[6] * .5, - }, - }) - - return child -end - - --- compatibility function for old entities to new modpack entities -function mobs:alias_mob(old_name, new_name) - - -- spawn egg - minetest.register_alias(old_name, new_name) - - -- entity - minetest.register_entity(":" .. old_name, { - - physical = false, - - on_step = function(self) - - if minetest.registered_entities[new_name] then - minetest.add_entity(self.object:get_pos(), new_name) - end - - self.object:remove() - end - }) - -end - ---[[ -local timer = 0 -minetest.register_globalstep(function(dtime) - timer = timer + dtime - if timer < 1 then return end - for _, player in pairs(minetest.get_connected_players()) do - local pos = player:get_pos() - for _, obj in pairs(minetest.get_objects_inside_radius(pos, 47)) do - local lua = obj:get_luaentity() - if lua and lua._cmi_is_mob then - lua.lifetimer = math.max(20, lua.lifetimer) - lua.despawn_immediately = false - end - end - end - timer = 0 -end) -]]-- \ No newline at end of file +--end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua new file mode 100644 index 00000000..c50fb630 --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua @@ -0,0 +1,179 @@ +local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius + +local vector = vector + +--check to see if someone nearby has some tasty food +mobs.check_following = function(self) -- returns true or false + --ignore + if not self.follow then + self.following_person = nil + return false + end + + --hey look, this thing works for passive mobs too! + local follower = mobs.detect_closest_player_within_radius(self,true,self.view_range,self.eye_height) + + --check if the follower is a player incase they log out + if follower and follower:is_player() then + local stack = follower:get_wielded_item() + --safety check + if not stack then + self.following_person = nil + return false + end + + local item_name = stack:get_name() + --all checks have passed, that guy has some good looking food + if item_name == self.follow then + self.following_person = follower + return true + end + end + + --everything failed + self.following_person = nil + return false +end + +--a function which attempts to make mobs enter +--the breeding state +mobs.enter_breed_state = function(self,clicker) + + --do not breed if baby + if self.baby then + return false + end + + --do not do anything if looking for mate or + --if cooling off from breeding + if self.breed_lookout_timer > 0 or self.breed_timer > 0 then + return false + end + + --if this is caught, that means something has gone + --seriously wrong + if not clicker or not clicker:is_player() then + return false + end + + local stack = clicker:get_wielded_item() + --safety check + if not stack then + return false + end + + local item_name = stack:get_name() + --all checks have passed, that guy has some good looking food + if item_name == self.follow then + if not minetest.is_creative_enabled(clicker:get_player_name()) then + stack:take_item() + clicker:set_wielded_item(stack) + end + self.breed_lookout_timer = self.breed_lookout_timer_goal + self.bred = true + mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic") + return true + end + + --everything failed + return false +end + + +--find the closest mate in the area +mobs.look_for_mate = function(self) + + local pos1 = self.object:get_pos() + pos1.y = pos1.y + self.eye_height + + local mates_in_area = {} + local winner_mate = nil + local mates_detected = 0 + local radius = self.view_range + + --get mates in radius + for _,mate in pairs(minetest_get_objects_inside_radius(pos1, radius)) do + + --look for a breeding mate + if mate and mate:get_luaentity() + and mate:get_luaentity()._cmi_is_mob + and mate:get_luaentity().name == self.name + and mate:get_luaentity().breed_lookout_timer > 0 + and mate:get_luaentity() ~= self then + + local pos2 = mate:get_pos() + + local distance = vector.distance(pos1,pos2) + + if distance <= radius then + if minetest.line_of_sight then + --must add eye height or stuff breaks randomly because of + --seethrough nodes being a blocker (like grass) + if minetest.line_of_sight( + vector.new(pos1.x, pos1.y, pos1.z), + vector.new(pos2.x, pos2.y + mate:get_properties().eye_height, pos2.z) + ) then + mates_detected = mates_detected + 1 + mates_in_area[mate] = distance + end + else + mates_detected = mates_detected + 1 + mates_in_area[mate] = distance + end + end + end + end + + + --return if there's no one near by + if mates_detected <= 0 then --handle negative numbers for some crazy error that could possibly happen + return nil + end + + --do a default radius max + local shortest_distance = radius + 1 + + --sort through mates and find the closest mate + for mate,distance in pairs(mates_in_area) do + if distance < shortest_distance then + shortest_distance = distance + winner_mate = mate + end + end + return winner_mate +end + +--make the baby grow up +mobs.baby_grow_up = function(self) + self.baby = nil + self.visual_size = self.backup_visual_size + self.collisionbox = self.backup_collisionbox + self.selectionbox = self.backup_selectionbox + self.object:set_properties(self) +end + +--makes the baby grow up faster with diminishing returns +mobs.make_baby_grow_faster = function(self,clicker) + if clicker and clicker:is_player() then + local stack = clicker:get_wielded_item() + --safety check + if not stack then + return false + end + + local item_name = stack:get_name() + --all checks have passed, that guy has some good looking food + if item_name == self.follow then + self.grow_up_timer = self.grow_up_timer - (self.grow_up_timer * 0.10) --take 10 percent off - diminishing returns + + if not minetest.is_creative_enabled(clicker:get_player_name()) then + stack:take_item() + clicker:set_wielded_item(stack) + end + + mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic") + return true + end + end + return false +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua new file mode 100644 index 00000000..ed9aec6c --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua @@ -0,0 +1,135 @@ +local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius + +local math_random = math.random +local vector_multiply = vector.multiply + +local vector_direction = vector.direction + +local integer_test = {-1,1} + +mobs.collision = function(self) + local pos = self.object:get_pos() + + if not self or not self.object or not self.object:get_luaentity() then + return + end + + --do collision detection from the base of the mob + local collisionbox = self.object:get_properties().collisionbox + + pos.y = pos.y + collisionbox[2] + + local collision_boundary = collisionbox[4] + + local radius = collision_boundary + + if collisionbox[5] > collision_boundary then + radius = collisionbox[5] + end + + local collision_count = 0 + + + local check_for_attack = false + + if self.attack_type == "punch" and self.hostile and self.attacking then + check_for_attack = true + end + + for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do + if object and object ~= self.object and (object:is_player() or (object:get_luaentity() and object:get_luaentity()._cmi_is_mob == true and object:get_luaentity().health > 0)) and + --don't collide with rider, rider don't collide with thing + (not object:get_attach() or (object:get_attach() and object:get_attach() ~= self.object)) and + (not self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then + --stop infinite loop + collision_count = collision_count + 1 + --mob cramming + if collision_count > 30 then + self.health = -20 + break + end + + local pos2 = object:get_pos() + + local object_collisionbox = object:get_properties().collisionbox + + pos2.y = pos2.y + object_collisionbox[2] + + local object_collision_boundary = object_collisionbox[4] + + + --this is checking the difference of the object collided with's possision + --if positive top of other object is inside (y axis) of current object + local y_base_diff = (pos2.y + object_collisionbox[5]) - pos.y + + local y_top_diff = (pos.y + collisionbox[5]) - pos2.y + + + local distance = vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z)) + + if distance <= collision_boundary + object_collision_boundary and y_base_diff >= 0 and y_top_diff >= 0 then + + local dir = vector.direction(pos,pos2) + + dir.y = 0 + + --eliminate mob being stuck in corners + if dir.x == 0 and dir.z == 0 then + --slightly adjust mob position to prevent equal length + --corner/wall sticking + dir.x = dir.x + ((math_random()/10)*integer_test[math.random(1,2)]) + dir.z = dir.z + ((math_random()/10)*integer_test[math.random(1,2)]) + end + + local velocity = dir + + --0.5 is the max force multiplier + local force = 0.5 - (0.5 * distance / (collision_boundary + object_collision_boundary)) + + local vel1 = vector.multiply(velocity, -1.5) + local vel2 = vector.multiply(velocity, 1.5) + + vel1 = vector.multiply(vel1, force * 10) + vel2 = vector.multiply(vel2, force) + + if object:is_player() then + vel2 = vector_multiply(vel2, 2.5) + + --integrate mob punching into collision detection + if check_for_attack and self.punch_timer <= 0 then + if object == self.attacking then + mobs.punch_attack(self) + end + end + end + self.object:add_velocity(vel1) + object:add_velocity(vel2) + end + end + end +end + + +--this is used for arrow collisions +mobs.arrow_hit = function(self, player) + player:punch(self.object, 1.0, { + full_punch_interval = 1.0, + damage_groups = {fleshy = self._damage} + }, nil) + + + --knockback + local pos1 = self.object:get_pos() + pos1.y = 0 + local pos2 = player:get_pos() + pos2.y = 0 + local dir = vector_direction(pos1,pos2) + + dir = vector_multiply(dir,3) + + if player:get_velocity().y <= 1 then + dir.y = 5 + end + + player:add_velocity(dir) +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua new file mode 100644 index 00000000..45e46d3d --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua @@ -0,0 +1,158 @@ +local minetest_add_item = minetest.add_item +--local minetest_sound_play = minetest.sound_play + +local math_pi = math.pi +local math_random = math.random +local math_floor = math.floor +local HALF_PI = math_pi / 2 + +local vector_new = vector.new + + +-- drop items +local item_drop = function(self, cooked, looting_level) + + looting_level = looting_level or 0 + + -- no drops for child mobs (except monster) + if (self.child and self.type ~= "monster") then + return + end + + local obj, item + local pos = self.object:get_pos() + + self.drops = self.drops or {} -- nil check + + for n = 1, #self.drops do + local dropdef = self.drops[n] + local chance = 1 / dropdef.chance + local looting_type = dropdef.looting + + if looting_level > 0 then + local chance_function = dropdef.looting_chance_function + if chance_function then + chance = chance_function(looting_level) + elseif looting_type == "rare" then + chance = chance + (dropdef.looting_factor or 0.01) * looting_level + end + end + + local num = 0 + local do_common_looting = (looting_level > 0 and looting_type == "common") + if math_random() < chance then + num = math_random(dropdef.min or 1, dropdef.max or 1) + elseif not dropdef.looting_ignore_chance then + do_common_looting = false + end + + if do_common_looting then + num = num + math_floor(math_random(0, looting_level) + 0.5) + end + + if num > 0 then + item = dropdef.name + + -- cook items when true + if cooked then + + local output = minetest.get_craft_result({ + method = "cooking", + width = 1, + items = {item}, + }) + + if output and output.item and not output.item:is_empty() then + item = output.item:get_name() + end + end + + -- add item if it exists + for x = 1, num do + obj = minetest_add_item(pos, ItemStack(item .. " " .. 1)) + end + + if obj and obj:get_luaentity() then + + obj:set_velocity({ + x = math_random(-10, 10) / 9, + y = 6, + z = math_random(-10, 10) / 9, + }) + elseif obj then + obj:remove() -- item does not exist + end + end + end + + self.drops = {} +end + + +mobs.death_logic = function(self, dtime) + + --stop crashing game when object is nil + if not self or not self.object or not self.object:get_luaentity() then + return + end + + self.death_animation_timer = self.death_animation_timer + dtime + + --get all attached entities and sort through them + local attached_entities = self.object:get_children() + if #attached_entities > 0 then + for _,entity in pairs(attached_entities) do + --kick the player off + if entity:is_player() then + mobs.detach(entity) + --kick mobs off + --if there is scaling issues, this needs an additional check + else + entity:set_detach() + end + end + end + + --stop mob from getting in the way of other mobs you're fighting + if self.object:get_properties().pointable then + self.object:set_properties({pointable = false}) + end + + --the final POOF of a mob despawning + 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)) + self.object:remove() + return + end + + --I'm sure there's a more efficient way to do this + --but this is the easiest, easier to work with 1 variable synced + --this is also not smooth + local death_animation_roll = self.death_animation_timer * 2 -- * 2 to make it faster + if death_animation_roll > 1 then + death_animation_roll = 1 + end + + local rot = self.object:get_rotation() --(no pun intended) + + rot.z = death_animation_roll * HALF_PI + + self.object:set_rotation(rot) + + mobs.set_mob_animation(self,"stand", true) + + + --flying and swimming mobs just fall down + if self.fly or self.swim then + if self.object:get_acceleration().y ~= -self.gravity then + self.object:set_acceleration(vector_new(0,-self.gravity,0)) + end + end + + --when landing allow mob to slow down and just fall if in air + if self.pause_timer <= 0 then + mobs.set_velocity(self,0) + end +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua new file mode 100644 index 00000000..5c431135 --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua @@ -0,0 +1,250 @@ +local minetest_line_of_sight = minetest.line_of_sight +--local minetest_dir_to_yaw = minetest.dir_to_yaw +local minetest_yaw_to_dir = minetest.yaw_to_dir +local minetest_get_node = minetest.get_node +local minetest_get_item_group = minetest.get_item_group +local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius +local minetest_get_node_or_nil = minetest.get_node_or_nil +local minetest_registered_nodes = minetest.registered_nodes +local minetest_get_connected_players = minetest.get_connected_players + +local vector_new = vector.new +local vector_add = vector.add +local vector_multiply = vector.multiply +local vector_distance = vector.distance + +local table_copy = table.copy + +local math_abs = math.abs + +-- default function when mobs are blown up with TNT +--[[local function do_tnt(obj, damage) + obj.object:punch(obj.object, 1.0, { + full_punch_interval = 1.0, + damage_groups = {fleshy = damage}, + }, nil) + return false, true, {} +end]] + +--a fast function to be able to detect only players without using objects_in_radius +mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, object_height_adder) + local pos1 = self.object:get_pos() + local players_in_area = {} + local winner_player = nil + local players_detected = 0 + + --get players in radius + for _,player in pairs(minetest.get_connected_players()) do + if player and player:get_hp() > 0 then + + local pos2 = player:get_pos() + + local distance = vector_distance(pos1,pos2) + + if distance <= radius then + if line_of_sight then + --must add eye height or stuff breaks randomly because of + --seethrough nodes being a blocker (like grass) + if minetest_line_of_sight( + vector_new(pos1.x, pos1.y + object_height_adder, pos1.z), + vector_new(pos2.x, pos2.y + player:get_properties().eye_height, pos2.z) + ) then + players_detected = players_detected + 1 + players_in_area[player] = distance + end + else + players_detected = players_detected + 1 + players_in_area[player] = distance + end + end + end + end + + + --return if there's no one near by + if players_detected <= 0 then --handle negative numbers for some crazy error that could possibly happen + return nil + end + + --do a default radius max + local shortest_distance = radius + 1 + + --sort through players and find the closest player + for player,distance in pairs(players_in_area) do + if distance < shortest_distance then + shortest_distance = distance + winner_player = player + end + end + return winner_player +end + + +--check if a mob needs to jump +mobs.jump_check = function(self,dtime) + + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + local dir = minetest_yaw_to_dir(self.yaw) + + local collisionbox = self.object:get_properties().collisionbox + local radius = collisionbox[4] + 0.5 + + vector_multiply(dir, radius) + + --only jump if there's a node and a non-solid node above it + local test_dir = vector_add(pos,dir) + + local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0 + + test_dir.y = test_dir.y + 1 + + local green_flag_2 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") == 0 + + if green_flag_1 and green_flag_2 then + --can jump over node + return 1 + elseif green_flag_1 and not green_flag_2 then + --wall in front of mob + return 2 + end + --nothing to jump over + return 0 +end + +-- a helper function to quickly turn neutral passive mobs hostile +local turn_hostile = function(self,detected_mob) + --drop in variables for attacking (stops crash) + detected_mob.punch_timer = 0 + --set to hostile + detected_mob.hostile = true + --hostile_cooldown timer is initialized here + detected_mob.hostile_cooldown_timer = detected_mob.hostile_cooldown + --set target to the same + detected_mob.attacking = self.attacking +end + +--allow hostile mobs to signal to other mobs +--to switch from neutal passive to neutral hostile +mobs.group_attack_initialization = function(self) + + --get basic data + local friends_list + + if self.group_attack == true then + friends_list = {self.name} + else + friends_list = table_copy(self.group_attack) + end + + local objects_in_area = minetest_get_objects_inside_radius(self.object:get_pos(), self.view_range) + + --get the player's name + local name = self.attacking:get_player_name() + + --re-use local variable + local detected_mob + + --run through mobs in viewing distance + for _,object in pairs(objects_in_area) do + if object and object:get_luaentity() then + detected_mob = object:get_luaentity() + -- only alert members of same mob or friends + if detected_mob._cmi_is_mob and detected_mob.state ~= "attack" and detected_mob.owner ~= name then + if detected_mob.name == self.name then + turn_hostile(self,detected_mob) + else + for _,id in pairs(friends_list) do + if detected_mob.name == id then + turn_hostile(self,detected_mob) + break + end + end + end + end + + --THIS NEEDS TO BE RE-IMPLEMENTED AS A GLOBAL HIT IN MOB_PUNCH!! + -- have owned mobs attack player threat + --if obj.owner == name and obj.owner_loyal then + -- do_attack(obj, self.object) + --end + end + end +end + +-- check if within physical map limits (-30911 to 30927) +-- within_limits, wmin, wmax = nil, -30913, 30928 +mobs.within_limits = function(pos, radius) + local wmin, wmax + if mcl_vars then + if mcl_vars.mapgen_edge_min and mcl_vars.mapgen_edge_max then + wmin, wmax = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max + end + end + return pos + and (pos.x - radius) > wmin and (pos.x + radius) < wmax + and (pos.y - radius) > wmin and (pos.y + radius) < wmax + and (pos.z - radius) > wmin and (pos.z + radius) < wmax +end + +-- get node but use fallback for nil or unknown +mobs.node_ok = function(pos, fallback) + + fallback = fallback or mobs.fallback_node + + local node = minetest_get_node_or_nil(pos) + + if node and minetest_registered_nodes[node.name] then + return node + end + + return minetest_registered_nodes[fallback] +end + + +--a teleport functoin +mobs.teleport = function(self, target) + if self.do_teleport then + if self.do_teleport(self, target) == false then + return + end + end +end + +--a function used for despawning mobs +mobs.check_for_player_within_area = function(self, radius) + local pos1 = self.object:get_pos() + --get players in radius + for _,player in pairs(minetest_get_connected_players()) do + if player and player:get_hp() > 0 then + local pos2 = player:get_pos() + local distance = vector_distance(pos1,pos2) + if distance < radius then + --found a player + return true + end + end + end + --did not find a player + return false +end + + +--a simple helper function for mobs following +mobs.get_2d_distance = function(pos1,pos2) + pos1.y = 0 + pos2.y = 0 + return vector_distance(pos1, pos2) +end + +-- fall damage onto solid ground +mobs.calculate_fall_damage = function(self) + if self.old_velocity and self.old_velocity.y < -7 and self.object:get_velocity().y == 0 then + local vel = self.object:get_velocity() + if vel then + local damage = math_abs(self.old_velocity.y + 7) * 2 + self.pause_timer = 0.4 + self.health = self.health - damage + end + end +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua new file mode 100644 index 00000000..0f561550 --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua @@ -0,0 +1,98 @@ +local math = math +local vector = vector + +--converts yaw to degrees +local degrees = function(yaw) + return yaw*180.0/math.pi +end + +mobs.do_head_logic = function(self,dtime) + + local player = minetest.get_player_by_name("singleplayer") + + local look_at = player:get_pos() + look_at.y = look_at.y + player:get_properties().eye_height + + local pos = self.object:get_pos() + + local body_yaw = self.object:get_yaw() + + local body_dir = minetest.yaw_to_dir(body_yaw) + + pos.y = pos.y + self.head_height_offset + + local head_offset = vector.multiply(body_dir, self.head_direction_offset) + + pos = vector.add(pos, head_offset) + + minetest.add_particle({ + pos = pos, + velocity = {x=0, y=0, z=0}, + acceleration = {x=0, y=0, z=0}, + expirationtime = 0.2, + size = 1, + texture = "default_dirt.png", + }) + + local bone_pos = vector.new(0,0,0) + + --(horizontal) + bone_pos.y = self.head_bone_pos_y + + --(vertical) + bone_pos.z = self.head_bone_pos_z + + --print(yaw) + + --local _, bone_rot = self.object:get_bone_position("head") + + --bone_rot.x = bone_rot.x + (dtime * 10) + --bone_rot.z = bone_rot.z + (dtime * 10) + + local head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw + + if self.reverse_head_yaw then + head_yaw = head_yaw * -1 + end + + --over rotation protection + --stops radians from going out of spec + if head_yaw > math.pi then + head_yaw = head_yaw - (math.pi * 2) + elseif head_yaw < -math.pi then + head_yaw = head_yaw + (math.pi * 2) + end + + + local check_failed = false + --upper check + 90 degrees or upper math.radians (3.14/2) + if head_yaw > math.pi - (math.pi/2) then + head_yaw = 0 + check_failed = true + --lower check - 90 degrees or lower negative math.radians (-3.14/2) + elseif head_yaw < -math.pi + (math.pi/2) then + head_yaw = 0 + check_failed = true + end + + local head_pitch = 0 + + --DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + --head_yaw = 0 + --DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + + if not check_failed then + head_pitch = minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(look_at.x,0,look_at.z)),0,pos.y-look_at.y))+(math.pi/2) + end + + if self.head_pitch_modifier then + head_pitch = head_pitch + self.head_pitch_modifier + end + + if self.swap_y_with_x then + self.object:set_bone_position(self.head_bone, bone_pos, vector.new(degrees(head_pitch),degrees(head_yaw),0)) + else + self.object:set_bone_position(self.head_bone, bone_pos, vector.new(degrees(head_pitch),0,degrees(head_yaw))) + end + --set_bone_position([bone, position, rotation]) +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua new file mode 100644 index 00000000..fa5b3121 --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua @@ -0,0 +1,276 @@ +local minetest_after = minetest.after +local minetest_sound_play = minetest.sound_play +local minetest_dir_to_yaw = minetest.dir_to_yaw + +local math = math +local vector = vector + +local MAX_MOB_NAME_LENGTH = 30 + +local mod_hunger = minetest.get_modpath("mcl_hunger") + +mobs.feed_tame = function(self) + return nil +end + +-- Code to execute before custom on_rightclick handling +local function on_rightclick_prefix(self, clicker) + local item = clicker:get_wielded_item() + + -- Name mob with nametag + if not self.ignores_nametag and item:get_name() == "mcl_mobs:nametag" then + + local tag = item:get_meta():get_string("name") + if tag ~= "" then + if string.len(tag) > MAX_MOB_NAME_LENGTH then + tag = string.sub(tag, 1, MAX_MOB_NAME_LENGTH) + end + self.nametag = tag + + mobs.update_tag(self) + + if not mobs.is_creative(clicker:get_player_name()) then + item:take_item() + clicker:set_wielded_item(item) + end + return true + end + + end + return false +end + +-- I have no idea what this does +mobs.create_mob_on_rightclick = function(on_rightclick) + return function(self, clicker) + --don't allow rightclicking dead mobs + if self.health <= 0 then + return + end + local stop = on_rightclick_prefix(self, clicker) + if (not stop) and (on_rightclick) then + on_rightclick(self, clicker) + end + end +end + + +-- deal damage and effects when mob punched +mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) + --don't do anything if the mob is already dead + if self.health <= 0 then + return + end + + --neutral passive mobs switch to neutral hostile + if self.neutral then + --drop in variables for attacking (stops crash) + self.attacking = hitter + self.punch_timer = 0 + self.hostile = true + --hostile_cooldown timer is initialized here + self.hostile_cooldown_timer = self.hostile_cooldown + + --initialize the group attack (check for other mobs in area, make them neutral hostile) + if self.group_attack then + mobs.group_attack_initialization(self) + end + end + + --turn skittish mobs away and RUN + if self.skittish then + + self.state = "run" + + self.run_timer = 5 --arbitrary 5 seconds + + local pos1 = self.object:get_pos() + pos1.y = 0 + local pos2 = hitter:get_pos() + pos2.y = 0 + + + local dir = vector.direction(pos2,pos1) + + local yaw = minetest_dir_to_yaw(dir) + + self.yaw = yaw + end + + -- custom punch function + if self.do_punch then + -- when false skip going any further + if self.do_punch(self, hitter, tflp, tool_capabilities, dir) == false then + return + end + end + + --don't do damage until pause timer resets + if self.pause_timer > 0 then + return + end + + -- error checking when mod profiling is enabled + if not tool_capabilities then + minetest.log("warning", "[mobs_mc] Mod profiling enabled, damage not enabled") + return + end + + local is_player = hitter:is_player() + + -- punch interval + local weapon = hitter:get_wielded_item() + + --local punch_interval = 1.4 + + -- exhaust attacker + if mod_hunger and is_player then + mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK) + end + + -- calculate mob damage + local damage = 0 + local armor = self.object:get_armor_groups() or {} + + --calculate damage groups + for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do + damage = damage + (tool_capabilities.damage_groups[group] or 0) * ((armor[group] or 0) / 100.0) + end + + if weapon then + local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect") + if fire_aspect_level > 0 then + mcl_burning.set_on_fire(self.object, fire_aspect_level * 4) + end + end + + -- check for tool immunity or special damage + for n = 1, #self.immune_to do + if self.immune_to[n][1] == weapon:get_name() then + damage = self.immune_to[n][2] or 0 + break + end + end + + -- healing + if damage <= -1 then + self.health = self.health - math.floor(damage) + return + end + + --if tool_capabilities then + -- punch_interval = tool_capabilities.full_punch_interval or 1.4 + --end + + -- add weapon wear manually + -- Required because we have custom health handling ("health" property) + --minetest_is_creative_enabled("") ~= true --removed for now + if tool_capabilities then + if tool_capabilities.punch_attack_uses then + -- Without this delay, the wear does not work. Quite hacky ... + minetest_after(0, function(name) + local player = minetest.get_player_by_name(name) + if not player then return end + local weapon = hitter:get_wielded_item(player) + local def = weapon:get_definition() + if def.tool_capabilities and def.tool_capabilities.punch_attack_uses then + local wear = math.floor(65535/tool_capabilities.punch_attack_uses) + weapon:add_wear(wear) + hitter:set_wielded_item(weapon) + end + end, hitter:get_player_name()) + end + end + + + --if player is falling multiply damage by 1.5 + --critical hit + if hitter:get_velocity().y < 0 then + damage = damage * 1.5 + mobs.critical_effect(self) + end + + + -- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately. + if damage >= 0.1 then + + minetest_sound_play("default_punch", { + object = self.object, + max_hear_distance = 16 + }, true) + + -- do damage + self.health = self.health - damage + + + --0.4 seconds until you can hurt the mob again + self.pause_timer = 0.4 + + --don't do knockback from a rider + for _,obj in pairs(self.object:get_children()) do + if obj == hitter then + return + end + end + + -- knock back effect + local velocity = self.object:get_velocity() + + --2d direction + local pos1 = self.object:get_pos() + pos1.y = 0 + local pos2 = hitter:get_pos() + pos2.y = 0 + + local dir = vector.direction(pos2,pos1) + + local up = 3 + + -- if already in air then dont go up anymore when hit + if velocity.y ~= 0 then + up = 0 + end + + --0.75 for perfect distance to not be too easy, and not be too hard + local multiplier = 0.75 + + -- check if tool already has specific knockback value + local knockback_enchant = mcl_enchanting.get_enchantment(hitter:get_wielded_item(), "knockback") + if knockback_enchant and knockback_enchant > 0 then + multiplier = knockback_enchant + 1 --(starts from 1, 1 would be no change) + end + + --do this to sure you can punch a mob back when + --it's coming for you + if self.hostile then + multiplier = multiplier + 2 + end + dir = vector.multiply(dir,multiplier) + dir.y = up + --add the velocity + self.object:add_velocity(dir) + end +end + +--do internal per mob projectile calculations +mobs.shoot_projectile = function(self) + local pos1 = self.object:get_pos() + --add mob eye height + pos1.y = pos1.y + self.eye_height + + local pos2 = self.attacking:get_pos() + --add player eye height + pos2.y = pos2.y + self.attacking:get_properties().eye_height + + --get direction + local dir = vector.direction(pos1,pos2) + + --call internal shoot_arrow function + self.shoot_arrow(self,pos1,dir) +end + +mobs.update_tag = function(self) + self.object:set_properties({ + nametag = self.nametag, + }) +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua new file mode 100644 index 00000000..83df8099 --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua @@ -0,0 +1,150 @@ +local minetest_add_particlespawner = minetest.add_particlespawner + +mobs.death_effect = function(self) + local pos = self.object:get_pos() + --local yaw = self.object:get_yaw() + local collisionbox = self.object:get_properties().collisionbox + + local min, max + + if collisionbox then + min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]} + max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]} + end + + minetest_add_particlespawner({ + amount = 50, + time = 0.0001, + minpos = vector.add(pos, min), + maxpos = vector.add(pos, max), + minvel = vector.new(-0.5,0.5,-0.5), + maxvel = vector.new(0.5,1,0.5), + minexptime = 1.1, + maxexptime = 1.5, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "mcl_particles_mob_death.png", -- this particle looks strange + }) +end + +mobs.critical_effect = function(self) + + local pos = self.object:get_pos() + --local yaw = self.object:get_yaw() + local collisionbox = self.object:get_properties().collisionbox + + local min, max + + if collisionbox then + min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]} + max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]} + end + + minetest_add_particlespawner({ + amount = 10, + time = 0.0001, + minpos = vector.add(pos, min), + maxpos = vector.add(pos, max), + minvel = vector.new(-1,1,-1), + maxvel = vector.new(1,3,1), + minexptime = 0.7, + maxexptime = 1, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "heart.png^[colorize:black:255", + }) +end + +--when feeding a mob +mobs.feed_effect = function(self) + local pos = self.object:get_pos() + --local yaw = self.object:get_yaw() + local collisionbox = self.object:get_properties().collisionbox + + local min, max + + if collisionbox then + min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]} + max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]} + end + + minetest_add_particlespawner({ + amount = 10, + time = 0.0001, + minpos = vector.add(pos, min), + maxpos = vector.add(pos, max), + minvel = vector.new(-1,1,-1), + maxvel = vector.new(1,3,1), + minexptime = 0.7, + maxexptime = 1, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "heart.png^[colorize:gray:255", + }) +end + +--hearts when tamed +mobs.tamed_effect = function(self) + local pos = self.object:get_pos() + --local yaw = self.object:get_yaw() + local collisionbox = self.object:get_properties().collisionbox + + local min, max + + if collisionbox then + min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]} + max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]} + end + + minetest_add_particlespawner({ + amount = 30, + time = 0.0001, + minpos = vector.add(pos, min), + maxpos = vector.add(pos, max), + minvel = vector.new(-1,1,-1), + maxvel = vector.new(1,3,1), + minexptime = 0.7, + maxexptime = 1, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "heart.png", + }) +end + +--hearts when breeding +mobs.breeding_effect = function(self) + local pos = self.object:get_pos() + --local yaw = self.object:get_yaw() + local collisionbox = self.object:get_properties().collisionbox + + local min, max + + if collisionbox then + min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]} + max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]} + end + + minetest_add_particlespawner({ + amount = 2, + time = 0.0001, + minpos = vector.add(pos, min), + maxpos = vector.add(pos, max), + minvel = vector.new(-1,1,-1), + maxvel = vector.new(1,3,1), + minexptime = 0.7, + maxexptime = 1, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "heart.png", + }) +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua new file mode 100644 index 00000000..893f8eed --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua @@ -0,0 +1,387 @@ +-- localize math functions +local math = math +local HALF_PI = math.pi / 2 +local DOUBLE_PI = math.pi * 2 + +-- localize vector functions +local vector = vector + +local minetest_yaw_to_dir = minetest.yaw_to_dir +local minetest_dir_to_yaw = minetest.dir_to_yaw + +local DEFAULT_JUMP_HEIGHT = 5 +local DEFAULT_FLOAT_SPEED = 4 +local DEFAULT_CLIMB_SPEED = 3 + +mobs.stick_in_cobweb = function(self) + local current_velocity = self.object:get_velocity() + + local goal_velocity = vector.multiply(vector.normalize(current_velocity), 0.4) + + goal_velocity.y = -0.5 + + local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) + + --smooths out mobs a bit + if vector.length(new_velocity_addition) >= 0.0001 then + self.object:add_velocity(new_velocity_addition) + end +end + +--this is a generic float function +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 + return + end + + local current_velocity = self.object:get_velocity() + + local goal_velocity = { + x = 0, + y = DEFAULT_FLOAT_SPEED, + z = 0, + } + + local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) + + new_velocity_addition.x = 0 + new_velocity_addition.z = 0 + + --smooths out mobs a bit + if vector.length(new_velocity_addition) >= 0.0001 then + self.object:add_velocity(new_velocity_addition) + end +end + +--this is a generic climb function +mobs.climb = function(self) + + local current_velocity = self.object:get_velocity() + + local goal_velocity = { + x = 0, + y = DEFAULT_CLIMB_SPEED, + z = 0, + } + + local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) + + new_velocity_addition.x = 0 + new_velocity_addition.z = 0 + + --smooths out mobs a bit + if vector.length(new_velocity_addition) >= 0.0001 then + self.object:add_velocity(new_velocity_addition) + end +end + + + +--[[ + _ _ +| | | | +| | __ _ _ __ __| | +| | / _` | '_ \ / _` | +| |___| (_| | | | | (_| | +\_____/\__,_|_| |_|\__,_| +]] + + +-- move mob in facing direction +--this has been modified to be internal +--internal = lua (self.yaw) +--engine = c++ (self.object:get_yaw()) +mobs.set_velocity = function(self, v) + + local yaw = (self.yaw or 0) + + local current_velocity = self.object:get_velocity() + + local goal_velocity = { + x = (math.sin(yaw) * -v), + y = 0, + z = (math.cos(yaw) * v), + } + + + local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) + + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) + end + + new_velocity_addition.y = 0 + + --smooths out mobs a bit + if vector.length(new_velocity_addition) >= 0.0001 then + self.object:add_velocity(new_velocity_addition) + end +end + + + +-- calculate mob velocity +mobs.get_velocity = function(self) + + local v = self.object:get_velocity() + + v.y = 0 + + if v then + return vector.length(v) + end + + return 0 +end + +--make mobs jump +mobs.jump = function(self, velocity) + + if self.object:get_velocity().y ~= 0 or not self.old_velocity or (self.old_velocity and self.old_velocity.y > 0) then + return + end + + --fallback velocity to allow modularity + velocity = velocity or DEFAULT_JUMP_HEIGHT + + self.object:add_velocity(vector.new(0,velocity,0)) +end + +--make mobs fall slowly +mobs.mob_fall_slow = function(self) + + local current_velocity = self.object:get_velocity() + + local goal_velocity = { + x = 0, + y = -2, + z = 0, + } + + + local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) + + new_velocity_addition.x = 0 + new_velocity_addition.z = 0 + + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) + end + + new_velocity_addition.x = 0 + new_velocity_addition.z = 0 + + --smooths out mobs a bit + if vector.length(new_velocity_addition) >= 0.0001 then + self.object:add_velocity(new_velocity_addition) + end + +end + + +--[[ + _____ _ +/ ___| (_) +\ `--.__ ___ _ __ ___ + `--. \ \ /\ / / | '_ ` _ \ +/\__/ /\ V V /| | | | | | | +\____/ \_/\_/ |_|_| |_| |_| +]]-- + + + + +--make mobs flop +mobs.flop = function(self, velocity) + + if self.object:get_velocity().y ~= 0 or not self.old_velocity or (self.old_velocity and self.old_velocity.y > 0) then + return false + end + + mobs.set_velocity(self, 0) + + --fallback velocity to allow modularity + velocity = velocity or DEFAULT_JUMP_HEIGHT + + --create a random direction (2d yaw) + local dir = DOUBLE_PI * math.random() + + --create a random force value + local force = math.random(0,3) + math.random() + + --convert the yaw to a direction vector then multiply it times the force + local final_additional_force = vector.multiply(minetest_yaw_to_dir(dir), force) + + --place in the "flop" velocity to make the mob flop + final_additional_force.y = velocity + + self.object:add_velocity(final_additional_force) + + return true +end + + + +-- move mob in facing direction +--this has been modified to be internal +--internal = lua (self.yaw) +--engine = c++ (self.object:get_yaw()) +mobs.set_swim_velocity = function(self, v) + + local yaw = (self.yaw or 0) + local pitch = (self.pitch or 0) + + if v == 0 then + pitch = 0 + end + + local current_velocity = self.object:get_velocity() + + local goal_velocity = { + x = (math.sin(yaw) * -v), + y = pitch, + z = (math.cos(yaw) * v), + } + + + local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) + + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) + end + + --smooths out mobs a bit + if vector.length(new_velocity_addition) >= 0.0001 then + self.object:add_velocity(new_velocity_addition) + end +end + +--[[ +______ _ +| ___| | +| |_ | |_ _ +| _| | | | | | +| | | | |_| | +\_| |_|\__, | + __/ | + |___/ +]]-- + +-- move mob in facing direction +--this has been modified to be internal +--internal = lua (self.yaw) +--engine = c++ (self.object:get_yaw()) +mobs.set_fly_velocity = function(self, v) + + local yaw = (self.yaw or 0) + local pitch = (self.pitch or 0) + + if v == 0 then + pitch = 0 + end + + local current_velocity = self.object:get_velocity() + + local goal_velocity = { + x = (math.sin(yaw) * -v), + y = pitch, + z = (math.cos(yaw) * v), + } + + + local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) + + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) + end + + --smooths out mobs a bit + if vector.length(new_velocity_addition) >= 0.0001 then + self.object:add_velocity(new_velocity_addition) + end +end + +--a quick and simple pitch calculation between two vector positions +mobs.calculate_pitch = function(pos1, pos2) + + if pos1 == nil or pos2 == nil then + return false + end + + return minetest_dir_to_yaw(vector.new(vector.distance(vector.new(pos1.x,0,pos1.z),vector.new(pos2.x,0,pos2.z)),0,pos1.y - pos2.y)) + HALF_PI +end + +--make mobs fly up or down based on their y difference +mobs.set_pitch_while_attacking = function(self) + local pos1 = self.object:get_pos() + local pos2 = self.attacking:get_pos() + + local pitch = mobs.calculate_pitch(pos2,pos1) + + self.pitch = pitch +end + + + +--[[ + ___ + |_ | + | |_ _ _ __ ___ _ __ + | | | | | '_ ` _ \| '_ \ +/\__/ / |_| | | | | | | |_) | +\____/ \__,_|_| |_| |_| .__/ + | | + |_| +]]-- + +--special mob jump movement +mobs.jump_move = function(self, velocity) + + if self.object:get_velocity().y ~= 0 or not self.old_velocity or (self.old_velocity and self.old_velocity.y > 0) then + return + end + + --make the mob stick for a split second + mobs.set_velocity(self,0) + + --fallback velocity to allow modularity + local jump_height = DEFAULT_JUMP_HEIGHT + + local yaw = (self.yaw or 0) + + local current_velocity = self.object:get_velocity() + + local goal_velocity = { + x = (math.sin(yaw) * -velocity), + y = jump_height, + z = (math.cos(yaw) * velocity), + } + + + local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) + + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) + end + + --smooths out mobs a bit + if vector.length(new_velocity_addition) >= 0.0001 then + self.object:add_velocity(new_velocity_addition) + end +end + +--make it so mobs do not glitch out and freak out +--when moving around over nodes +mobs.swap_auto_step_height_adjust = function(self) + local y_vel = self.object:get_velocity().y + + if y_vel == 0 and self.stepheight ~= self.stepheight_backup then + self.stepheight = self.stepheight_backup + elseif y_vel ~= 0 and self.stepheight ~= 0 then + self.stepheight = 0 + end +end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/projectile_handling.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/projectile_handling.lua new file mode 100644 index 00000000..a4b4c075 --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/projectile_handling.lua @@ -0,0 +1,43 @@ +local GRAVITY = minetest.settings:get("movement_gravity")-- + 9.81 + +mobs.shoot_projectile_handling = function(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_stack, collectable, gravity) + local obj = minetest.add_entity({x=pos.x,y=pos.y,z=pos.z}, arrow_item.."_entity") + if power == nil then + power = 19 + end + if damage == nil then + damage = 3 + end + + gravity = gravity or -GRAVITY + + local knockback + if bow_stack then + local enchantments = mcl_enchanting.get_enchantments(bow_stack) + if enchantments.power then + damage = damage + (enchantments.power + 1) / 4 + end + if enchantments.punch then + knockback = enchantments.punch * 3 + end + if enchantments.flame then + mcl_burning.set_on_fire(obj, math.huge) + 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._damage = damage + le._is_critical = is_critical + le._startpos = pos + le._knockback = knockback + le._collectable = collectable + + --play custom shoot sound + if shooter and shooter.shoot_sound then + minetest.sound_play(shooter.shoot_sound, {pos=pos, max_hear_distance=16}, true) + end + return obj +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua new file mode 100644 index 00000000..65ba764f --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -0,0 +1,224 @@ +local math_random = math.random + +local minetest_settings = minetest.settings + +-- CMI support check +local use_cmi = minetest.global_exists("cmi") + +-- get entity staticdata +mobs.mob_staticdata = function(self) + --despawn mechanism + --don't despawned tamed or bred mobs + if not self.tamed and not self.bred then + if not mobs.check_for_player_within_area(self, 64) then + --print("removing SERIALIZED!") + self.object:remove() + return + end + end + + self.remove_ok = true + self.attack = nil + self.following = nil + + if use_cmi then + self.serialized_cmi_components = cmi.serialize_components(self._cmi_components) + end + + local tmp = {} + + for _,stat in pairs(self) do + + local t = type(stat) + + if t ~= "function" + and t ~= "nil" + and t ~= "userdata" + and _ ~= "_cmi_components" then + tmp[_] = self[_] + end + end + + return minetest.serialize(tmp) +end + + +-- activate mob and reload settings +mobs.mob_activate = function(self, staticdata, def, dtime) + + -- remove monsters in peaceful mode + if self.type == "monster" and minetest_settings:get_bool("only_peaceful_mobs", false) then + mcl_burning.extinguish(self.object) + self.object:remove() + return + end + + -- load entity variables + local tmp = minetest.deserialize(staticdata) + + if tmp then + for _,stat in pairs(tmp) do + self[_] = stat + end + end + + --set up wandering + if not self.wandering then + self.wandering = true + end + + --clear animation + self.current_animation = nil + + -- select random texture, set model and size + if not self.base_texture then + + -- compatiblity with old simple mobs textures + if type(def.textures[1]) == "string" then + def.textures = {def.textures} + end + + self.base_texture = def.textures[math_random(1, #def.textures)] + self.base_mesh = def.mesh + self.base_size = self.visual_size + self.base_colbox = self.collisionbox + self.base_selbox = self.selectionbox + end + + -- for current mobs that dont have this set + if not self.base_selbox then + self.base_selbox = self.selectionbox or self.base_colbox + end + + -- set texture, model and size + local textures = self.base_texture + local mesh = self.base_mesh + local vis_size = self.base_size + local colbox = self.base_colbox + local selbox = self.base_selbox + + -- specific texture if gotten + if self.gotten == true + and def.gotten_texture then + textures = def.gotten_texture + end + + -- specific mesh if gotten + if self.gotten == true + and def.gotten_mesh then + mesh = def.gotten_mesh + end + + -- set baby mobs to half size + if self.baby == true then + + vis_size = { + x = self.base_size.x * self.baby_size, + y = self.base_size.y * self.baby_size, + } + + if def.child_texture then + textures = def.child_texture[1] + end + + colbox = { + self.base_colbox[1] * self.baby_size, + self.base_colbox[2] * self.baby_size, + self.base_colbox[3] * self.baby_size, + self.base_colbox[4] * self.baby_size, + self.base_colbox[5] * self.baby_size, + self.base_colbox[6] * self.baby_size + } + selbox = { + self.base_selbox[1] * self.baby_size, + self.base_selbox[2] * self.baby_size, + self.base_selbox[3] * self.baby_size, + self.base_selbox[4] * self.baby_size, + self.base_selbox[5] * self.baby_size, + self.base_selbox[6] * self.baby_size + } + end + + --stop mobs from reviving + if not self.dead and not self.health then + self.health = math_random (self.hp_min, self.hp_max) + end + + if not self.random_sound_timer then + self.random_sound_timer = math_random(self.random_sound_timer_min,self.random_sound_timer_max) + end + + if self.breath == nil then + self.breath = self.breath_max + end + + -- pathfinding init + self.path = {} + self.path.way = {} -- path to follow, table of positions + self.path.lastpos = {x = 0, y = 0, z = 0} + self.path.stuck = false + self.path.following = false -- currently following path? + self.path.stuck_timer = 0 -- if stuck for too long search for path + + -- Armor groups + -- immortal=1 because we use custom health + -- handling (using "health" property) + local armor + if type(self.armor) == "table" then + armor = table.copy(self.armor) + armor.immortal = 1 + else + armor = {immortal=1, fleshy = self.armor} + end + self.object:set_armor_groups(armor) + self.old_y = self.object:get_pos().y + self.old_health = self.health + self.sounds.distance = self.sounds.distance or 10 + self.textures = textures + self.mesh = mesh + self.collisionbox = colbox + self.selectionbox = selbox + self.visual_size = vis_size + self.standing_in = "ignore" + self.standing_on = "ignore" + self.jump_sound_cooloff = 0 -- used to prevent jump sound from being played too often in short time + self.opinion_sound_cooloff = 0 -- used to prevent sound spam of particular sound types + + self.texture_mods = {} + + self.v_start = false + self.timer = 0 + self.blinktimer = 0 + self.blinkstatus = false + + + --continue mob effect on server restart + if self.dead or self.health <= 0 then + self.object:set_texture_mod("^[colorize:red:120") + else + self.object:set_texture_mod("") + end + + -- set anything changed above + self.object:set_properties(self) + + --update_tag(self) + --mobs.set_animation(self, "stand") + + -- run on_spawn function if found + if self.on_spawn and not self.on_spawn_run then + if self.on_spawn(self) then + self.on_spawn_run = true -- if true, set flag to run once only + end + end + + -- run after_activate + if def.after_activate then + def.after_activate(self, staticdata, def, dtime) + end + + if use_cmi then + self._cmi_components = cmi.activate_components(self.serialized_cmi_components) + cmi.notify_activate(self.object, dtime) + end +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/sound_handling.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/sound_handling.lua new file mode 100644 index 00000000..98d2644e --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/sound_handling.lua @@ -0,0 +1,59 @@ +local math_random = math.random + + +--generic call for sound handler for mobs (data access) +mobs.play_sound = function(self,sound) + local soundinfo = self.sounds + + if not soundinfo then + return + end + + local play_sound = soundinfo[sound] + + if not play_sound then + return + end + + mobs.play_sound_handler(self, play_sound) +end + + +--generic sound handler for mobs +mobs.play_sound_handler = function(self, sound) + local pitch = (100 + math_random(-15,15) + math_random()) / 100 + local distance = self.sounds.distance or 16 + + minetest.sound_play(sound, { + object = self.object, + gain = 1.0, + max_hear_distance = distance, + pitch = pitch, + }, true) +end + + +--random sound timing handler +mobs.random_sound_handling = function(self,dtime) + + self.random_sound_timer = self.random_sound_timer - dtime + + --play sound and reset timer + if self.random_sound_timer <= 0 then + mobs.play_sound(self,"random") + self.random_sound_timer = math_random(self.random_sound_timer_min,self.random_sound_timer_max) + end +end + +--used for playing a non-mob internal sound at random pitches +mobs.play_sound_specific = function(self,soundname) + local pitch = (100 + math_random(-15,15) + math_random()) / 100 + local distance = self.sounds.distance or 16 + + minetest.sound_play(soundname, { + object = self.object, + gain = 1.0, + max_hear_distance = distance, + pitch = pitch, + }, true) +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/mount.lua b/mods/ENTITIES/mcl_mobs/api/mount.lua similarity index 88% rename from mods/ENTITIES/mcl_mobs/mount.lua rename to mods/ENTITIES/mcl_mobs/api/mount.lua index 9383ee06..0ed54a46 100644 --- a/mods/ENTITIES/mcl_mobs/mount.lua +++ b/mods/ENTITIES/mcl_mobs/api/mount.lua @@ -1,8 +1,11 @@ -- lib_mount by Blert2112 (edited by TenPlus1) -local enable_crash = false -local crash_threshold = 6.5 -- ignored if enable_crash=false +--local enable_crash = false +--local crash_threshold = 6.5 -- ignored if enable_crash=false + +local math = math +local vector = vector ------------------------------------------------------------------------------ @@ -10,7 +13,7 @@ local crash_threshold = 6.5 -- ignored if enable_crash=false -- Helper functions -- -local node_ok = function(pos, fallback) +--[[local function node_ok(pos, fallback) fallback = fallback or mobs.fallback_node @@ -21,10 +24,10 @@ local node_ok = function(pos, fallback) end return {name = fallback} -end +end]] -local function node_is(pos) +--[[local function node_is(pos) local node = node_ok(pos) @@ -45,7 +48,7 @@ local function node_is(pos) end return "other" -end +end]] local function get_sign(i) @@ -60,13 +63,11 @@ local function get_sign(i) end -local function get_velocity(v, yaw, y) - +--[[local function get_velocity(v, yaw, y) local x = -math.sin(yaw) * v local z = math.cos(yaw) * v - return {x = x, y = y, z = z} -end +end]] local function get_v(v) @@ -172,7 +173,7 @@ function mobs.detach(player, offset) --pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z} - player:add_velocity(vector.new(math.random(-6,6),math.random(5,8),math.random(-6,6))) --throw the rider off + player:add_velocity(vector.new(math.random(-6,6), math.random(5,8), math.random(-6,6))) --throw the rider off --[[ minetest.after(0.1, function(name, pos) @@ -187,13 +188,13 @@ end function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) - local rot_view = 0 + --local rot_view = 0 - if entity.player_rotation.y == 90 then - rot_view = math.pi/2 - end + --if entity.player_rotation.y == 90 then + -- rot_view = math.pi/2 + --end - local acce_y = 0 + --local acce_y = 0 local velo = entity.object:get_velocity() entity.v = get_v(velo) * get_sign(entity.v) @@ -206,21 +207,30 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) -- move forwards if ctrl.up then - entity.v = entity.v + entity.accel / 10 + mobs.set_velocity(entity, entity.run_velocity) + + mobs.set_mob_animation(entity, moving_anim) -- move backwards elseif ctrl.down then - if entity.max_speed_reverse == 0 and entity.v == 0 then - return - end + mobs.set_velocity(entity, -entity.run_velocity) - entity.v = entity.v - entity.accel / 10 + mobs.set_mob_animation(entity, moving_anim) + + --halt + else + + mobs.set_velocity(entity, 0) + + mobs.set_mob_animation(entity, stand_anim) end - -- fix mob rotation + -- mob rotation entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate) + entity.yaw = entity.driver:get_look_horizontal() - entity.rotate + --[[ if can_fly then -- fly up @@ -244,32 +254,21 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) end else + ]]-- - -- jump - if ctrl.jump then + -- jump + if ctrl.jump then - if velo.y == 0 then - velo.y = velo.y + entity.jump_height - acce_y = acce_y + (acce_y * 3) + 1 - end - end - - end - end - - -- if not moving then set animation and return - if entity.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then - - if stand_anim then - mobs:set_animation(entity, stand_anim) + mobs.jump(entity) end - return + --end end + --[[ -- set moving animation if moving_anim then - mobs:set_animation(entity, moving_anim) + mobs:set_mob_animation(entity, moving_anim) end -- Stop! @@ -383,13 +382,17 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) end entity.v2 = v + ]]-- end -- directional flying routine by D00Med (edited by TenPlus1) function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim) - + if true then + print("succ") + return + end local ctrl = entity.driver:get_player_control() local velo = entity.object:get_velocity() local dir = entity.driver:get_look_dir() @@ -440,9 +443,9 @@ function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim) -- change animation if stopped if velo.x == 0 and velo.y == 0 and velo.z == 0 then - mobs:set_animation(entity, stand_anim) + mobs:set_mob_animation(entity, stand_anim) else -- moving animation - mobs:set_animation(entity, moving_anim) + mobs:set_mob_animation(entity, moving_anim) end end diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/api/spawning.lua similarity index 65% rename from mods/ENTITIES/mcl_mobs/spawning.lua rename to mods/ENTITIES/mcl_mobs/api/spawning.lua index ff52128d..bf07ca94 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/api/spawning.lua @@ -1,18 +1,33 @@ --lua locals -local get_node = minetest.get_node -local get_item_group = minetest.get_item_group -local get_node_light = minetest.get_node_light +local get_node = minetest.get_node +local get_item_group = minetest.get_item_group +local get_node_light = minetest.get_node_light local find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air -local new_vector = vector.new +local get_biome_name = minetest.get_biome_name +local get_objects_inside_radius = minetest.get_objects_inside_radius +local get_connected_players = minetest.get_connected_players + + local math_random = math.random -local get_biome_name = minetest.get_biome_name -local max = math.max -local get_objects_inside_radius = minetest.get_objects_inside_radius -local vector_distance = vector.distance +local math_floor = math.floor +--local max = math.max + +--local vector_distance = vector.distance +local vector_new = vector.new +local vector_floor = vector.floor + +local table_copy = table.copy +local table_remove = table.remove + +local pairs = pairs -- range for mob count -local aoc_range = 32 ---[[ +local aoc_range = 48 + +--do mobs spawn? +local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false + +--[[ THIS IS THE BIG LIST OF ALL BIOMES - used for programming/updating mobs @@ -153,29 +168,14 @@ Overworld regular: - -local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false --- count how many mobs of one type are inside an area - -local count_mobs = function(pos,mobtype) - print(mobtype) +-- count how many mobs are in an area +local function count_mobs(pos) local num = 0 - local objs = get_objects_inside_radius(pos, aoc_range) - for n = 1, #objs do - local obj = objs[n]:get_luaentity() - if obj and obj.name and obj._cmi_is_mob then - -- count hostile mobs only - if mobtype == "hostile" then - if obj.spawn_class == "hostile" then - num = num + 1 - end - -- count passive mobs only - else - num = num + 1 - end + for _,object in pairs(get_objects_inside_radius(pos, aoc_range)) do + if object and object:get_luaentity() and object:get_luaentity()._cmi_is_mob then + num = num + 1 end end - return num end @@ -194,7 +194,7 @@ end name: the mobs name -dimension: +dimension: "overworld" "nether" "end" @@ -244,8 +244,7 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh end --[[ - local spawn_action - spawn_action = function(pos, node, active_object_count, active_object_count_wider, name) + local function spawn_action(pos, node, active_object_count, active_object_count_wider, name) local orig_pos = table.copy(pos) -- is mob actually registered? @@ -282,7 +281,7 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh end -- if toggle set to nil then ignore day/night check - if day_toggle ~= nil then + if day_toggle then local tod = (minetest.get_timeofday() or 0) * 24000 @@ -372,7 +371,7 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh if minetest.registered_nodes[node_ok(pos2).name].walkable == true then -- inside block minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, too little space!") - if ent.spawn_small_alternative ~= nil and (not minetest.registered_nodes[node_ok(pos).name].walkable) then + if ent.spawn_small_alternative and (not minetest.registered_nodes[node_ok(pos).name].walkable) then minetest.log("info", "Trying to spawn smaller alternative mob: "..ent.spawn_small_alternative) spawn_action(orig_pos, node, active_object_count, active_object_count_wider, ent.spawn_small_alternative) end @@ -485,25 +484,26 @@ end local axis --inner and outer part of square donut radius -local inner = 1 -local outer = 65 +local inner = 15 +local outer = 64 local int = {-1,1} -local position_calculation = function(pos) - pos = vector.floor(pos) +local function position_calculation(pos) + + pos = vector_floor(pos) --this is used to determine the axis buffer from the player - axis = math.random(0,1) + axis = math_random(0,1) --cast towards the direction if axis == 0 then --x - pos.x = pos.x + math.random(inner,outer)*int[math.random(1,2)] - pos.z = pos.z + math.random(-outer,outer) + pos.x = pos.x + math_random(inner,outer)*int[math_random(1,2)] + pos.z = pos.z + math_random(-outer,outer) else --z - pos.z = pos.z + math.random(inner,outer)*int[math.random(1,2)] - pos.x = pos.x + math.random(-outer,outer) + pos.z = pos.z + math_random(inner,outer)*int[math_random(1,2)] + pos.x = pos.x + math_random(-outer,outer) end - return(pos) + return pos end --[[ @@ -517,7 +517,7 @@ local decypher_limits_dictionary = { local function decypher_limits(posy) --local min_max_table = decypher_limits_dictionary[dimension] --return min_max_table[1],min_max_table[2] - posy = math.floor(posy) + posy = math_floor(posy) return posy - 32, posy + 32 end @@ -531,7 +531,7 @@ local function biome_check(biome_list, biome_goal) return false end - + --todo mob limiting --MAIN LOOP @@ -540,108 +540,169 @@ if mobs_spawn then local timer = 0 minetest.register_globalstep(function(dtime) timer = timer + dtime - if timer >= 8 then + if timer >= 10 then timer = 0 - for _,player in pairs(minetest.get_connected_players()) do - for i = 1,math_random(3,8) do - repeat -- after this line each "break" means "continue" - local player_pos = player:get_pos() + for _,player in pairs(get_connected_players()) do + -- after this line each "break" means "continue" + local do_mob_spawning = true + repeat + --don't need to get these variables more than once + --they happen in a single server step - local _,dimension = mcl_worlds.y_to_layer(player_pos.y) + local player_pos = player:get_pos() + local dimension = mcl_worlds.pos_to_dimension(player_pos) - if dimension == "void" or dimension == "default" then - break -- ignore void and unloaded area - end - - local min,max = decypher_limits(player_pos.y) + if dimension == "void" or dimension == "default" then + break -- ignore void and unloaded area + end - local goal_pos = position_calculation(player_pos) - - local spawning_position_list = find_nodes_in_area_under_air(new_vector(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), {"group:solid", "group:water", "group:lava"}) + local min, max = decypher_limits(player_pos.y) + + for i = 1, math_random(1,4) do + -- after this line each "break" means "continue" + local do_mob_algorithm = true + repeat + + local goal_pos = position_calculation(player_pos) + + local spawning_position_list = find_nodes_in_area_under_air(vector_new(goal_pos.x,min,goal_pos.z), vector_new(goal_pos.x,max,goal_pos.z), {"group:solid", "group:water", "group:lava"}) + + --couldn't find node + if #spawning_position_list <= 0 then + break + end + + local spawning_position = spawning_position_list[math_random(1,#spawning_position_list)] + + --Prevent strange behavior --- this is commented out: /too close to player --fixed with inner circle + if not spawning_position then -- or vector_distance(player_pos, spawning_position) < 15 + break + end + + --hard code mob limit in area to 5 for now + if count_mobs(spawning_position) >= 5 then + break + end + + local gotten_node = get_node(spawning_position).name + + if not gotten_node or gotten_node == "air" then --skip air nodes + break + end + + local gotten_biome = minetest.get_biome_data(spawning_position) + + if not gotten_biome then + break --skip if in unloaded area + end + + gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with + + --add this so mobs don't spawn inside nodes + spawning_position.y = spawning_position.y + 1 + + --only need to poll for node light if everything else worked + local gotten_light = get_node_light(spawning_position) + + local is_water = get_item_group(gotten_node, "water") ~= 0 + local is_lava = get_item_group(gotten_node, "lava") ~= 0 + + local mob_def = nil + + --create a disconnected clone of the spawn dictionary + --prevents memory leak + local mob_library_worker_table = table_copy(spawn_dictionary) + + --grab mob that fits into the spawning location + --randomly grab a mob, don't exclude any possibilities + local repeat_mob_search = true + repeat + + --do not infinite loop + if #mob_library_worker_table <= 0 then + --print("breaking infinite loop") + break + end + + local skip = false + + --use this for removing table elements of mobs that do not match + local temp_index = math_random(1,#mob_library_worker_table) + + local temp_def = mob_library_worker_table[temp_index] + + --skip if something ridiculous happens (nil mob def) + --something truly horrible has happened if skip gets + --activated at this point + if not temp_def then + skip = true + end + + if not skip and (spawning_position.y < temp_def.min_height or spawning_position.y > temp_def.max_height) then + skip = true + end + + --skip if not correct dimension + if not skip and (temp_def.dimension ~= dimension) then + skip = true + end + + --skip if not in correct biome + if not skip and (not biome_check(temp_def.biomes, gotten_biome)) then + skip = true + end + + --don't spawn if not in light limits + if not skip and (gotten_light < temp_def.min_light or gotten_light > temp_def.max_light) then + skip = true + end + + --skip if not in correct spawning type + if not skip and (temp_def.type_of_spawning == "ground" and is_water) then + skip = true + end + + if not skip and (temp_def.type_of_spawning == "ground" and is_lava) then + skip = true + end + + --found a mob, exit out of loop + if not skip then + --minetest.log("warning", "found mob:"..temp_def.name) + --print("found mob:"..temp_def.name) + mob_def = table_copy(temp_def) + break + else + --minetest.log("warning", "deleting temp index "..temp_index) + --print("deleting temp index") + table_remove(mob_library_worker_table, temp_index) + end + + until repeat_mob_search == false --this is needed to sort through mobs randomly + + + --catch if went through all mobs and something went horribly wrong + --could not find a valid mob to spawn that fits the environment + if not mob_def then + break + end + + --adjust the position for water and lava mobs + if mob_def.type_of_spawning == "water" or mob_def.type_of_spawning == "lava" then + spawning_position.y = spawning_position.y - 1 + end + + --print("spawning: " .. mob_def.name) + + --everything is correct, spawn mob + minetest.add_entity(spawning_position, mob_def.name) - --couldn't find node - if #spawning_position_list <= 0 then break - end + until do_mob_algorithm == false --this is a safety catch + end - local spawning_position = spawning_position_list[math_random(1,#spawning_position_list)] - - --Prevent strange behavior/too close to player - if not spawning_position or vector_distance(player_pos, spawning_position) < 15 then - break - end - - local gotten_node = get_node(spawning_position).name - - if not gotten_node or gotten_node == "air" then --skip air nodes - break - end - - local gotten_biome = minetest.get_biome_data(spawning_position) - - if not gotten_biome then - break --skip if in unloaded area - end - - gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with - - --grab random mob - local mob_def = spawn_dictionary[math.random(1,#spawn_dictionary)] - - if not mob_def then - break --skip if something ridiculous happens (nil mob def) - end - - --skip if not correct dimension - if mob_def.dimension ~= dimension then - break - end - - --skip if not in correct biome - if not biome_check(mob_def.biomes, gotten_biome) then - break - end - - --add this so mobs don't spawn inside nodes - spawning_position.y = spawning_position.y + 1 - - if spawning_position.y < mob_def.min_height or spawning_position.y > mob_def.max_height then - break - end - - --only need to poll for node light if everything else worked - local gotten_light = get_node_light(spawning_position) - - --don't spawn if not in light limits - if gotten_light < mob_def.min_light or gotten_light > mob_def.max_light then - break - end - - local is_water = get_item_group(gotten_node, "water") ~= 0 - local is_lava = get_item_group(gotten_node, "lava") ~= 0 - - if mob_def.type_of_spawning == "ground" and is_water then - break - end - - if mob_def.type_of_spawning == "ground" and is_lava then - break - end - - --finally do the heavy check (for now) of mobs in area - if count_mobs(spawning_position, mob_def.spawn_class) >= mob_def.aoc then - break - end - - --adjust the position for water and lava mobs - if mob_def.type_of_spawning == "water" or mob_def.type_of_spawning == "lava" then - spawning_position.y = spawning_position.y - 1 - end - - --everything is correct, spawn mob - minetest.add_entity(spawning_position, mob_def.name) - until true --this is a safety catch - end + break + until do_mob_spawning == false --this is a performance catch end end end) diff --git a/mods/ENTITIES/mcl_mobs/crafts.lua b/mods/ENTITIES/mcl_mobs/crafts.lua index e8a5b60f..2b23c6f5 100644 --- a/mods/ENTITIES/mcl_mobs/crafts.lua +++ b/mods/ENTITIES/mcl_mobs/crafts.lua @@ -1,5 +1,5 @@ -local S = minetest.get_translator("mcl_mobs") +local S = minetest.get_translator(minetest.get_current_modname()) -- name tag minetest.register_craftitem("mcl_mobs:nametag", { diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index 69246b47..b0daba2c 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -1,14 +1,16 @@ local path = minetest.get_modpath(minetest.get_current_modname()) +local api_path = path.."/api" + -- Mob API -dofile(path .. "/api.lua") +dofile(api_path .. "/api.lua") -- Spawning Algorithm -dofile(path .. "/spawning.lua") +dofile(api_path .. "/spawning.lua") -- Rideable Mobs -dofile(path .. "/mount.lua") +dofile(api_path .. "/mount.lua") -- Mob Items dofile(path .. "/crafts.lua") \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/lucky_block.lua b/mods/ENTITIES/mcl_mobs/lucky_block.lua deleted file mode 100644 index ea90de74..00000000 --- a/mods/ENTITIES/mcl_mobs/lucky_block.lua +++ /dev/null @@ -1,8 +0,0 @@ - -if minetest.get_modpath("lucky_block") then - - lucky_block:add_blocks({ - {"dro", {"mcl_mobs:nametag"}, 1}, - {"lig"}, - }) -end diff --git a/mods/ENTITIES/mcl_mobs/mod.conf b/mods/ENTITIES/mcl_mobs/mod.conf index 0d622f6a..2a91a776 100644 --- a/mods/ENTITIES/mcl_mobs/mod.conf +++ b/mods/ENTITIES/mcl_mobs/mod.conf @@ -2,4 +2,4 @@ name = mcl_mobs author = PilzAdam description = Adds a mob API for mods to add animals or monsters, etc. depends = mcl_particles -optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience +optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience diff --git a/mods/ENTITIES/mcl_mobs/sounds/attributes.txt b/mods/ENTITIES/mcl_mobs/sounds/attributes.txt new file mode 100644 index 00000000..1228dd9d --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/sounds/attributes.txt @@ -0,0 +1,4 @@ + +default_punch.1 = https://freesound.org/people/Merrick079/sounds/566436/ +default_punch.2 = https://freesound.org/people/Merrick079/sounds/566435/ +default_punch.3 = https://freesound.org/people/Merrick079/sounds/566434/ diff --git a/mods/ENTITIES/mcl_mobs/sounds/default_punch.1.ogg b/mods/ENTITIES/mcl_mobs/sounds/default_punch.1.ogg new file mode 100644 index 00000000..4d7ba801 Binary files /dev/null and b/mods/ENTITIES/mcl_mobs/sounds/default_punch.1.ogg differ diff --git a/mods/ENTITIES/mcl_mobs/sounds/default_punch.2.ogg b/mods/ENTITIES/mcl_mobs/sounds/default_punch.2.ogg new file mode 100644 index 00000000..c022d94f Binary files /dev/null and b/mods/ENTITIES/mcl_mobs/sounds/default_punch.2.ogg differ diff --git a/mods/ENTITIES/mcl_mobs/sounds/default_punch.3.ogg b/mods/ENTITIES/mcl_mobs/sounds/default_punch.3.ogg new file mode 100644 index 00000000..4c5e3f9b Binary files /dev/null and b/mods/ENTITIES/mcl_mobs/sounds/default_punch.3.ogg differ diff --git a/mods/ENTITIES/mcl_mobs/sounds/default_punch.ogg b/mods/ENTITIES/mcl_mobs/sounds/default_punch.ogg deleted file mode 100644 index 28a500bf..00000000 Binary files a/mods/ENTITIES/mcl_mobs/sounds/default_punch.ogg and /dev/null differ diff --git a/mods/ENTITIES/mcl_mobs/todo.txt b/mods/ENTITIES/mcl_mobs/todo.txt new file mode 100644 index 00000000..7598b14e --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/todo.txt @@ -0,0 +1 @@ +--use vector.distance to count down mob despawn timer \ No newline at end of file diff --git a/mods/ENTITIES/mcl_paintings/init.lua b/mods/ENTITIES/mcl_paintings/init.lua index cb85ee5f..26bd2c61 100644 --- a/mods/ENTITIES/mcl_paintings/init.lua +++ b/mods/ENTITIES/mcl_paintings/init.lua @@ -1,12 +1,15 @@ mcl_paintings = {} -dofile(minetest.get_modpath(minetest.get_current_modname()).."/paintings.lua") +local modname = minetest.get_current_modname() +dofile(minetest.get_modpath(modname).."/paintings.lua") -local S = minetest.get_translator("mcl_paintings") +local S = minetest.get_translator(modname) + +local math = math local wood = "[combine:16x16:-192,0=mcl_paintings_paintings.png" -local is_protected = function(pos, name) +local function is_protected(pos, name) if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) return true @@ -17,7 +20,7 @@ end -- Check if there's a painting for provided painting size. -- If yes, returns the arguments. -- If not, returns the next smaller available painting. -local shrink_painting = function(x, y) +local function shrink_painting(x, y) if x > 4 or y > 4 then return nil end @@ -43,7 +46,7 @@ local shrink_painting = function(x, y) end end -local get_painting = function(x, y, motive) +local function get_painting(x, y, motive) local painting = mcl_paintings.paintings[y] and mcl_paintings.paintings[y][x] and mcl_paintings.paintings[y][x][motive] if not painting then return nil @@ -53,7 +56,7 @@ local get_painting = function(x, y, motive) return "[combine:"..sx.."x"..sy..":"..px..","..py.."=mcl_paintings_paintings.png" end -local get_random_painting = function(x, y) +local function get_random_painting(x, y) if not mcl_paintings.paintings[y] or not mcl_paintings.paintings[y][x] then return nil end @@ -65,7 +68,7 @@ local get_random_painting = function(x, y) return get_painting(x, y, r), r end -local size_to_minmax = function(size) +--[[local function size_to_minmax(size) local min, max if size == 2 then min = -0.5 @@ -81,13 +84,13 @@ local size_to_minmax = function(size) max = 0.5 end return min, max -end +end]] -local size_to_minmax_entity = function(size) +local function size_to_minmax_entity(size) return -size/2, size/2 end -local set_entity = function(object) +local function set_entity(object) local ent = object:get_luaentity() local wallm = ent._facing local xsize = ent._xsize @@ -169,7 +172,7 @@ minetest.register_entity("mcl_paintings:painting", { on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) -- Drop as item on punch if puncher and puncher:is_player() then - kname = puncher:get_player_name() + local kname = puncher:get_player_name() local pos = self._pos if not pos then pos = self.object:get_pos() diff --git a/mods/ENTITIES/mcl_paintings/paintings.lua b/mods/ENTITIES/mcl_paintings/paintings.lua index d606306c..ccf58436 100644 --- a/mods/ENTITIES/mcl_paintings/paintings.lua +++ b/mods/ENTITIES/mcl_paintings/paintings.lua @@ -3,7 +3,7 @@ local TS = 16 -- texture size mcl_paintings.paintings = { [1] = { [1] = { - { cx = 0, cy = 0 }, + { cx = 0, cy = 0 }, { cx = TS, cy = 0 }, { cx = 2*TS, cy = 0 }, { cx = 3*TS, cy = 0 }, @@ -26,7 +26,7 @@ mcl_paintings.paintings = { { cx = 0, cy = 4*TS }, { cx = TS, cy = 4*TS }, }, - [2] = { + [2] = { { cx = 0, cy = 8*TS }, { cx = 2*TS, cy = 8*TS }, { cx = 4*TS, cy = 8*TS }, @@ -35,7 +35,7 @@ mcl_paintings.paintings = { { cx = 10*TS, cy = 8*TS }, }, [3] = 2, - [4] = { + [4] = { { cx = 0, cy = 6*TS }, }, }, diff --git a/mods/ENTITIES/mobs_mc/0_gameconfig.lua b/mods/ENTITIES/mobs_mc/0_gameconfig.lua index c92ccbba..f21d946f 100644 --- a/mods/ENTITIES/mobs_mc/0_gameconfig.lua +++ b/mods/ENTITIES/mobs_mc/0_gameconfig.lua @@ -15,7 +15,7 @@ with name "mobs_mc_gameconfig". ]] -- Set to false in your gameconfig mod if you create your own monster egg nodes. mobs_mc.create_monster_egg_nodes = true -mobs_mc.items = {} +--mobs_mc.items = {} mobs_mc.items = { -- Items defined in mobs_mc @@ -81,7 +81,9 @@ mobs_mc.items = { gunpowder = "tnt:gunpowder", flint_and_steel = "fire:flint_and_steel", water_source = "default:water_source", + water_flowing = "default:water_flowing", river_water_source = "default:river_water_source", + --water_flowing = "default:river_water_flowing", black_dye = "dye:black", poppy = "flowers:rose", dandelion = "flowers:dandelion_yellow", @@ -126,7 +128,6 @@ mobs_mc.items = { nether_portal = "nether:portal", netherrack = "nether:rack", - nether_brick_block = "nether:brick", -- Wool (Minecraft color scheme) wool_white = "wool:white", diff --git a/mods/ENTITIES/mobs_mc/1_items_default.lua b/mods/ENTITIES/mobs_mc/1_items_default.lua index b4abd4f9..c8ac421c 100644 --- a/mods/ENTITIES/mobs_mc/1_items_default.lua +++ b/mods/ENTITIES/mobs_mc/1_items_default.lua @@ -8,7 +8,7 @@ -- NOTE: Most strings intentionally not marked for translation, other mods already have these items. -- TODO: Remove this file eventually, most items are already outsourced in other mods. -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local c = mobs_mc.is_item_variable_overridden @@ -234,8 +234,8 @@ end if c("ender_eye") and c("blaze_powder") and c("blaze_rod") then minetest.register_craft({ type = "shapeless", - output = 'mobs_mc:ender_eye', - recipe = { 'mobs_mc:blaze_powder', 'mobs_mc:blaze_rod'}, + output = "mobs_mc:ender_eye", + recipe = { "mobs_mc:blaze_powder", "mobs_mc:blaze_rod"}, }) end @@ -516,8 +516,6 @@ end -- Evoker if c("totem") then - local hud_totem = {} - -- Totem of Undying minetest.register_craftitem("mobs_mc:totem", { description = S("Totem of Undying"), @@ -527,66 +525,8 @@ if c("totem") then inventory_image = "mcl_totems_totem.png", wield_image = "mcl_totems_totem.png", stack_max = 1, + groups = {combat_item=1}, }) - - minetest.register_on_leaveplayer(function(player) - hud_totem[player:get_player_name()] = nil - end) - - -- Save the player from death when holding totem of undying in hand - minetest.register_on_player_hpchange(function(player, hp_change) - local hp = player:get_hp() - -- Fatal damage? - if hp + hp_change <= 0 then - local wield = player:get_wielded_item() - if wield:get_name() == "mobs_mc:totem" then - local ppos = player: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 - if pnname == mobs_mc.misc.totem_fail_nodes[n] then - return hp_change - end - end - -- Reset breath as well - if player:get_breath() < 11 then - player:set_breath(10) - end - if not minetest.is_creative_enabled(player:get_player_name()) then - wield:take_item() - player:set_wielded_item(wield) - end - -- Effects - minetest.sound_play({name = "mcl_totems_totem", gain=1}, {pos=ppos, max_hear_distance=16}, true) - - -- Big totem overlay - if not hud_totem[player:get_player_name()] then - hud_totem[player:get_player_name()] = player: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 }, - z_index = 100, - }) - minetest.after(3, function(name) - local player = minetest.get_player_by_name(name) - if player and player:is_player() then - local name = player:get_player_name() - if hud_totem[name] then - player:hud_remove(hud_totem[name]) - hud_totem[name] = nil - end - end - end, player:get_player_name()) - end - - -- Set HP to exactly 1 - return -hp + 1 - end - end - return hp_change - end, true) end -- Rotten flesh diff --git a/mods/ENTITIES/mobs_mc/2_throwing.lua b/mods/ENTITIES/mobs_mc/2_throwing.lua index 23ae86d8..d97351ac 100644 --- a/mods/ENTITIES/mobs_mc/2_throwing.lua +++ b/mods/ENTITIES/mobs_mc/2_throwing.lua @@ -6,7 +6,7 @@ -- NOTE: Strings intentionally not marked for translation, other mods already have these items. -- TODO: Remove this file eventually, all items here are already outsourced in other mods. -local S = minetest.get_translator("mobs_mc") +--local S = minetest.get_translator(minetest.get_current_modname()) --maikerumines throwing code --arrow (weapon) @@ -83,7 +83,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) if self.timer>0.2 then local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5) for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then + if obj:get_luaentity() then if obj:get_luaentity().name ~= "mobs_mc:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then local damage = 3 minetest.sound_play("damage", {pos = pos}, true) @@ -108,7 +108,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) if self.lastpos.x~=nil then if node.name ~= "air" then minetest.sound_play("bowhit1", {pos = pos}, true) - minetest.add_item(self.lastpos, 'mobs_mc:arrow') + minetest.add_item(self.lastpos, "mobs_mc:arrow") self.object:remove() end end @@ -155,7 +155,7 @@ end if c("arrow") and c("flint") and c("feather") and c("stick") then minetest.register_craft({ - output = 'mobs_mc:arrow 4', + output = "mobs_mc:arrow 4", recipe = { {mobs_mc.items.flint}, {mobs_mc.items.stick}, @@ -181,11 +181,11 @@ if c("bow") then }) minetest.register_craft({ - output = 'mobs_mc:bow_wood', + output = "mobs_mc:bow_wood", recipe = { - {mobs_mc.items.string, mobs_mc.items.stick, ''}, - {mobs_mc.items.string, '', mobs_mc.items.stick}, - {mobs_mc.items.string, mobs_mc.items.stick, ''}, + {mobs_mc.items.string, mobs_mc.items.stick, ""}, + {mobs_mc.items.string, "", mobs_mc.items.stick}, + {mobs_mc.items.string, mobs_mc.items.stick, ""}, } }) end @@ -259,7 +259,7 @@ if c("egg") then }) -- shoot egg - local mobs_shoot_egg = function (item, player, pointed_thing) + local function mobs_shoot_egg(item, player, pointed_thing) local playerpos = player:get_pos() @@ -349,7 +349,7 @@ mobs:register_arrow("mobs_mc:snowball_entity", { if c("snowball") then -- shoot snowball - local mobs_shoot_snowball = function (item, player, pointed_thing) + local function mobs_shoot_snowball(item, player, pointed_thing) local playerpos = player:get_pos() diff --git a/mods/ENTITIES/mobs_mc/4_heads.lua b/mods/ENTITIES/mobs_mc/4_heads.lua index 01b8ee57..ecd09ee0 100644 --- a/mods/ENTITIES/mobs_mc/4_heads.lua +++ b/mods/ENTITIES/mobs_mc/4_heads.lua @@ -3,8 +3,9 @@ -- NOTE: Strings intentionally not marked for translation, other mods already have these items. -- TODO: Remove this file eventually, all items here are already outsourced in other mods. +-- TODO: Add translation. -local S = minetest.get_translator("mobs_mc") +--local S = local S = minetest.get_translator(minetest.get_current_modname()) -- Heads system diff --git a/mods/ENTITIES/mobs_mc/agent.lua b/mods/ENTITIES/mobs_mc/agent.lua index cc9910ee..8475f92f 100644 --- a/mods/ENTITIES/mobs_mc/agent.lua +++ b/mods/ENTITIES/mobs_mc/agent.lua @@ -2,7 +2,7 @@ --################### AGENT - seemingly unused --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:agent", { type = "npc", diff --git a/mods/ENTITIES/mobs_mc/bat.lua b/mods/ENTITIES/mobs_mc/bat.lua index 677b96aa..5492add7 100644 --- a/mods/ENTITIES/mobs_mc/bat.lua +++ b/mods/ENTITIES/mobs_mc/bat.lua @@ -1,12 +1,16 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:bat", { + description = S("Bat"), type = "animal", spawn_class = "ambient", can_despawn = true, passive = true, + rotate = 270, + tilt_fly = true, + fly = true, hp_min = 6, hp_max = 6, collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.89, 0.25}, @@ -44,9 +48,7 @@ mobs:register_mob("mobs_mc:bat", { fall_damage = 0, view_range = 16, fear_height = 0, - jump = false, - fly = true, makes_footstep_sound = false, }) diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index 847e2f4a..0f62c538 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -3,7 +3,7 @@ -- Model and mobs_blaze.png see https://github.com/22i/minecraft-voxel-blender-models -hi 22i ~jordan4ibanez -- blaze.lua partial copy of mobs_mc/ghast.lua -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### BLAZE @@ -11,12 +11,16 @@ local S = minetest.get_translator("mobs_mc") mobs:register_mob("mobs_mc:blaze", { + description = S("Blaze"), type = "monster", spawn_class = "hostile", hp_min = 20, hp_max = 20, xp_min = 10, xp_max = 10, + tilt_fly = false, + hostile = true, + --rotate = 270, collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.79, 0.3}, rotate = -180, visual = "mesh", @@ -35,7 +39,7 @@ mobs:register_mob("mobs_mc:blaze", { walk_velocity = .8, run_velocity = 1.6, damage = 6, - reach = 2, + reach = 4, -- don't want blaze getting too close pathfinding = 1, drops = { {name = mobs_mc.items.blaze_rod, @@ -63,7 +67,7 @@ mobs:register_mob("mobs_mc:blaze", { fall_speed = -2.25, light_damage = 0, view_range = 16, - attack_type = "dogshoot", + attack_type = "projectile", arrow = "mobs_mc:blaze_fireball", shoot_interval = 3.5, shoot_offset = 1.0, @@ -75,9 +79,18 @@ mobs:register_mob("mobs_mc:blaze", { fear_height = 0, glow = 14, fire_resistant = true, + eye_height = 0.75, + projectile_cooldown_min = 2, + projectile_cooldown_max = 3, + shoot_arrow = function(self, pos, dir) + -- 2-4 damage per arrow + local dmg = math.random(2,4) + mobs.shoot_projectile_handling("mobs_mc:blaze_fireball", pos, dir, self.object:get_yaw(), self.object, 7, dmg,nil,nil,nil,-0.4) + end, + do_custom = function(self) - if self.state == "attack" and vector.distance(self.object:get_pos(), self.attack:get_pos()) < 1.2 then - mcl_burning.set_on_fire(self.attack, 5) + if self.attacking and self.state == "attack" and vector.distance(self.object:get_pos(), self.attacking:get_pos()) < 1.2 then + mcl_burning.set_on_fire(self.attacking, 5) end local pos = self.object:get_pos() minetest.add_particle({ @@ -147,16 +160,19 @@ mobs:register_arrow("mobs_mc:blaze_fireball", { visual_size = {x = 0.3, y = 0.3}, textures = {"mcl_fire_fire_charge.png"}, velocity = 15, + speed = 5, + tail = 1, + tail_texture = "mobs_mc_spit.png^[colorize:black:255", --repurpose spit texture + tail_size = 2, + tail_distance_divider = 3, + _is_fireball = true, -- Direct hit, no fire... just plenty of pain hit_player = function(self, player) - if rawget(_G, "armor") and armor.last_damage_types then - armor.last_damage_types[player:get_player_name()] = "fireball" - end - mcl_burning.set_on_fire(player, 5, "blaze") + mcl_burning.set_on_fire(player, 5) player:punch(self.object, 1.0, { full_punch_interval = 1.0, - damage_groups = {fleshy = 5}, + damage_groups = {fleshy = self._damage}, }, nil) end, @@ -164,7 +180,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", { mcl_burning.set_on_fire(mob, 5) mob:punch(self.object, 1.0, { full_punch_interval = 1.0, - damage_groups = {fleshy = 5}, + damage_groups = {fleshy = self._damage}, }, nil) end, @@ -179,7 +195,9 @@ mobs:register_arrow("mobs_mc:blaze_fireball", { -- Node hit, make fire hit_node = function(self, pos, node) - if node.name == "air" then + if node.name ~= "air" then + local pos_above = table.copy(pos) + pos_above.y = pos_above.y + 1 minetest.set_node(pos_above, {name=mobs_mc.items.fire}) else local v = self.object:get_velocity() diff --git a/mods/ENTITIES/mobs_mc/chicken.lua b/mods/ENTITIES/mobs_mc/chicken.lua index 246bf216..ffaebca2 100644 --- a/mods/ENTITIES/mobs_mc/chicken.lua +++ b/mods/ENTITIES/mobs_mc/chicken.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### CHICKEN @@ -9,6 +9,7 @@ local S = minetest.get_translator("mobs_mc") mobs:register_mob("mobs_mc:chicken", { + description = S("Chicken"), type = "animal", spawn_class = "passive", @@ -17,7 +18,8 @@ mobs:register_mob("mobs_mc:chicken", { xp_min = 1, xp_max = 3, collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.69, 0.2}, - runaway = true, + skittish = true, + fall_slow = true, floats = 1, visual = "mesh", mesh = "mobs_mc_chicken.b3d", @@ -25,9 +27,10 @@ mobs:register_mob("mobs_mc:chicken", { {"mobs_mc_chicken.png"}, }, visual_size = {x=2.2, y=2.2}, - + rotate = 270, makes_footstep_sound = true, walk_velocity = 1, + run_velocity = 3, drops = { {name = mobs_mc.items.chicken_raw, chance = 1, @@ -63,14 +66,25 @@ mobs:register_mob("mobs_mc:chicken", { run_start = 0, run_end = 40, }, - follow = mobs_mc.follow.chicken, + follow = "mcl_farming:wheat_seeds", + breed_distance = 1.5, + baby_size = 0.5, + follow_distance = 2, view_range = 16, fear_height = 4, + --why do chickend breed if they lay eggs?? on_rightclick = function(self, clicker) - if mobs:feed_tame(self, clicker, 1, true, true) then return end - if mobs:protect(self, clicker) then return end - if mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end end, do_custom = function(self, dtime) @@ -95,37 +109,83 @@ mobs:register_mob("mobs_mc:chicken", { gain = 1.0, max_hear_distance = 16, }, true) - end, - + end, + + --head code + has_head = true, + head_bone = "head", + + swap_y_with_x = false, + reverse_head_yaw = false, + + head_bone_pos_y = 1.675, + head_bone_pos_z = 0, + + head_height_offset = 0.55, + head_direction_offset = 0.0925, + + head_pitch_modifier = -math.pi/2, + --end head code }) --spawn mobs:spawn_specific( -"mobs_mc:chicken", -"overworld", +"mobs_mc:chicken", +"overworld", "ground", { -"FlowerForest", -"Swampland", -"Taiga", -"ExtremeHills", -"BirchForest", -"MegaSpruceTaiga", -"MegaTaiga", -"ExtremeHills+", -"Forest", -"Plains", -"ColdTaiga", -"SunflowerPlains", -"RoofedForest", -"MesaPlateauFM_grasstop", -"ExtremeHillsM", -"BirchForestM", + "FlowerForest_beach", + "Forest_beach", + "StoneBeach", + "ColdTaiga_beach_water", + "Taiga_beach", + "Savanna_beach", + "Plains_beach", + "ExtremeHills_beach", + "ColdTaiga_beach", + "Swampland_shore", + "JungleM_shore", + "Jungle_shore", + "MesaPlateauFM_sandlevel", + "MesaPlateauF_sandlevel", + "MesaBryce_sandlevel", + "Mesa_sandlevel", + "Mesa", + "FlowerForest", + "Swampland", + "Taiga", + "ExtremeHills", + "Jungle", + "Savanna", + "BirchForest", + "MegaSpruceTaiga", + "MegaTaiga", + "ExtremeHills+", + "Forest", + "Plains", + "Desert", + "ColdTaiga", + "IcePlainsSpikes", + "SunflowerPlains", + "IcePlains", + "RoofedForest", + "ExtremeHills+_snowtop", + "MesaPlateauFM_grasstop", + "JungleEdgeM", + "ExtremeHillsM", + "JungleM", + "BirchForestM", + "MesaPlateauF", + "MesaPlateauFM", + "MesaPlateauF_grasstop", + "MesaBryce", + "JungleEdge", + "SavannaM", }, -9, -minetest.LIGHT_MAX+1, -30, 17000, -3, +9, +minetest.LIGHT_MAX+1, +30, 17000, +3, mobs_mc.spawn_height.water, mobs_mc.spawn_height.overworld_max) diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 48fcc819..17c4e1e6 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -1,14 +1,16 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local cow_def = { + description = S("Cow"), type = "animal", spawn_class = "passive", hp_min = 10, hp_max = 10, xp_min = 1, xp_max = 3, + rotate = 270, collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.39, 0.45}, visual = "mesh", mesh = "mobs_mc_cow.b3d", @@ -19,6 +21,7 @@ local cow_def = { visual_size = {x=2.8, y=2.8}, makes_footstep_sound = true, walk_velocity = 1, + run_velocity = 3, drops = { {name = mobs_mc.items.beef_raw, chance = 1, @@ -31,7 +34,7 @@ local cow_def = { max = 2, looting = "common",}, }, - runaway = true, + skittish = true, sounds = { random = "mobs_mc_cow", damage = "mobs_mc_cow_hurt", @@ -43,15 +46,20 @@ local cow_def = { stand_speed = 25, walk_speed = 40, run_speed = 60, stand_start = 0, stand_end = 0, walk_start = 0, - walk_end = 40, run_start = 0, + walk_end = 40, run_start = 0, run_end = 40, }, - follow = mobs_mc.follow.cow, + --follow = mobs_mc.follow.cow, on_rightclick = function(self, clicker) - if mobs:feed_tame(self, clicker, 1, true, true) then return end - if mobs:protect(self, clicker) then return end - if self.child then + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) return end @@ -70,27 +78,49 @@ local cow_def = { end return end - mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) end, + breed_distance = 1.5, + baby_size = 0.5, + follow_distance = 2, follow = mobs_mc.items.wheat, view_range = 10, fear_height = 4, + + --head code + has_head = true, + head_bone = "head", + + swap_y_with_x = false, + reverse_head_yaw = false, + + head_bone_pos_y = 3.6, + head_bone_pos_z = -0.6, + + head_height_offset = 1.0525, + head_direction_offset = 0.5, + head_pitch_modifier = 0, + --end head code } mobs:register_mob("mobs_mc:cow", cow_def) -- Mooshroom local mooshroom_def = table.copy(cow_def) - +mooshroom_def.description = S("Mooshroom") mooshroom_def.mesh = "mobs_mc_cow.b3d" mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } } mooshroom_def.on_rightclick = function(self, clicker) - if mobs:feed_tame(self, clicker, 1, true, true) then return end - if mobs:protect(self, clicker) then return end - - if self.child then + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then return end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end + local item = clicker:get_wielded_item() -- Use shears to get mushrooms and turn mooshroom into cow if item:get_name() == mobs_mc.items.shears then @@ -139,7 +169,6 @@ mooshroom_def.on_rightclick = function(self, clicker) minetest.add_item(pos, {name = mobs_mc.items.mushroom_stew}) end end - mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) end mobs:register_mob("mobs_mc:mooshroom", mooshroom_def) @@ -147,50 +176,81 @@ mobs:register_mob("mobs_mc:mooshroom", mooshroom_def) -- Spawning mobs:spawn_specific( "mobs_mc:cow", -"overworld", +"overworld", "ground", { -"FlowerForest", -"Swampland", -"Taiga", -"ExtremeHills", -"BirchForest", -"MegaSpruceTaiga", -"MegaTaiga", -"ExtremeHills+", -"Forest", -"Plains", -"ColdTaiga", -"SunflowerPlains", -"RoofedForest", -"MesaPlateauFM_grasstop", -"ExtremeHillsM", -"BirchForestM", + "FlowerForest_beach", + "Forest_beach", + "StoneBeach", + "ColdTaiga_beach_water", + "Taiga_beach", + "Savanna_beach", + "Plains_beach", + "ExtremeHills_beach", + "ColdTaiga_beach", + "Swampland_shore", + "JungleM_shore", + "Jungle_shore", + "MesaPlateauFM_sandlevel", + "MesaPlateauF_sandlevel", + "MesaBryce_sandlevel", + "Mesa_sandlevel", + "Mesa", + "FlowerForest", + "Swampland", + "Taiga", + "ExtremeHills", + "Jungle", + "Savanna", + "BirchForest", + "MegaSpruceTaiga", + "MegaTaiga", + "ExtremeHills+", + "Forest", + "Plains", + "Desert", + "ColdTaiga", + "IcePlainsSpikes", + "SunflowerPlains", + "IcePlains", + "RoofedForest", + "ExtremeHills+_snowtop", + "MesaPlateauFM_grasstop", + "JungleEdgeM", + "ExtremeHillsM", + "JungleM", + "BirchForestM", + "MesaPlateauF", + "MesaPlateauFM", + "MesaPlateauF_grasstop", + "MesaBryce", + "JungleEdge", + "SavannaM", }, -9, -minetest.LIGHT_MAX+1, -30, -17000, -10, -mobs_mc.spawn_height.water, +9, +minetest.LIGHT_MAX+1, +30, +17000, +10, +mobs_mc.spawn_height.water, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific( -"mobs_mc:mooshroom", -"overworld", +"mobs_mc:mooshroom", +"overworld", "ground", { "MushroomIslandShore", "MushroomIsland" }, -9, -minetest.LIGHT_MAX+1, -30, -17000, -5, -mobs_mc.spawn_height.overworld_min, +9, +minetest.LIGHT_MAX+1, +30, +17000, +5, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- spawn egg diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index 0c884d56..999cc5f2 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### CREEPER @@ -12,6 +12,8 @@ local S = minetest.get_translator("mobs_mc") mobs:register_mob("mobs_mc:creeper", { type = "monster", spawn_class = "hostile", + hostile = true, + rotate = 270, hp_min = 20, hp_max = 20, xp_min = 5, @@ -33,28 +35,44 @@ mobs:register_mob("mobs_mc:creeper", { explode = "tnt_explode", distance = 16, }, - makes_footstep_sound = true, + makes_footstep_sound = false, walk_velocity = 1.05, - run_velocity = 2.1, + run_velocity = 3.25, runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" }, attack_type = "explode", - + eye_height = 1.25, --hssssssssssss explosion_strength = 3, - explosion_radius = 3.5, - explosion_damage_radius = 3.5, - explosiontimer_reset_radius = 6, - reach = 3, - explosion_timer = 1.5, + --explosion_radius = 3, + --explosion_damage_radius = 6, + --explosiontimer_reset_radius = 6, + reach = 1.5, + defuse_reach = 4, + explosion_timer = 0.3, allow_fuse_reset = true, stop_to_explode = true, + --head code + has_head = true, + head_bone = "head", + + swap_y_with_x = true, + reverse_head_yaw = true, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + -- Force-ignite creeper with flint and steel and explode after 1.5 seconds. -- TODO: Make creeper flash after doing this as well. -- TODO: Test and debug this code. on_rightclick = function(self, clicker) - if self._forced_explosion_countdown_timer ~= nil then + if self._forced_explosion_countdown_timer then return end local item = clicker:get_wielded_item() @@ -74,7 +92,7 @@ mobs:register_mob("mobs_mc:creeper", { end end, do_custom = function(self, dtime) - if self._forced_explosion_countdown_timer ~= nil then + 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) @@ -130,6 +148,7 @@ mobs:register_mob("mobs_mc:creeper", { }) mobs:register_mob("mobs_mc:creeper_charged", { + description = S("Charged Creeper"), type = "monster", spawn_class = "hostile", hp_min = 20, @@ -142,12 +161,13 @@ mobs:register_mob("mobs_mc:creeper_charged", { mesh = "mobs_mc_creeper.b3d", --BOOM - + textures = { {"mobs_mc_creeper.png", "mobs_mc_creeper_charge.png"}, }, visual_size = {x=3, y=3}, + rotate = 270, sounds = { attack = "tnt_ignite", death = "mobs_mc_creeper_death", @@ -156,18 +176,19 @@ mobs:register_mob("mobs_mc:creeper_charged", { explode = "tnt_explode", distance = 16, }, - makes_footstep_sound = true, + makes_footstep_sound = false, walk_velocity = 1.05, run_velocity = 2.1, runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" }, attack_type = "explode", explosion_strength = 6, - explosion_radius = 8, - explosion_damage_radius = 8, - explosiontimer_reset_radius = 6, - reach = 3, - explosion_timer = 1.5, + --explosion_radius = 3, + --explosion_damage_radius = 6, + --explosiontimer_reset_radius = 3, + reach = 1.5, + defuse_reach = 4, + explosion_timer = 0.3, allow_fuse_reset = true, stop_to_explode = true, @@ -175,7 +196,7 @@ mobs:register_mob("mobs_mc:creeper_charged", { -- TODO: Make creeper flash after doing this as well. -- TODO: Test and debug this code. on_rightclick = function(self, clicker) - if self._forced_explosion_countdown_timer ~= nil then + if self._forced_explosion_countdown_timer then return end local item = clicker:get_wielded_item() @@ -195,7 +216,7 @@ mobs:register_mob("mobs_mc:creeper_charged", { end end, do_custom = function(self, dtime) - if self._forced_explosion_countdown_timer ~= nil then + 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) @@ -254,8 +275,8 @@ mobs:register_mob("mobs_mc:creeper_charged", { }) mobs:spawn_specific( -"mobs_mc:creeper", -"overworld", +"mobs_mc:creeper", +"overworld", "ground", { "Mesa", @@ -398,12 +419,12 @@ mobs:spawn_specific( "ExtremeHillsM_underground", "JungleEdgeM_underground", }, -0, -7, -20, -16500, -2, -mobs_mc.spawn_height.overworld_min, +0, +7, +20, +16500, +2, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- spawn eggs diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index db29b63a..bafb3f84 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -2,20 +2,28 @@ --################### ENDERDRAGON --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:enderdragon", { + description = S("Ender Dragon"), type = "monster", spawn_class = "hostile", - pathfinding = 1, attacks_animals = true, walk_chance = 100, + rotate = 270, + tilt_fly = true, + hostile = true, + shoot_arrow = function(self, pos, dir) + -- 2-4 damage per arrow + local dmg = math.random(2,4) + mobs.shoot_projectile_handling("mobs_mc:dragon_fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg) + end, hp_max = 200, hp_min = 200, xp_min = 500, xp_max = 500, - collisionbox = {-2, 3, -2, 2, 5, 2}, - physical = false, + collisionbox = {-2, 0, -2, 2, 2, 2}, + eye_height = 1, visual = "mesh", mesh = "mobs_mc_dragon.b3d", textures = { @@ -23,6 +31,7 @@ mobs:register_mob("mobs_mc:enderdragon", { }, visual_size = {x=3, y=3}, view_range = 35, + reach = 20, walk_velocity = 6, run_velocity = 6, can_despawn = false, @@ -46,12 +55,10 @@ mobs:register_mob("mobs_mc:enderdragon", { lava_damage = 0, fire_damage = 0, on_rightclick = nil, - attack_type = "dogshoot", + attack_type = "projectile", arrow = "mobs_mc:dragon_fireball", shoot_interval = 0.5, shoot_offset = -1.0, - xp_min = 500, - xp_max = 500, animation = { fly_speed = 8, stand_speed = 8, stand_start = 0, stand_end = 20, @@ -60,7 +67,7 @@ mobs:register_mob("mobs_mc:enderdragon", { }, ignores_nametag = true, do_custom = function(self) - mcl_bossbars.update_boss(self, "Ender Dragon", "light_purple") + mcl_bossbars.update_boss(self.object, "Ender Dragon", "light_purple") for _, obj in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 80)) do local luaentity = obj:get_luaentity() if luaentity and luaentity.name == "mcl_end:crystal" then @@ -104,8 +111,8 @@ mobs:register_mob("mobs_mc:enderdragon", { fire_resistant = true, }) - -local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false +--TODO: replace this setting by a proper gamerules system +local mobs_griefing = minetest.settings:get_bool("mobs_griefing", true) -- dragon fireball (projectile) mobs:register_arrow("mobs_mc:dragon_fireball", { @@ -132,10 +139,13 @@ mobs:register_arrow("mobs_mc:dragon_fireball", { -- node hit, explode hit_node = function(self, pos, node) - mobs:boom(self, pos, 2) + --mobs:boom(self, pos, 2) + if mobs_griefing then + mcl_explosions.explode(self.object:get_pos(), 2, { drop_chance = 1.0 }) + end end }) mobs:register_egg("mobs_mc:enderdragon", S("Ender Dragon"), "mobs_mc_spawn_icon_dragon.png", 0, true) -mcl_wip.register_wip_item("mobs_mc:enderdragon") +--mcl_wip.register_wip_item("mobs_mc:enderdragon") diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index 6c87b930..a821bd76 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -24,9 +24,11 @@ -- added rain damage. -- fixed the grass_with_dirt issue. -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) -local telesound = function(pos, is_source) +local vector = vector + +local function telesound(pos, is_source) local snd if is_source then snd = "mobs_mc_enderman_teleport_src" @@ -190,20 +192,22 @@ end local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false mobs:register_mob("mobs_mc:enderman", { + description = S("Enderman"), type = "monster", spawn_class = "passive", - passive = true, - pathfinding = 1, + neutral = true, hp_min = 40, hp_max = 40, xp_min = 5, xp_max = 5, + rotate = 270, collisionbox = {-0.3, -0.01, -0.3, 0.3, 2.89, 0.3}, visual = "mesh", mesh = "mobs_mc_enderman.b3d", textures = create_enderman_textures(), visual_size = {x=3, y=3}, makes_footstep_sound = true, + eye_height = 2.5, sounds = { -- TODO: Custom war cry sound war_cry = "mobs_sandmonster", @@ -212,8 +216,8 @@ mobs:register_mob("mobs_mc:enderman", { random = {name="mobs_mc_enderman_random", gain=0.5}, distance = 16, }, - walk_velocity = 0.2, - run_velocity = 3.4, + walk_velocity = 1, + run_velocity = 4, damage = 7, reach = 2, drops = { @@ -223,6 +227,22 @@ mobs:register_mob("mobs_mc:enderman", { max = 1, looting = "common"}, }, + + --head code + has_head = false, + head_bone = "head.low", + + swap_y_with_x = false, + reverse_head_yaw = false, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + animation = select_enderman_animation("normal"), _taken_node = "", do_custom = function(self, dtime) @@ -281,10 +301,10 @@ mobs:register_mob("mobs_mc:enderman", { --self:teleport(nil) --self.state = "" --else - if self.attack then - local target = self.attack + if self.attacking then + local target = self.attacking local pos = target:get_pos() - if pos ~= nil then + if pos then if vector.distance(self.object:get_pos(), target:get_pos()) > 10 then self:teleport(target) end @@ -300,12 +320,12 @@ mobs:register_mob("mobs_mc:enderman", { for n = 1, #objs do local obj = objs[n] if obj then - if minetest.is_player(obj) then + --if minetest.is_player(obj) then -- Warp from players during day. --if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then -- self:teleport(nil) --end - else + if not obj:is_player() then local lua = obj:get_luaentity() if lua then if lua.name == "mcl_bows:arrow_entity" or lua.name == "mcl_throwing:snowball_entity" then @@ -323,14 +343,14 @@ mobs:register_mob("mobs_mc:enderman", { -- self:teleport(nil) -- self.state = "" --else - if self.attack ~= nil then - self.state = 'attack' + if self.attack and not minetest.settings:get_bool("creative_mode") then + self.state = "attack" end --end end -- Check to see if people are near by enough to look at us. for _,obj in pairs(minetest.get_connected_players()) do - + --check if they are within radius local player_pos = obj:get_pos() if player_pos then -- prevent crashing in 1 in a million scenario @@ -355,16 +375,21 @@ mobs:register_mob("mobs_mc:enderman", { local ender_eye_pos = vector.new(enderpos.x, enderpos.y + 2.75, enderpos.z) local eye_distance_from_player = vector.distance(ender_eye_pos, look_pos) look_pos = vector.add(look_pos, vector.multiply(look_dir, eye_distance_from_player)) - + --if looking in general head position, turn hostile if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then self.provoked = "staring" - self.attack = minetest.get_player_by_name(obj:get_player_name()) + self.state = "stand" + self.hostile = false break - else -- I'm not sure what this part does, but I don't want to break anything - jordan4ibanez + --begin attacking the player + else if self.provoked == "staring" then self.provoked = "broke_contact" - end + self.hostile = true + self.state = "attack" + self.attacking = obj + end end end @@ -429,14 +454,14 @@ mobs:register_mob("mobs_mc:enderman", { self.base_texture = create_enderman_textures(block_type, self._taken_node) self.object:set_properties({ textures = self.base_texture }) self.animation = select_enderman_animation("block") - mobs:set_animation(self, self.animation.current) + mobs.set_mob_animation(self, self.animation.current) if def.sounds and def.sounds.dug then minetest.sound_play(def.sounds.dug, {pos = take_pos, max_hear_distance = 16}, true) end end end end - elseif self._taken_node ~= nil and self._taken_node ~= "" and self._take_place_timer >= self._next_take_place_time then + elseif self._taken_node and self._taken_node ~= "" and self._take_place_timer >= self._next_take_place_time then -- Place taken node self._take_place_timer = 0 self._next_take_place_time = math.random(take_frequency_min, take_frequency_max) @@ -452,7 +477,7 @@ mobs:register_mob("mobs_mc:enderman", { local def = minetest.registered_nodes[self._taken_node] -- Update animation accordingly (removes visible block) self.animation = select_enderman_animation("normal") - mobs:set_animation(self, self.animation.current) + mobs.set_mob_animation(self, self.animation.current) if def.sounds and def.sounds.place then minetest.sound_play(def.sounds.place, {pos = place_pos, max_hear_distance = 16}, true) end @@ -462,12 +487,12 @@ mobs:register_mob("mobs_mc:enderman", { end end, do_teleport = function(self, target) - if target ~= nil then + if target then local target_pos = target:get_pos() -- Find all solid nodes below air in a 10×10×10 cuboid centered on the target local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(target_pos, 5), vector.add(target_pos, 5), {"group:solid", "group:cracky", "group:crumbly"}) local telepos - if nodes ~= nil then + if nodes then if #nodes > 0 then -- Up to 64 attempts to teleport for n=1, math.min(64, #nodes) do @@ -502,7 +527,7 @@ mobs:register_mob("mobs_mc:enderman", { -- We need to add (or subtract) different random numbers to each vector component, so it couldn't be done with a nice single vector.add() or .subtract(): local randomCube = vector.new( pos.x + 8*(pr:next(0,16)-8), pos.y + 8*(pr:next(0,16)-8), pos.z + 8*(pr:next(0,16)-8) ) local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(randomCube, 4), vector.add(randomCube, 4), {"group:solid", "group:cracky", "group:crumbly"}) - if nodes ~= nil then + if nodes then if #nodes > 0 then -- Up to 8 low-level (in total up to 8*8 = 64) attempts to teleport for n=1, math.min(8, #nodes) do @@ -534,13 +559,13 @@ mobs:register_mob("mobs_mc:enderman", { end, on_die = function(self, pos) -- Drop carried node on death - if self._taken_node ~= nil and self._taken_node ~= "" then + if self._taken_node and self._taken_node ~= "" then minetest.add_item(pos, self._taken_node) end end, do_punch = function(self, hitter, tflp, tool_caps, dir) -- damage from rain caused by itself so we don't want it to attack itself. - if hitter ~= self.object and hitter ~= nil then + if hitter ~= self.object and hitter then --if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then -- self:teleport(nil) --else @@ -556,29 +581,29 @@ mobs:register_mob("mobs_mc:enderman", { water_damage = 8, view_range = 64, fear_height = 4, - attack_type = "dogfight", + attack_type = "punch", }) -- End spawn mobs:spawn_specific( -"mobs_mc:enderman", -"end", +"mobs_mc:enderman", +"end", "ground", { "End" }, -0, -minetest.LIGHT_MAX+1, -30, -3000, -12, -mobs_mc.spawn_height.end_min, +0, +minetest.LIGHT_MAX+1, +30, +3000, +12, +mobs_mc.spawn_height.end_min, mobs_mc.spawn_height.end_max) -- Overworld spawn mobs:spawn_specific( -"mobs_mc:enderman", -"overworld", +"mobs_mc:enderman", +"overworld", "ground", { "Mesa", @@ -721,28 +746,28 @@ mobs:spawn_specific( "ExtremeHillsM_underground", "JungleEdgeM_underground", }, -0, -7, -30, -19000, -2, -mobs_mc.spawn_height.overworld_min, +0, +7, +30, +19000, +2, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- Nether spawn (rare) mobs:spawn_specific( -"mobs_mc:enderman", -"nether", +"mobs_mc:enderman", +"nether", "ground", { "Nether" }, -0, -7, -30, -27500, -4, -mobs_mc.spawn_height.nether_min, +0, +7, +30, +27500, +4, +mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) -- spawn eggs diff --git a/mods/ENTITIES/mobs_mc/endermite.lua b/mods/ENTITIES/mobs_mc/endermite.lua index da3922a1..29a887c0 100644 --- a/mods/ENTITIES/mobs_mc/endermite.lua +++ b/mods/ENTITIES/mobs_mc/endermite.lua @@ -2,18 +2,22 @@ --################### ENDERMITE --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:endermite", { + description = S("Endermite"), type = "monster", spawn_class = "hostile", passive = false, + rotate = 270, + hostile = true, hp_min = 8, hp_max = 8, xp_min = 3, xp_max = 3, armor = {fleshy = 100, arthropod = 100}, group_attack = true, + attack_type = "punch", collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.29, 0.2}, visual = "mesh", mesh = "mobs_mc_endermite.b3d", diff --git a/mods/ENTITIES/mobs_mc/ghast.lua b/mods/ENTITIES/mobs_mc/ghast.lua index 83a10bfc..dc47411f 100644 --- a/mods/ENTITIES/mobs_mc/ghast.lua +++ b/mods/ENTITIES/mobs_mc/ghast.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### GHAST @@ -11,15 +11,20 @@ local S = minetest.get_translator("mobs_mc") mobs:register_mob("mobs_mc:ghast", { + description = S("Ghast"), type = "monster", spawn_class = "hostile", - pathfinding = 1, group_attack = true, + hostile = true, + fly_random_while_attack = true, hp_min = 10, hp_max = 10, + rotate = 270, xp_min = 5, xp_max = 5, - collisionbox = {-2, 5, -2, 2, 9, 2}, + reach = 20, + eye_height = 2.5, + collisionbox = {-2, 0, -2, 2, 4, 2}, visual = "mesh", mesh = "mobs_mc_ghast.b3d", textures = { @@ -35,8 +40,10 @@ mobs:register_mob("mobs_mc:ghast", { -- TODO: damage -- TODO: better death }, + walk_velocity = 1.6, run_velocity = 3.2, + drops = { {name = mobs_mc.items.gunpowder, chance = 1, min = 0, max = 2, looting = "common"}, {name = mobs_mc.items.ghast_tear, chance = 10/6, min = 0, max = 1, looting = "common", looting_ignore_chance = true}, @@ -47,22 +54,23 @@ mobs:register_mob("mobs_mc:ghast", { walk_start = 0, walk_end = 40, run_start = 0, run_end = 40, }, + fall_damage = 0, - view_range = 100, - attack_type = "dogshoot", - arrow = "mobs_mc:fireball", - shoot_interval = 3.5, - shoot_offset = -5, - dogshoot_switch = 1, - dogshoot_count_max =1, - passive = false, - jump = true, - jump_height = 4, + view_range = 28, + attack_type = "projectile", + arrow = "mobs_mc:ghast_fireball", floats=1, fly = true, makes_footstep_sound = false, - instant_death = true, fire_resistant = true, + projectile_cooldown_min = 5, + projectile_cooldown_max = 7, + shoot_arrow = function(self, pos, dir) + -- 2-4 damage per arrow + local dmg = math.random(2,4) + mobs.shoot_projectile_handling("mobs_mc:ghast_fireball", pos, dir, self.object:get_yaw(), self.object, 11, dmg,nil,nil,nil,-0.6) + end, + --[[ do_custom = function(self) if self.firing == true then self.base_texture = {"mobs_mc_ghast_firing.png"} @@ -72,53 +80,60 @@ mobs:register_mob("mobs_mc:ghast", { self.object:set_properties({textures=self.base_texture}) end end, + ]]-- }) mobs:spawn_specific( -"mobs_mc:ghast", -"nether", +"mobs_mc:ghast", +"nether", "ground", { "Nether" }, -0, -minetest.LIGHT_MAX+1, -30, -18000, -2, -mobs_mc.spawn_height.nether_min, +0, +minetest.LIGHT_MAX+1, +30, +18000, +2, +mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) -- fireball (projectile) -mobs:register_arrow("mobs_mc:fireball", { +mobs:register_arrow("mobs_mc:ghast_fireball", { visual = "sprite", visual_size = {x = 1, y = 1}, textures = {"mcl_fire_fire_charge.png"}, velocity = 15, collisionbox = {-.5, -.5, -.5, .5, .5, .5}, + tail = 1, + tail_texture = "mobs_mc_spit.png^[colorize:black:255", --repurpose spit texture + tail_size = 5, + _is_fireball = true, hit_player = function(self, player) - if rawget(_G, "armor") and armor.last_damage_types then - armor.last_damage_types[player:get_player_name()] = "fireball" - end + --[[ player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 6}, }, nil) - mobs:boom(self, self.object:get_pos(), 1, true) + ]]-- + --mobs:boom(self, self.object:get_pos(), 1, true) + mcl_explosions.explode(self.object:get_pos(), 3,{ drop_chance = 1.0 }) end, hit_mob = function(self, mob) mob:punch(self.object, 1.0, { full_punch_interval = 1.0, - damage_groups = {fleshy = 6}, + damage_groups = {fleshy = self._damage}, }, nil) - mobs:boom(self, self.object:get_pos(), 1, true) + --mobs:boom(self, self.object:get_pos(), 1, true) + mcl_explosions.explode(self.object:get_pos(), 3,{ drop_chance = 1.0 }) end, hit_node = function(self, pos, node) - mobs:boom(self, pos, 1, true) + --mobs:boom(self, pos, 1, true) + mcl_explosions.explode(self.object:get_pos(), 3,{ drop_chance = 1.0 }) end }) diff --git a/mods/ENTITIES/mobs_mc/guardian.lua b/mods/ENTITIES/mobs_mc/guardian.lua index 13c857ea..3e1a4f85 100644 --- a/mods/ENTITIES/mobs_mc/guardian.lua +++ b/mods/ENTITIES/mobs_mc/guardian.lua @@ -2,9 +2,10 @@ --################### GUARDIAN --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:guardian", { + description = S("Guardian"), type = "monster", spawn_class = "hostile", hp_min = 30, @@ -12,8 +13,8 @@ mobs:register_mob("mobs_mc:guardian", { xp_min = 10, xp_max = 10, breath_max = -1, - passive = false, - attack_type = "dogfight", + passive = false, + attack_type = "punch", pathfinding = 1, view_range = 16, walk_velocity = 2, @@ -93,7 +94,6 @@ mobs:register_mob("mobs_mc:guardian", { makes_footstep_sound = false, fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source }, jump = false, - view_range = 16, }) -- Spawning disabled due to size issues diff --git a/mods/ENTITIES/mobs_mc/guardian_elder.lua b/mods/ENTITIES/mobs_mc/guardian_elder.lua index 089f6e38..2bb0e984 100644 --- a/mods/ENTITIES/mobs_mc/guardian_elder.lua +++ b/mods/ENTITIES/mobs_mc/guardian_elder.lua @@ -4,9 +4,10 @@ --################### GUARDIAN --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:guardian_elder", { + description = S("Elder Guardian"), type = "monster", spawn_class = "hostile", hp_min = 80, @@ -14,8 +15,8 @@ mobs:register_mob("mobs_mc:guardian_elder", { xp_min = 10, xp_max = 10, breath_max = -1, - passive = false, - attack_type = "dogfight", + passive = false, + attack_type = "punch", pathfinding = 1, view_range = 16, walk_velocity = 2, @@ -103,7 +104,6 @@ mobs:register_mob("mobs_mc:guardian_elder", { makes_footstep_sound = false, fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source }, jump = false, - view_range = 16, }) -- Spawning disabled due to size issues <- what do you mean? -j4i diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index 938a6b6a..4b33515d 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### HORSE @@ -38,9 +38,9 @@ end local can_equip_horse_armor = function(entity_id) return entity_id == "mobs_mc:horse" or entity_id == "mobs_mc:skeleton_horse" or entity_id == "mobs_mc:zombie_horse" end -local can_equip_chest = function(entity_id) +--[[local can_equip_chest = function(entity_id) return entity_id == "mobs_mc:mule" or entity_id == "mobs_mc:donkey" -end +end]] local can_breed = function(entity_id) return entity_id == "mobs_mc:horse" or "mobs_mc:mule" or entity_id == "mobs_mc:donkey" end @@ -83,10 +83,15 @@ end -- Horse local horse = { + description = S("Horse"), type = "animal", spawn_class = "passive", visual = "mesh", mesh = "mobs_mc_horse.b3d", + rotate = 270, + walk_velocity = 1, + run_velocity = 8, + skittish = true, visual_size = {x=3.0, y=3.0}, collisionbox = {-0.69825, -0.01, -0.69825, 0.69825, 1.59, 0.69825}, animation = { @@ -96,7 +101,7 @@ local horse = { walk_speed = 25, walk_start = 0, walk_end = 40, - run_speed = 60, + run_speed = 120, run_start = 0, run_end = 40, }, @@ -113,7 +118,8 @@ local horse = { fly = false, walk_chance = 60, view_range = 16, - follow = mobs_mc.follow.horse, + follow = "mcl_farming:wheat_item", + follow_distance = 3, passive = true, hp_min = 15, hp_max = 30, @@ -181,7 +187,7 @@ local horse = { -- if driver present and horse has a saddle allow control of horse if self.driver and self._saddle then - mobs.drive(self, "walk", "stand", false, dtime) + mobs.drive(self, "run", "stand", false, dtime) return false -- skip rest of mob functions end @@ -213,6 +219,21 @@ local horse = { local iname = item:get_name() local heal = 0 + --sneak click to breed the horse/feed it + if self.owner and self.owner == clicker:get_player_name() then + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + end + + --don't do any other logic with the baby + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end + -- Taming self.temper = self.temper or (math.random(1,100)) @@ -238,6 +259,7 @@ local horse = { self.buck_off_time = 40 -- TODO how long does it take in minecraft? if self.temper > 100 then self.tamed = true -- NOTE taming can only be finished by riding the horse + mobs.tamed_effect(self) if not self.owner or self.owner == "" then self.owner = clicker:get_player_name() end @@ -252,6 +274,14 @@ local horse = { -- If nothing happened temper_increase = 0 and addition does nothing self.temper = self.temper + temper_increase + --give the player some kind of idea + --of what's happening with the horse's temper + if self.temper <= 100 then + mobs.feed_effect(self) + else + mobs.tamed_effect(self) + end + return end @@ -281,14 +311,10 @@ local horse = { return end - if mobs:protect(self, clicker) then - return - end - -- Make sure tamed horse is mature and being clicked by owner only if self.tamed and not self.child and self.owner == clicker:get_player_name() then - local inv = clicker:get_inventory() + --local inv = clicker:get_inventory() -- detatch player already riding horse if self.driver and clicker == self.driver then @@ -356,9 +382,6 @@ local horse = { self.object:set_properties({stepheight = 1.1}) mobs.attach(self, clicker) - -- Used to capture horse - elseif not self.driver and iname ~= "" then - mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) end end end, @@ -418,6 +441,7 @@ mobs:register_mob("mobs_mc:horse", horse) -- Skeleton horse local skeleton_horse = table.copy(horse) +skeleton_horse.description = S("Skeleton Horse") skeleton_horse.breath_max = -1 skeleton_horse.armor = {undead = 100, fleshy = 100} skeleton_horse.textures = {{"blank.png", "mobs_mc_horse_skeleton.png", "blank.png"}} @@ -440,6 +464,7 @@ mobs:register_mob("mobs_mc:skeleton_horse", skeleton_horse) -- Zombie horse local zombie_horse = table.copy(horse) +zombie_horse.description = S("Zombie Horse") zombie_horse.breath_max = -1 zombie_horse.armor = {undead = 100, fleshy = 100} zombie_horse.textures = {{"blank.png", "mobs_mc_horse_zombie.png", "blank.png"}} @@ -464,6 +489,7 @@ mobs:register_mob("mobs_mc:zombie_horse", zombie_horse) -- Donkey local d = 0.86 -- donkey scale local donkey = table.copy(horse) +donkey.description = S("Donkey") donkey.textures = {{"blank.png", "mobs_mc_donkey.png", "blank.png"}} donkey.animation = { speed_normal = 25, @@ -494,6 +520,7 @@ mobs:register_mob("mobs_mc:donkey", donkey) -- Mule local m = 0.94 local mule = table.copy(donkey) +mule.description = S("Mule") mule.textures = {{"blank.png", "mobs_mc_mule.png", "blank.png"}} mule.visual_size = { x=horse.visual_size.x*m, y=horse.visual_size.y*m } mule.sounds = table.copy(donkey.sounds) @@ -515,35 +542,66 @@ mobs:spawn_specific( "overworld", "ground", { -"FlowerForest", -"Swampland", -"Taiga", -"ExtremeHills", -"BirchForest", -"MegaSpruceTaiga", -"MegaTaiga", -"ExtremeHills+", -"Forest", -"Plains", -"ColdTaiga", -"SunflowerPlains", -"RoofedForest", -"MesaPlateauFM_grasstop", -"ExtremeHillsM", -"BirchForestM", + "FlowerForest_beach", + "Forest_beach", + "StoneBeach", + "ColdTaiga_beach_water", + "Taiga_beach", + "Savanna_beach", + "Plains_beach", + "ExtremeHills_beach", + "ColdTaiga_beach", + "Swampland_shore", + "JungleM_shore", + "Jungle_shore", + "MesaPlateauFM_sandlevel", + "MesaPlateauF_sandlevel", + "MesaBryce_sandlevel", + "Mesa_sandlevel", + "Mesa", + "FlowerForest", + "Swampland", + "Taiga", + "ExtremeHills", + "Jungle", + "Savanna", + "BirchForest", + "MegaSpruceTaiga", + "MegaTaiga", + "ExtremeHills+", + "Forest", + "Plains", + "Desert", + "ColdTaiga", + "IcePlainsSpikes", + "SunflowerPlains", + "IcePlains", + "RoofedForest", + "ExtremeHills+_snowtop", + "MesaPlateauFM_grasstop", + "JungleEdgeM", + "ExtremeHillsM", + "JungleM", + "BirchForestM", + "MesaPlateauF", + "MesaPlateauFM", + "MesaPlateauF_grasstop", + "MesaBryce", + "JungleEdge", + "SavannaM", }, -0, -minetest.LIGHT_MAX+1, -30, -15000, -4, -mobs_mc.spawn_height.water+3, +0, +minetest.LIGHT_MAX+1, +30, +15000, +4, +mobs_mc.spawn_height.water+3, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific( -"mobs_mc:donkey", -"overworld", +"mobs_mc:donkey", +"overworld", "ground", { "Mesa", @@ -553,12 +611,12 @@ mobs:spawn_specific( "MesaPlateauF_grasstop", "MesaBryce", }, -0, -minetest.LIGHT_MAX+1, -30, -15000, -4, -mobs_mc.spawn_height.water+3, +0, +minetest.LIGHT_MAX+1, +30, +15000, +4, +mobs_mc.spawn_height.water+3, mobs_mc.spawn_height.overworld_max) -- spawn eggs diff --git a/mods/ENTITIES/mobs_mc/init.lua b/mods/ENTITIES/mobs_mc/init.lua index 58006fe9..d7600e92 100644 --- a/mods/ENTITIES/mobs_mc/init.lua +++ b/mods/ENTITIES/mobs_mc/init.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local path = minetest.get_modpath("mobs_mc") +local path = minetest.get_modpath(minetest.get_current_modname()) if not minetest.get_modpath("mobs_mc_gameconfig") then mobs_mc = {} diff --git a/mods/ENTITIES/mobs_mc/iron_golem.lua b/mods/ENTITIES/mobs_mc/iron_golem.lua index 2ccee2d0..946db312 100644 --- a/mods/ENTITIES/mobs_mc/iron_golem.lua +++ b/mods/ENTITIES/mobs_mc/iron_golem.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### IRON GOLEM @@ -12,11 +12,15 @@ local S = minetest.get_translator("mobs_mc") mobs:register_mob("mobs_mc:iron_golem", { + description = S("Iron Golem"), type = "npc", spawn_class = "passive", passive = true, + rotate = 270, hp_min = 100, hp_max = 100, + protect = true, + neutral = true, breath_max = -1, collisionbox = {-0.7, -0.01, -0.7, 0.7, 2.69, 0.7}, visual = "mesh", @@ -39,7 +43,7 @@ mobs:register_mob("mobs_mc:iron_golem", { reach = 3, group_attack = true, attacks_monsters = true, - attack_type = "dogfight", + attack_type = "punch", drops = { {name = mobs_mc.items.iron_ingot, chance = 1, diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index 8ff82b50..9c3f681b 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### LLAMA @@ -25,8 +25,18 @@ local carpets = { } mobs:register_mob("mobs_mc:llama", { + description = S("Llama"), type = "animal", spawn_class = "passive", + rotate = 270, + neutral = true, + group_attack = true, + attack_type = "projectile", + shoot_arrow = function(self, pos, dir) + -- 2-4 damage per arrow + local dmg = 1 + mobs.shoot_projectile_handling("mobs_mc:spit", pos, dir, self.object:get_yaw(), self.object, nil, dmg) + end, hp_min = 15, hp_max = 30, xp_min = 1, @@ -49,7 +59,11 @@ mobs:register_mob("mobs_mc:llama", { walk_velocity = 1, run_velocity = 4.4, follow_velocity = 4.4, + breed_distance = 1.5, + baby_size = 0.5, + follow_distance = 2, floats = 1, + reach = 6, drops = { {name = mobs_mc.items.leather, chance = 1, @@ -82,7 +96,7 @@ mobs:register_mob("mobs_mc:llama", { look_start = 78, look_end = 108, }, - follow = mobs_mc.follow.llama, + follow = mobs_mc.items.hay_bale, view_range = 16, do_custom = function(self, dtime) @@ -125,30 +139,71 @@ mobs:register_mob("mobs_mc:llama", { return end - local item = clicker:get_wielded_item() - if item:get_name() == mobs_mc.items.hay_bale then - -- Breed with hay bale - if mobs:feed_tame(self, clicker, 1, true, false) then return end - else - -- Feed with anything else - if mobs:feed_tame(self, clicker, 1, false, true) then return end + --owner is broken for this + --we'll make the owner this guy + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + self.tamed = true + self.owner = clicker:get_player_name() + return end - if mobs:protect(self, clicker) then return end + + --ignore other logic + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end + -- Make sure tamed llama is mature and being clicked by owner only if self.tamed and not self.child and self.owner == clicker:get_player_name() then + local item = clicker:get_wielded_item() + --safety catch + if not item then + return + end + + + + --put chest on carpeted llama + if self.carpet and not self.chest and item:get_name() == "mcl_chests:chest" then + if not minetest.is_creative_enabled(clicker:get_player_name()) then + item:take_item() + clicker:set_wielded_item(item) + end + + self.base_texture = table.copy(self.base_texture) + self.base_texture[1] = "mobs_mc_llama_chest.png" + self.object:set_properties({ + textures = self.base_texture, + }) + self.chest = true + + return --don't attempt to ride + end + + -- Place carpet - --[[ TODO: Re-enable this code when carpet textures arrived. - if minetest.get_item_group(item:get_name(), "carpet") == 1 and not self.carpet then + --TODO: Re-enable this code when carpet textures arrived. + if minetest.get_item_group(item:get_name(), "carpet") == 1 then + for group, carpetdata in pairs(carpets) do if minetest.get_item_group(item:get_name(), group) == 1 then if not minetest.is_creative_enabled(clicker:get_player_name()) then item:take_item() clicker:set_wielded_item(item) + + --shoot off old carpet + if self.carpet then + minetest.add_item(self.object:get_pos(), self.carpet) + end end + local substr = carpetdata[2] local tex_carpet = "mobs_mc_llama_decor_"..substr..".png" + self.base_texture = table.copy(self.base_texture) self.base_texture[2] = tex_carpet self.object:set_properties({ @@ -169,23 +224,21 @@ mobs:register_mob("mobs_mc:llama", { end end end - ]] - -- detatch player already riding llama - if self.driver and clicker == self.driver then + if self.carpet then + -- detatch player already riding llama + if self.driver and clicker == self.driver then - mobs.detach(clicker, {x = 1, y = 0, z = 1}) + mobs.detach(clicker, {x = 1, y = 0, z = 1}) - -- attach player to llama - elseif not self.driver then + -- attach player to llama + elseif not self.driver then - self.object:set_properties({stepheight = 1.1}) - mobs.attach(self, clicker) + self.object:set_properties({stepheight = 1.1}) + mobs.attach(self, clicker) + end end - -- Used to capture llama - elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then - mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) end end, @@ -229,13 +282,48 @@ mobs:spawn_specific( "MesaPlateauF_grasstop", "MesaBryce", }, -0, -minetest.LIGHT_MAX+1, -30, -15000, -5, -mobs_mc.spawn_height.water+15, +0, +minetest.LIGHT_MAX+1, +30, +15000, +5, +mobs_mc.spawn_height.water+15, mobs_mc.spawn_height.overworld_max) -- spawn eggs mobs:register_egg("mobs_mc:llama", S("Llama"), "mobs_mc_spawn_icon_llama.png", 0) + + +-- llama spit +mobs:register_arrow("mobs_mc:spit", { + visual = "sprite", + visual_size = {x = 0.3, y = 0.3}, + textures = {"mobs_mc_spit.png"}, + velocity = 1, + speed = 1, + tail = 1, + tail_texture = "mobs_mc_spit.png", + tail_size = 2, + tail_distance_divider = 4, + + hit_player = function(self, player) + --[[if rawget(_G, "armor") and armor.last_damage_types then + armor.last_damage_types[player:get_player_name()] = "spit" + end]] + player:punch(self.object, 1.0, { + full_punch_interval = 1.0, + damage_groups = {fleshy = self._damage}, + }, nil) + end, + + hit_mob = function(self, mob) + mob:punch(self.object, 1.0, { + full_punch_interval = 1.0, + damage_groups = {fleshy = self._damage}, + }, nil) + end, + + hit_node = function(self, pos, node) + --does nothing + end +}) \ No newline at end of file diff --git a/mods/ENTITIES/mobs_mc/locale/mobs_mc.de.tr b/mods/ENTITIES/mobs_mc/locale/mobs_mc.de.tr index 24d3fa32..6598cd48 100644 --- a/mods/ENTITIES/mobs_mc/locale/mobs_mc.de.tr +++ b/mods/ENTITIES/mobs_mc/locale/mobs_mc.de.tr @@ -28,6 +28,7 @@ Pig=Schwein Polar Bear=Eisbär Rabbit=Kaninchen Killer Bunny=Killerkaninchen +The Killer Bunny=Das Killerkaninchen Sheep=Schaf Shulker=Shulker Silverfish=Silberfischchen diff --git a/mods/ENTITIES/mobs_mc/locale/mobs_mc.es.tr b/mods/ENTITIES/mobs_mc/locale/mobs_mc.es.tr index 240e7759..c61c0994 100644 --- a/mods/ENTITIES/mobs_mc/locale/mobs_mc.es.tr +++ b/mods/ENTITIES/mobs_mc/locale/mobs_mc.es.tr @@ -28,6 +28,7 @@ Pig=Cerdo Polar Bear=Oso polar Rabbit=Conejo Killer Bunny=Conejo asesino +The Killer Bunny=El Conejo asesino Sheep=Oveja Shulker=Shulker Silverfish=Lepisma diff --git a/mods/ENTITIES/mobs_mc/locale/mobs_mc.fr.tr b/mods/ENTITIES/mobs_mc/locale/mobs_mc.fr.tr index ff1e2b9c..4c8bd562 100644 --- a/mods/ENTITIES/mobs_mc/locale/mobs_mc.fr.tr +++ b/mods/ENTITIES/mobs_mc/locale/mobs_mc.fr.tr @@ -28,6 +28,7 @@ Pig=Cochon Polar Bear=Ours blanc Rabbit=Lapin Killer Bunny=Lapin tueur +The Killer Bunny=Le Lapin tueur Sheep=Mouton Shulker=Shulker Silverfish=Poisson d'argent diff --git a/mods/ENTITIES/mobs_mc/locale/mobs_mc.ru.tr b/mods/ENTITIES/mobs_mc/locale/mobs_mc.ru.tr index 73807c00..8857dda9 100644 --- a/mods/ENTITIES/mobs_mc/locale/mobs_mc.ru.tr +++ b/mods/ENTITIES/mobs_mc/locale/mobs_mc.ru.tr @@ -28,6 +28,7 @@ Pig=Свинья Polar Bear=Полярный медведь Rabbit=Кролик Killer Bunny=Кролик-убийца +The Killer Bunny=Кролик-убийца Sheep=Овца Shulker=Шалкер Silverfish=Чешуйница diff --git a/mods/ENTITIES/mobs_mc/mod.conf b/mods/ENTITIES/mobs_mc/mod.conf index a3057faf..98f48b38 100644 --- a/mods/ENTITIES/mobs_mc/mod.conf +++ b/mods/ENTITIES/mobs_mc/mod.conf @@ -1,6 +1,6 @@ name = mobs_mc author = maikerumine description = Adds Minecraft-like monsters and animals. -depends = mcl_init, mcl_particles, mcl_mobs, mcl_wip, mcl_colors +depends = mcl_init, mcl_particles, mcl_mobs, mcl_wip optional_depends = default, mcl_tnt, mcl_bows, mcl_throwing, mcl_fishing, bones, mesecons_materials, mobs_mc_gameconfig, doc_items diff --git a/mods/ENTITIES/mobs_mc/models/attributes.txt b/mods/ENTITIES/mobs_mc/models/attributes.txt new file mode 100644 index 00000000..ec59e0f7 --- /dev/null +++ b/mods/ENTITIES/mobs_mc/models/attributes.txt @@ -0,0 +1 @@ +Ghast fixed by epCode - Thanks! \ No newline at end of file diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_cat.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_cat.b3d index 9ab4fc10..1a6ecbbe 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_cat.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_cat.b3d differ diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_cow.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_cow.b3d index 2f13ba9c..c0098391 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_cow.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_cow.b3d differ diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_creeper.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_creeper.b3d index 54341579..e04ffc7b 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_creeper.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_creeper.b3d differ diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_ghast.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_ghast.b3d index cebc037c..ab34f334 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_ghast.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_ghast.b3d differ diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_mooshroom.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_mooshroom.b3d index 725268ea..c0098391 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_mooshroom.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_mooshroom.b3d differ diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_skeleton.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_skeleton.b3d index be4094c1..aa1681db 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_skeleton.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_skeleton.b3d differ diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_slime.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_slime.b3d index 18cc3d62..b426ee23 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_slime.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_slime.b3d differ diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_villager_zombie.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_villager_zombie.b3d index 9958b281..b7dd9d7e 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_villager_zombie.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_villager_zombie.b3d differ diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_witherskeleton.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_witherskeleton.b3d index 6f78392f..c1b80830 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_witherskeleton.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_witherskeleton.b3d differ diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_zombie.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_zombie.b3d index f357f68b..deacf31b 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_zombie.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_zombie.b3d differ diff --git a/mods/ENTITIES/mobs_mc/ocelot.lua b/mods/ENTITIES/mobs_mc/ocelot.lua index f3c8c87a..aea54389 100644 --- a/mods/ENTITIES/mobs_mc/ocelot.lua +++ b/mods/ENTITIES/mobs_mc/ocelot.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### OCELOT AND CAT @@ -27,9 +27,12 @@ end -- Ocelot local ocelot = { + description = S("Ocelot"), type = "animal", spawn_class = "passive", can_despawn = true, + rotate = 270, + skittish = true, hp_min = 10, hp_max = 10, xp_min = 1, @@ -42,7 +45,7 @@ local ocelot = { makes_footstep_sound = true, walk_chance = default_walk_chance, walk_velocity = 1, - run_velocity = 3, + run_velocity = 10, follow_velocity = 1, floats = 1, runaway = true, @@ -56,7 +59,7 @@ local ocelot = { }, animation = { speed_normal = 25, - run_speed = 50, + run_speed = 150, stand_start = 0, stand_end = 0, walk_start = 0, @@ -102,6 +105,7 @@ mobs:register_mob("mobs_mc:ocelot", ocelot) -- Cat local cat = table.copy(ocelot) +cat.description = S("Cat") cat.textures = {{"mobs_mc_cat_black.png"}, {"mobs_mc_cat_red.png"}, {"mobs_mc_cat_siamese.png"}} cat.can_despawn = false cat.owner = "" @@ -121,8 +125,6 @@ cat.sounds = { } cat.on_rightclick = function(self, clicker) if mobs:feed_tame(self, clicker, 1, true, false) then return end - if mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end - if mobs:protect(self, clicker) then return end if self.child then return end @@ -149,13 +151,13 @@ end mobs:register_mob("mobs_mc:cat", cat) -local base_spawn_chance = 5000 +--local base_spawn_chance = 5000 -- Spawn ocelot --they get the same as the llama because I'm trying to rework so much of this code right now -j4i mobs:spawn_specific( -"mobs_mc:ocelot", -"overworld", +"mobs_mc:ocelot", +"overworld", "ground", { "Jungle", @@ -163,12 +165,12 @@ mobs:spawn_specific( "JungleM", "JungleEdge", }, -0, -minetest.LIGHT_MAX+1, -30, -15000, -5, -mobs_mc.spawn_height.water+15, +0, +minetest.LIGHT_MAX+1, +30, +15000, +5, +mobs_mc.spawn_height.water+15, mobs_mc.spawn_height.overworld_max) --[[ mobs:spawn({ @@ -183,7 +185,7 @@ mobs:spawn({ max_height = mobs_mc.spawn_height.overworld_max, on_spawn = function(self, pos) Note: Minecraft has a 1/3 spawn failure rate. - In this mod it is emulated by reducing the spawn rate accordingly (see above). + In this mod it is emulated by reducing the spawn rate accordingly (see above). -- 1/7 chance to spawn 2 ocelot kittens if pr:next(1,7) == 1 then diff --git a/mods/ENTITIES/mobs_mc/parrot.lua b/mods/ENTITIES/mobs_mc/parrot.lua index 5efcb191..affcac49 100644 --- a/mods/ENTITIES/mobs_mc/parrot.lua +++ b/mods/ENTITIES/mobs_mc/parrot.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### PARROT @@ -12,6 +12,7 @@ local S = minetest.get_translator("mobs_mc") mobs:register_mob("mobs_mc:parrot", { + description = S("Parrot"), type = "npc", spawn_class = "passive", pathfinding = 1, @@ -19,11 +20,14 @@ mobs:register_mob("mobs_mc:parrot", { hp_max = 6, xp_min = 1, xp_max = 3, - collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.89, 0.25}, + tilt_fly = true, + collisionbox = {-0.25, 0, -0.25, 0.25, 0.9, 0.25}, + eye_height = 0.45, visual = "mesh", mesh = "mobs_mc_parrot.b3d", textures = {{"mobs_mc_parrot_blue.png"},{"mobs_mc_parrot_green.png"},{"mobs_mc_parrot_grey.png"},{"mobs_mc_parrot_red_blue.png"},{"mobs_mc_parrot_yellow_blue.png"}}, visual_size = {x=3, y=3}, + rotate = 270, walk_velocity = 3, run_velocity = 5, sounds = { @@ -40,7 +44,7 @@ mobs:register_mob("mobs_mc:parrot", { max = 2, looting = "common",}, }, - animation = { + animation = { stand_speed = 50, walk_speed = 50, fly_speed = 50, @@ -84,8 +88,6 @@ mobs:register_mob("mobs_mc:parrot", { -- Feed to tame, but not breed if mobs:feed_tame(self, clicker, 1, false, true) then return end - if mobs:protect(self, clicker) then return end - if mobs:capture_mob(self, clicker, 0, 50, 80, false, nil) then return end end, }) @@ -93,7 +95,7 @@ mobs:register_mob("mobs_mc:parrot", { -- Parrots spawn rarely in jungles. TODO: Also check for jungle *biome* <- I'll get to this eventually -j4i mobs:spawn_specific( "mobs_mc:parrot", -"overworld", +"overworld", "ground", { "Jungle", @@ -101,12 +103,12 @@ mobs:spawn_specific( "JungleM", "JungleEdge", }, -0, -minetest.LIGHT_MAX+1, -7, -30000, -1, -mobs_mc.spawn_height.water+7, +0, +minetest.LIGHT_MAX+1, +7, +30000, +1, +mobs_mc.spawn_height.water+7, mobs_mc.spawn_height.overworld_max) -- spawn eggs diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index b7cdf1af..84ff996f 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -1,11 +1,13 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:pig", { + description = S("Pig"), type = "animal", spawn_class = "passive", - runaway = true, + skittish = true, + rotate = 270, hp_min = 10, hp_max = 10, xp_min = 1, @@ -18,11 +20,30 @@ mobs:register_mob("mobs_mc:pig", { "mobs_mc_pig.png", -- base "blank.png", -- saddle }}, + + --head code + has_head = true, + head_bone = "head", + + swap_y_with_x = false, + reverse_head_yaw = false, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + visual_size = {x=2.5, y=2.5}, makes_footstep_sound = true, walk_velocity = 1, run_velocity = 3, follow_velocity = 3.4, + breed_distance = 1.5, + baby_size = 0.5, + follow_distance = 2, drops = { {name = mobs_mc.items.porkchop_raw, chance = 1, @@ -49,7 +70,7 @@ mobs:register_mob("mobs_mc:pig", { run_start = 0, run_end = 40, }, - follow = mobs_mc.follow.pig, + follow = "mcl_farming:carrot_item", view_range = 8, do_custom = function(self, dtime) @@ -90,12 +111,17 @@ mobs:register_mob("mobs_mc:pig", { return end - local wielditem = clicker:get_wielded_item() - -- Feed pig - if wielditem:get_name() ~= mobs_mc.items.carrot_on_a_stick then - if mobs:feed_tame(self, clicker, 1, true, true) then return end + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + --ignore other logic + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return end - if mobs:protect(self, clicker) then return end if self.child then return @@ -103,6 +129,8 @@ mobs:register_mob("mobs_mc:pig", { -- Put saddle on pig local item = clicker:get_wielded_item() + local wielditem = item + if item:get_name() == mobs_mc.items.saddle and self.saddle ~= "yes" then self.base_texture = { "blank.png", -- baby @@ -135,7 +163,7 @@ mobs:register_mob("mobs_mc:pig", { end -- Mount or detach player - local name = clicker:get_player_name() + --local name = clicker:get_player_name() if self.driver and clicker == self.driver then -- Detach if already attached mobs.detach(clicker, {x=1, y=0, z=0}) @@ -163,10 +191,6 @@ mobs:register_mob("mobs_mc:pig", { inv:set_stack("main",self.driver:get_wield_index(), wielditem) end return - - -- Capture pig - elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then - mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) end end, @@ -183,33 +207,64 @@ mobs:register_mob("mobs_mc:pig", { }) mobs:spawn_specific( -"mobs_mc:pig", -"overworld", +"mobs_mc:pig", +"overworld", "ground", { -"FlowerForest", -"Swampland", -"Taiga", -"ExtremeHills", -"BirchForest", -"MegaSpruceTaiga", -"MegaTaiga", -"ExtremeHills+", -"Forest", -"Plains", -"ColdTaiga", -"SunflowerPlains", -"RoofedForest", -"MesaPlateauFM_grasstop", -"ExtremeHillsM", -"BirchForestM", + "FlowerForest_beach", + "Forest_beach", + "StoneBeach", + "ColdTaiga_beach_water", + "Taiga_beach", + "Savanna_beach", + "Plains_beach", + "ExtremeHills_beach", + "ColdTaiga_beach", + "Swampland_shore", + "JungleM_shore", + "Jungle_shore", + "MesaPlateauFM_sandlevel", + "MesaPlateauF_sandlevel", + "MesaBryce_sandlevel", + "Mesa_sandlevel", + "Mesa", + "FlowerForest", + "Swampland", + "Taiga", + "ExtremeHills", + "Jungle", + "Savanna", + "BirchForest", + "MegaSpruceTaiga", + "MegaTaiga", + "ExtremeHills+", + "Forest", + "Plains", + "Desert", + "ColdTaiga", + "IcePlainsSpikes", + "SunflowerPlains", + "IcePlains", + "RoofedForest", + "ExtremeHills+_snowtop", + "MesaPlateauFM_grasstop", + "JungleEdgeM", + "ExtremeHillsM", + "JungleM", + "BirchForestM", + "MesaPlateauF", + "MesaPlateauFM", + "MesaPlateauF_grasstop", + "MesaBryce", + "JungleEdge", + "SavannaM", }, -9, -minetest.LIGHT_MAX+1, -30, -15000, -8, -mobs_mc.spawn_height.overworld_min, +9, +minetest.LIGHT_MAX+1, +30, +15000, +8, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- spawn eggs diff --git a/mods/ENTITIES/mobs_mc/polar_bear.lua b/mods/ENTITIES/mobs_mc/polar_bear.lua index 5d2853f6..0f5296d3 100644 --- a/mods/ENTITIES/mobs_mc/polar_bear.lua +++ b/mods/ENTITIES/mobs_mc/polar_bear.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### POLARBEAR @@ -8,6 +8,7 @@ local S = minetest.get_translator("mobs_mc") mobs:register_mob("mobs_mc:polar_bear", { + description = S("Polar Bear"), type = "animal", spawn_class = "passive", runaway = false, @@ -30,14 +31,14 @@ mobs:register_mob("mobs_mc:polar_bear", { walk_velocity = 1.2, run_velocity = 2.4, group_attack = true, - attack_type = "dogfight", + attack_type = "punch", drops = { -- 3/4 chance to drop raw fish (poor approximation) {name = mobs_mc.items.fish_raw, chance = 2, min = 0, max = 2, - looting = "common",}, + looting = "common",}, -- 1/4 to drop raw salmon {name = mobs_mc.items.salmon_raw, chance = 4, diff --git a/mods/ENTITIES/mobs_mc/rabbit.lua b/mods/ENTITIES/mobs_mc/rabbit.lua index 74bdffcd..8c267595 100644 --- a/mods/ENTITIES/mobs_mc/rabbit.lua +++ b/mods/ENTITIES/mobs_mc/rabbit.lua @@ -1,13 +1,14 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local rabbit = { + description = S("Rabbit"), type = "animal", spawn_class = "passive", passive = true, reach = 1, - + rotate = 270, hp_min = 3, hp_max = 3, xp_min = 1, @@ -61,8 +62,6 @@ local rabbit = { on_rightclick = function(self, clicker) -- Feed, tame protect or capture if mobs:feed_tame(self, clicker, 1, true, true) then return end - if mobs:protect(self, clicker) then return end - if mobs:capture_mob(self, clicker, 0, 50, 80, false, nil) then return end end, do_custom = function(self) -- Easter egg: Change texture if rabbit is named “Toast” @@ -83,6 +82,7 @@ mobs:register_mob("mobs_mc:rabbit", rabbit) -- The killer bunny (Only with spawn egg) local killer_bunny = table.copy(rabbit) +killer_bunny.description = S("Killer Bunny") killer_bunny.type = "monster" killer_bunny.spawn_class = "hostile" killer_bunny.attack_type = "dogfight" @@ -99,7 +99,7 @@ killer_bunny.on_rightclick = nil killer_bunny.run_velocity = 6 killer_bunny.do_custom = function(self) if not self._killer_bunny_nametag_set then - self.nametag = "The Killer Bunny" + self.nametag = S("The Killer Bunny") self._killer_bunny_nametag_set = true end end @@ -110,33 +110,64 @@ mobs:register_mob("mobs_mc:killer_bunny", killer_bunny) -- Different skins depending on spawn location <- we'll get to this when the spawning algorithm is fleshed out mobs:spawn_specific( -"mobs_mc:rabbit", -"overworld", +"mobs_mc:rabbit", +"overworld", "ground", { -"FlowerForest", -"Swampland", -"Taiga", -"ExtremeHills", -"BirchForest", -"MegaSpruceTaiga", -"MegaTaiga", -"ExtremeHills+", -"Forest", -"Plains", -"ColdTaiga", -"SunflowerPlains", -"RoofedForest", -"MesaPlateauFM_grasstop", -"ExtremeHillsM", -"BirchForestM", + "FlowerForest_beach", + "Forest_beach", + "StoneBeach", + "ColdTaiga_beach_water", + "Taiga_beach", + "Savanna_beach", + "Plains_beach", + "ExtremeHills_beach", + "ColdTaiga_beach", + "Swampland_shore", + "JungleM_shore", + "Jungle_shore", + "MesaPlateauFM_sandlevel", + "MesaPlateauF_sandlevel", + "MesaBryce_sandlevel", + "Mesa_sandlevel", + "Mesa", + "FlowerForest", + "Swampland", + "Taiga", + "ExtremeHills", + "Jungle", + "Savanna", + "BirchForest", + "MegaSpruceTaiga", + "MegaTaiga", + "ExtremeHills+", + "Forest", + "Plains", + "Desert", + "ColdTaiga", + "IcePlainsSpikes", + "SunflowerPlains", + "IcePlains", + "RoofedForest", + "ExtremeHills+_snowtop", + "MesaPlateauFM_grasstop", + "JungleEdgeM", + "ExtremeHillsM", + "JungleM", + "BirchForestM", + "MesaPlateauF", + "MesaPlateauFM", + "MesaPlateauF_grasstop", + "MesaBryce", + "JungleEdge", + "SavannaM", }, -9, -minetest.LIGHT_MAX+1, -30, -15000, -8, -mobs_mc.spawn_height.overworld_min, +9, +minetest.LIGHT_MAX+1, +30, +15000, +8, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) --[[ diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index d82df8cf..76f933a6 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### SHEEP @@ -38,7 +38,7 @@ local rainbow_colors = { "unicolor_red_violet" } -if minetest.get_modpath("mcl_wool") ~= nil then +if minetest.get_modpath("mcl_wool") then colors["unicolor_light_blue"] = { mobs_mc.items.wool_light_blue, "#5050FFD0" } end @@ -56,14 +56,20 @@ local gotten_texture = { "blank.png", "mobs_mc_sheep.png" } --mcsheep mobs:register_mob("mobs_mc:sheep", { + description = S("Sheep"), type = "animal", spawn_class = "passive", hp_min = 8, hp_max = 8, xp_min = 1, xp_max = 3, + skittish = true, + breed_distance = 1.5, + baby_size = 0.5, + follow_distance = 2, + follow = mobs_mc.items.wheat, collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.29, 0.45}, - + rotate = 270, visual = "mesh", visual_size = {x=3, y=3}, mesh = "mobs_mc_sheepfur.b3d", @@ -72,6 +78,23 @@ mobs:register_mob("mobs_mc:sheep", { color = "unicolor_white", makes_footstep_sound = true, walk_velocity = 1, + run_velocity = 3, + + --head code + has_head = true, + head_bone = "head", + + swap_y_with_x = false, + reverse_head_yaw = false, + + head_bone_pos_y = 3.6, + head_bone_pos_z = -0.6, + + head_height_offset = 1.0525, + head_direction_offset = 0.5, + head_pitch_modifier = 0, + --end head code + drops = { {name = mobs_mc.items.mutton_raw, chance = 1, @@ -98,7 +121,6 @@ mobs:register_mob("mobs_mc:sheep", { walk_start = 0, walk_end = 40, run_start = 0, run_end = 40, }, - follow = mobs_mc.follow.sheep, view_range = 12, -- Eat grass @@ -128,7 +150,6 @@ mobs:register_mob("mobs_mc:sheep", { do_custom = function(self, dtime) if not self.initial_color_set then local r = math.random(0,100000) - local textures if r <= 81836 then -- 81.836% self.color = "unicolor_white" @@ -194,8 +215,16 @@ mobs:register_mob("mobs_mc:sheep", { on_rightclick = function(self, clicker) local item = clicker:get_wielded_item() - if mobs:feed_tame(self, clicker, 1, true, true) then return end - if mobs:protect(self, clicker) then return end + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end if item:get_name() == mobs_mc.items.shears and not self.gotten and not self.child then self.gotten = true @@ -251,7 +280,6 @@ mobs:register_mob("mobs_mc:sheep", { end return end - if mobs:capture_mob(self, clicker, 0, 5, 70, false, nil) then return end end, on_breed = function(parent1, parent2) -- Breed sheep and choose a fur color for the child. @@ -308,30 +336,62 @@ mobs:spawn_specific( "overworld", "ground", { -"FlowerForest", -"Swampland", -"Taiga", -"ExtremeHills", -"BirchForest", -"MegaSpruceTaiga", -"MegaTaiga", -"ExtremeHills+", -"Forest", -"Plains", -"ColdTaiga", -"SunflowerPlains", -"RoofedForest", -"MesaPlateauFM_grasstop", -"ExtremeHillsM", -"BirchForestM", + "FlowerForest_beach", + "Forest_beach", + "StoneBeach", + "ColdTaiga_beach_water", + "Taiga_beach", + "Savanna_beach", + "Plains_beach", + "ExtremeHills_beach", + "ColdTaiga_beach", + "Swampland_shore", + "JungleM_shore", + "Jungle_shore", + "MesaPlateauFM_sandlevel", + "MesaPlateauF_sandlevel", + "MesaBryce_sandlevel", + "Mesa_sandlevel", + "Mesa", + "FlowerForest", + "Swampland", + "Taiga", + "ExtremeHills", + "Jungle", + "Savanna", + "BirchForest", + "MegaSpruceTaiga", + "MegaTaiga", + "ExtremeHills+", + "Forest", + "Plains", + "Desert", + "ColdTaiga", + "IcePlainsSpikes", + "SunflowerPlains", + "IcePlains", + "RoofedForest", + "ExtremeHills+_snowtop", + "MesaPlateauFM_grasstop", + "JungleEdgeM", + "ExtremeHillsM", + "JungleM", + "BirchForestM", + "MesaPlateauF", + "MesaPlateauFM", + "MesaPlateauF_grasstop", + "MesaBryce", + "JungleEdge", + "SavannaM", }, -0, -minetest.LIGHT_MAX+1, -30, -15000, -3, -mobs_mc.spawn_height.overworld_min, +0, +minetest.LIGHT_MAX+1, +30, +15000, +3, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- spawn eggs mobs:register_egg("mobs_mc:sheep", S("Sheep"), "mobs_mc_spawn_icon_sheep.png", 0) + diff --git a/mods/ENTITIES/mobs_mc/shulker.lua b/mods/ENTITIES/mobs_mc/shulker.lua index 8000d093..1a5c4ec8 100644 --- a/mods/ENTITIES/mobs_mc/shulker.lua +++ b/mods/ENTITIES/mobs_mc/shulker.lua @@ -3,18 +3,19 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### SHULKER --################### -- animation 45-80 is transition between passive and attack stance - + mobs:register_mob("mobs_mc:shulker", { + description = S("Shulker"), type = "monster", spawn_class = "hostile", - attack_type = "shoot", + attack_type = "projectile", shoot_interval = 0.5, arrow = "mobs_mc:shulkerbullet", shoot_offset = 0.5, @@ -82,16 +83,16 @@ mobs:register_arrow("mobs_mc:shulkerbullet", { mobs:register_egg("mobs_mc:shulker", S("Shulker"), "mobs_mc_spawn_icon_shulker.png", 0) mobs:spawn_specific( -"mobs_mc:shulker", -"end", +"mobs_mc:shulker", +"end", "ground", { "End" }, -0, -minetest.LIGHT_MAX+1, -30, -5000, -2, -mobs_mc.spawn_height.end_min, +0, +minetest.LIGHT_MAX+1, +30, +5000, +2, +mobs_mc.spawn_height.end_min, mobs_mc.spawn_height.end_max) diff --git a/mods/ENTITIES/mobs_mc/silverfish.lua b/mods/ENTITIES/mobs_mc/silverfish.lua index 43321150..ac3991ad 100644 --- a/mods/ENTITIES/mobs_mc/silverfish.lua +++ b/mods/ENTITIES/mobs_mc/silverfish.lua @@ -2,9 +2,10 @@ --################### SILVERFISH --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:silverfish", { + description = S("Silverfish"), type = "monster", spawn_class = "hostile", passive = false, @@ -43,9 +44,8 @@ mobs:register_mob("mobs_mc:silverfish", { run_start = 0, run_end = 20, }, view_range = 16, - attack_type = "dogfight", + attack_type = "punch", damage = 1, - reach = 1, }) mobs:register_egg("mobs_mc:silverfish", S("Silverfish"), "mobs_mc_spawn_icon_silverfish.png", 0) @@ -61,7 +61,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then description = "Stone Monster Egg", tiles = {"default_stone.png"}, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", is_ground_content = true, sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, @@ -72,7 +72,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then tiles = {"default_cobble.png"}, is_ground_content = false, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, }) @@ -82,7 +82,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then tiles = {"default_mossycobble.png"}, is_ground_content = false, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, }) @@ -94,7 +94,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then tiles = {"default_stone_brick.png"}, is_ground_content = false, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, }) @@ -104,7 +104,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then tiles = {"default_stone_block.png"}, is_ground_content = false, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, }) diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index b43873b2..f0e728e0 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -3,8 +3,8 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") -local mod_bows = minetest.get_modpath("mcl_bows") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) +local mod_bows = minetest.get_modpath("mcl_bows") --################### --################### SKELETON @@ -13,35 +13,53 @@ local mod_bows = minetest.get_modpath("mcl_bows") ~= nil local skeleton = { + description = S("Skeleton"), type = "monster", spawn_class = "hostile", + hostile = true, + rotate = 270, hp_min = 20, hp_max = 20, xp_min = 6, xp_max = 6, breath_max = -1, + eye_height = 1.5, + projectile_cooldown = 1.5, armor = {undead = 100, fleshy = 100}, collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.98, 0.3}, pathfinding = 1, group_attack = true, visual = "mesh", mesh = "mobs_mc_skeleton.b3d", - textures = { { - "mcl_bows_bow_0.png", -- bow - "mobs_mc_skeleton.png", -- skeleton - } }, - visual_size = {x=3, y=3}, + + --head code + has_head = false, + head_bone = "head", + + swap_y_with_x = true, + reverse_head_yaw = true, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + + visual_size = {x=1, y=1}, makes_footstep_sound = true, - sounds = { - random = "mobs_mc_skeleton_random", - death = "mobs_mc_skeleton_death", - damage = "mobs_mc_skeleton_hurt", - distance = 16, + textures = { + { + "mobs_mc_empty.png", -- armor + "mobs_mc_skeleton.png", -- texture + "mcl_bows_bow_0.png", -- wielded_item + } }, walk_velocity = 1.2, run_velocity = 2.4, damage = 2, - reach = 2, + reach = 3, drops = { {name = mobs_mc.items.arrow, chance = 1, @@ -73,6 +91,8 @@ local skeleton = { walk_speed = 15, walk_start = 40, walk_end = 60, + run_start = 40, + run_end = 60, run_speed = 30, shoot_start = 70, shoot_end = 90, @@ -84,13 +104,13 @@ local skeleton = { ignited_by_sunlight = true, view_range = 16, fear_height = 4, - attack_type = "dogshoot", + attack_type = "projectile", arrow = "mcl_bows:arrow_entity", shoot_arrow = function(self, pos, dir) if mod_bows then -- 2-4 damage per arrow - local dmg = math.max(4, math.random(2, 8)) - mcl_bows.shoot_arrow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg) + local dmg = math.random(2,4) + mobs.shoot_projectile_handling("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg) end end, shoot_interval = 2, @@ -108,12 +128,13 @@ mobs:register_mob("mobs_mc:skeleton", skeleton) --################### local stray = table.copy(skeleton) -stray.mesh = "mobs_mc_stray.b3d" +stray.description = S("Stray") +stray.mesh = "mobs_mc_skeleton.b3d" stray.textures = { { - "mcl_bows_bow_0.png", - "mobs_mc_stray.png", "mobs_mc_stray_overlay.png", + "mobs_mc_stray.png", + "mcl_bows_bow_0.png", }, } -- TODO: different sound (w/ echo) @@ -140,8 +161,8 @@ mobs:register_mob("mobs_mc:stray", stray) -- Overworld spawn mobs:spawn_specific( -"mobs_mc:skeleton", -"overworld", +"mobs_mc:skeleton", +"overworld", "ground", { "Mesa", @@ -284,36 +305,36 @@ mobs:spawn_specific( "ExtremeHillsM_underground", "JungleEdgeM_underground", }, -0, -7, -20, -17000, -2, -mobs_mc.spawn_height.overworld_min, +0, +7, +20, +17000, +2, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- Nether spawn mobs:spawn_specific( -"mobs_mc:skeleton", -"nether", -"ground", +"mobs_mc:skeleton", +"nether", +"ground", { "Nether" }, -0, -7, -30, -10000, -3, -mobs_mc.spawn_height.nether_min, +0, +7, +30, +10000, +3, +mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) -- Stray spawn -- TODO: Spawn directly under the sky mobs:spawn_specific( -"mobs_mc:stray", -"overworld", +"mobs_mc:stray", +"overworld", "ground", { "ColdTaiga", @@ -321,12 +342,12 @@ mobs:spawn_specific( "IcePlains", "ExtremeHills+_snowtop", }, -0, -7, -20, -19000, -2, -mobs_mc.spawn_height.water, +0, +7, +20, +19000, +2, +mobs_mc.spawn_height.water, mobs_mc.spawn_height.overworld_max) diff --git a/mods/ENTITIES/mobs_mc/skeleton_wither.lua b/mods/ENTITIES/mobs_mc/skeleton_wither.lua index da472d60..a6b48d42 100644 --- a/mods/ENTITIES/mobs_mc/skeleton_wither.lua +++ b/mods/ENTITIES/mobs_mc/skeleton_wither.lua @@ -3,13 +3,14 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### WITHER SKELETON --################### mobs:register_mob("mobs_mc:witherskeleton", { + description = S("Wither Skeleton"), type = "monster", spawn_class = "hostile", hp_min = 20, @@ -25,11 +26,12 @@ mobs:register_mob("mobs_mc:witherskeleton", { mesh = "mobs_mc_witherskeleton.b3d", textures = { { - "default_tool_stonesword.png", -- sword + "mobs_mc_empty.png", -- armor "mobs_mc_wither_skeleton.png", -- wither skeleton + "default_tool_stonesword.png", -- sword } }, - visual_size = {x=3.6, y=3.6}, + visual_size = {x=1.2, y=1.2}, makes_footstep_sound = true, sounds = { random = "mobs_mc_skeleton_random", @@ -85,7 +87,7 @@ mobs:register_mob("mobs_mc:witherskeleton", { fire_damage = 0, light_damage = 0, view_range = 16, - attack_type = "dogfight", + attack_type = "punch", dogshoot_switch = 1, dogshoot_count_max =0.5, fear_height = 4, @@ -110,4 +112,4 @@ mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) -- spawn eggs -mobs:register_egg("mobs_mc:witherskeleton", S("Wither Skeleton"), "mobs_mc_spawn_icon_witherskeleton.png", 0) \ No newline at end of file +mobs:register_egg("mobs_mc:witherskeleton", S("Wither Skeleton"), "mobs_mc_spawn_icon_witherskeleton.png", 0) diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 6c8000a5..48aacfcc 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) -- Returns a function that spawns children in a circle around pos. -- To be used as on_die callback. @@ -41,10 +41,10 @@ local spawn_children_on_die = function(child_mob, children_count, spawn_distance -- If mother was murdered, children attack the killer after 1 second if self.state == "attack" then minetest.after(1.0, function(children, enemy) - for c=1, #children do + for c = 1, #children do local child = children[c] local le = child:get_luaentity() - if le ~= nil then + if le then le.state = "attack" le.attack = enemy end @@ -56,17 +56,18 @@ end -- Slime local slime_big = { + description = S("Slime"), type = "monster", spawn_class = "hostile", - pathfinding = 1, group_attack = { "mobs_mc:slime_big", "mobs_mc:slime_small", "mobs_mc:slime_tiny" }, hp_min = 16, hp_max = 16, xp_min = 4, xp_max = 4, + rotate = 270, collisionbox = {-1.02, -0.01, -1.02, 1.02, 2.03, 1.02}, visual_size = {x=12.5, y=12.5}, - textures = {{"mobs_mc_slime.png"}}, + textures = {{"mobs_mc_slime.png", "mobs_mc_slime.png"}}, visual = "mesh", mesh = "mobs_mc_slime.b3d", makes_footstep_sound = true, @@ -83,23 +84,21 @@ local slime_big = { drops = {}, -- TODO: Fix animations animation = { - speed_normal = 24, - speed_run = 48, - stand_start = 0, - stand_end = 23, - walk_start = 24, - walk_end = 47, - run_start = 48, - run_end = 62, - hurt_start = 64, - hurt_end = 86, - death_start = 88, - death_end = 118, + jump_speed = 17, + stand_speed = 17, + walk_speed = 17, + jump_start = 1, + jump_end = 20, + stand_start = 1, + stand_end = 20, + walk_start = 1, + walk_end = 20, }, fall_damage = 0, view_range = 16, - attack_type = "dogfight", + attack_type = "jump_punch", passive = false, + jump_only = true, jump = true, walk_velocity = 2.5, run_velocity = 2.5, @@ -158,8 +157,8 @@ local smin = mobs_mc.spawn_height.overworld_min local smax = mobs_mc.spawn_height.water - 23 mobs:spawn_specific( -"mobs_mc:slime_tiny", -"overworld", +"mobs_mc:slime_tiny", +"overworld", "ground", { "FlowerForest_underground", @@ -193,17 +192,17 @@ mobs:spawn_specific( "ExtremeHillsM_underground", "JungleEdgeM_underground", }, -0, -minetest.LIGHT_MAX+1, -30, -12000, -4, -smin, +0, +minetest.LIGHT_MAX+1, +30, +12000, +4, +smin, smax) mobs:spawn_specific( -"mobs_mc:slime_small", -"overworld", +"mobs_mc:slime_small", +"overworld", "ground", { "FlowerForest_underground", @@ -236,19 +235,19 @@ mobs:spawn_specific( "JungleM_underground", "ExtremeHillsM_underground", "JungleEdgeM_underground", -}, -0, -minetest.LIGHT_MAX+1, -30, -8500, -4, -smin, +}, +0, +minetest.LIGHT_MAX+1, +30, +8500, +4, +smin, smax) mobs:spawn_specific( -"mobs_mc:slime_big", -"overworld", -"ground", +"mobs_mc:slime_big", +"overworld", +"ground", { "FlowerForest_underground", "JungleEdge_underground", @@ -281,16 +280,17 @@ mobs:spawn_specific( "ExtremeHillsM_underground", "JungleEdgeM_underground", }, -0, -minetest.LIGHT_MAX+1, -30, -10000, -4, -smin, +0, +minetest.LIGHT_MAX+1, +30, +10000, +4, +smin, smax) -- Magma cube local magma_cube_big = { + description = S("Magma Cube"), type = "monster", spawn_class = "hostile", hp_min = 16, @@ -299,7 +299,7 @@ local magma_cube_big = { xp_max = 4, collisionbox = {-1.02, -0.01, -1.02, 1.02, 2.03, 1.02}, visual_size = {x=12.5, y=12.5}, - textures = {{ "mobs_mc_magmacube.png" }}, + textures = {{ "mobs_mc_magmacube.png", "mobs_mc_magmacube.png" }}, visual = "mesh", mesh = "mobs_mc_magmacube.b3d", makes_footstep_sound = true, @@ -311,6 +311,7 @@ local magma_cube_big = { }, walk_velocity = 4, run_velocity = 4, + rotate = 270, damage = 6, reach = 3, armor = 53, @@ -322,27 +323,25 @@ local magma_cube_big = { }, -- TODO: Fix animations animation = { - speed_normal = 24, - speed_run = 48, - stand_start = 0, - stand_end = 23, - walk_start = 24, - walk_end = 47, - run_start = 48, - run_end = 62, - hurt_start = 64, - hurt_end = 86, - death_start = 88, - death_end = 118, + jump_speed = 20, + stand_speed = 20, + walk_speed = 20, + jump_start = 1, + jump_end = 40, + stand_start = 1, + stand_end = 1, + walk_start = 1, + walk_end = 40, }, water_damage = 0, lava_damage = 0, - fire_damage = 0, + fire_damage = 0, light_damage = 0, fall_damage = 0, view_range = 16, - attack_type = "dogfight", + attack_type = "jump_punch", passive = false, + jump_only = true, jump = true, jump_height = 8, walk_chance = 0, @@ -401,49 +400,49 @@ local mmin = mobs_mc.spawn_height.nether_min local mmax = mobs_mc.spawn_height.nether_max mobs:spawn_specific( -"mobs_mc:magma_cube_tiny", -"nether", +"mobs_mc:magma_cube_tiny", +"nether", "ground", { "Nether" }, -0, -minetest.LIGHT_MAX+1, -30, -15000, -4, -mmin, +0, +minetest.LIGHT_MAX+1, +30, +15000, +4, +mmin, mmax) mobs:spawn_specific( -"mobs_mc:magma_cube_small", -"nether", +"mobs_mc:magma_cube_small", +"nether", "ground", { "Nether" }, -0, -minetest.LIGHT_MAX+1, -30, -15500, -4, -mmin, +0, +minetest.LIGHT_MAX+1, +30, +15500, +4, +mmin, mmax) mobs:spawn_specific( -"mobs_mc:magma_cube_big", -"nether", +"mobs_mc:magma_cube_big", +"nether", "ground", { "Nether" -}, -0, -minetest.LIGHT_MAX+1, -30, -16000, -4, -mmin, +}, +0, +minetest.LIGHT_MAX+1, +30, +16000, +4, +mmin, mmax) --mobs:spawn_specific("mobs_mc:magma_cube_tiny", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11000, 4, mmin, mmax) diff --git a/mods/ENTITIES/mobs_mc/snowman.lua b/mods/ENTITIES/mobs_mc/snowman.lua index 1ee88b36..9e2fae4d 100644 --- a/mods/ENTITIES/mobs_mc/snowman.lua +++ b/mods/ENTITIES/mobs_mc/snowman.lua @@ -3,12 +3,12 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local snow_trail_frequency = 0.5 -- Time in seconds for checking to add a new snow trail local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false -local mod_throwing = minetest.get_modpath("mcl_throwing") ~= nil +local mod_throwing = minetest.get_modpath("mcl_throwing") local gotten_texture = { "mobs_mc_snowman.png", @@ -21,6 +21,7 @@ local gotten_texture = { } mobs:register_mob("mobs_mc:snowman", { + description = S("Snow Golem"), type = "npc", spawn_class = "passive", passive = true, diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.4.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.4.ogg index 5c9ee492..acb23644 100644 Binary files a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.4.ogg and b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.4.ogg differ diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.5.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.5.ogg index acb23644..1ef7a522 100644 Binary files a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.5.ogg and b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.5.ogg differ diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.6.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.6.ogg index 1ef7a522..c2743fbc 100644 Binary files a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.6.ogg and b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.6.ogg differ diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.7.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.7.ogg deleted file mode 100644 index c2743fbc..00000000 Binary files a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.7.ogg and /dev/null differ diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager_hurt.1.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager_hurt.1.ogg new file mode 100644 index 00000000..5c9ee492 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager_hurt.1.ogg differ diff --git a/mods/ENTITIES/mobs_mc/spider.lua b/mods/ENTITIES/mobs_mc/spider.lua index bb5e29eb..e1be9c3e 100644 --- a/mods/ENTITIES/mobs_mc/spider.lua +++ b/mods/ENTITIES/mobs_mc/spider.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### SPIDER @@ -13,20 +13,26 @@ local S = minetest.get_translator("mobs_mc") -- Spider by AspireMint (fishyWET (CC-BY-SA 3.0 license for texture) local spider = { + description = S("Spider"), type = "monster", spawn_class = "hostile", passive = false, + hostile = true, + always_climb = true, docile_by_day = true, - attack_type = "dogfight", - pathfinding = 1, + attack_type = "punch", + punch_timer_cooloff = 0.5, + rotate = 270, damage = 2, reach = 2, hp_min = 16, hp_max = 16, + ignores_cobwebs = true, xp_min = 5, xp_max = 5, + eye_height = 0.475, armor = {fleshy = 100, arthropod = 100}, - collisionbox = {-0.7, -0.01, -0.7, 0.7, 0.89, 0.7}, + collisionbox = {-0.45, 0, -0.45, 0.45, 0.9, 0.45}, visual = "mesh", mesh = "mobs_mc_spider.b3d", textures = { @@ -43,7 +49,7 @@ local spider = { distance = 16, }, walk_velocity = 1.3, - run_velocity = 2.8, + run_velocity = 2.75, --spider can become extremely difficult if any higher jump = true, jump_height = 4, view_range = 16, @@ -72,6 +78,7 @@ mobs:register_mob("mobs_mc:spider", spider) -- Cave spider local cave_spider = table.copy(spider) +cave_spider.description = S("Cave Spider") cave_spider.textures = { {"mobs_mc_cave_spider.png^(mobs_mc_spider_eyes.png^[makealpha:0,0,0)"} } -- TODO: Poison damage -- TODO: Revert damage to 2 @@ -88,8 +95,8 @@ mobs:register_mob("mobs_mc:cave_spider", cave_spider) mobs:spawn_specific( -"mobs_mc:spider", -"overworld", +"mobs_mc:spider", +"overworld", "ground", { "Mesa", @@ -232,12 +239,12 @@ mobs:spawn_specific( "ExtremeHillsM_underground", "JungleEdgeM_underground", }, -0, -7, -30, -17000, -2, -mobs_mc.spawn_height.overworld_min, +0, +7, +30, +17000, +2, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- spawn eggs diff --git a/mods/ENTITIES/mobs_mc/squid.lua b/mods/ENTITIES/mobs_mc/squid.lua index cf794ea5..ccd73296 100644 --- a/mods/ENTITIES/mobs_mc/squid.lua +++ b/mods/ENTITIES/mobs_mc/squid.lua @@ -4,9 +4,10 @@ --################### SQUID --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:squid", { + description = S("Squid"), type = "animal", spawn_class = "water", can_despawn = true, @@ -16,6 +17,8 @@ mobs:register_mob("mobs_mc:squid", { xp_min = 1, xp_max = 3, armor = 100, + rotate = 270, + tilt_swim = true, -- FIXME: If the squid is near the floor, it turns black collisionbox = {-0.4, 0.0, -0.4, 0.4, 0.9, 0.4}, visual = "mesh", @@ -47,8 +50,7 @@ mobs:register_mob("mobs_mc:squid", { }, visual_size = {x=3, y=3}, makes_footstep_sound = false, - fly = true, - fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source }, + swim = true, breathes_in_water = true, jump = false, view_range = 16, diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_chest.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_chest.png new file mode 100644 index 00000000..e0715af9 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_chest.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_black.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_black.png new file mode 100644 index 00000000..40c39648 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_black.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_blue.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_blue.png new file mode 100644 index 00000000..b02c41b2 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_blue.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_brown.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_brown.png new file mode 100644 index 00000000..2c7c71c2 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_brown.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_cyan.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_cyan.png new file mode 100644 index 00000000..83f7a8fa Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_cyan.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_gray.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_gray.png new file mode 100644 index 00000000..a4bd9cb1 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_gray.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_green.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_green.png new file mode 100644 index 00000000..c3297ce9 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_green.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_light_blue.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_light_blue.png new file mode 100644 index 00000000..71eabea5 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_light_blue.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_light_gray.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_light_gray.png new file mode 100644 index 00000000..929a6095 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_light_gray.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_lime.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_lime.png new file mode 100644 index 00000000..1507d6d7 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_lime.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_magenta.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_magenta.png new file mode 100644 index 00000000..809e645f Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_magenta.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_orange.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_orange.png new file mode 100644 index 00000000..ff17ff67 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_orange.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_pink.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_pink.png new file mode 100644 index 00000000..7009e6ef Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_pink.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_purple.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_purple.png new file mode 100644 index 00000000..1de65a40 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_purple.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_red.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_red.png new file mode 100644 index 00000000..645df497 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_red.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_white.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_white.png new file mode 100644 index 00000000..c6ae669d Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_white.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_yellow.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_yellow.png new file mode 100644 index 00000000..6318e163 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_llama_decor_yellow.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_slime.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_slime.png index 278fafb9..5a30e16f 100644 Binary files a/mods/ENTITIES/mobs_mc/textures/mobs_mc_slime.png and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_slime.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_spit.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_spit.png new file mode 100644 index 00000000..6cdb3e0b Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_spit.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_stray_overlay.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_stray_overlay.png index ab00032b..b4b47a9f 100644 Binary files a/mods/ENTITIES/mobs_mc/textures/mobs_mc_stray_overlay.png and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_stray_overlay.png differ diff --git a/mods/ENTITIES/mobs_mc/vex.lua b/mods/ENTITIES/mobs_mc/vex.lua index cccdebe7..22f1e70d 100644 --- a/mods/ENTITIES/mobs_mc/vex.lua +++ b/mods/ENTITIES/mobs_mc/vex.lua @@ -3,13 +3,14 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### VEX --################### mobs:register_mob("mobs_mc:vex", { + description = S("Vex"), type = "monster", spawn_class = "hostile", pathfinding = 1, @@ -35,7 +36,6 @@ mobs:register_mob("mobs_mc:vex", { view_range = 16, walk_velocity = 3.2, run_velocity = 5.9, - attack_type = "dogfight", sounds = { -- TODO: random death = "mobs_mc_vex_death", diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index d251ba82..06cec9ed 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -19,7 +19,7 @@ -- TODO: Internal inventory, pick up items, trade with other villagers -- TODO: Farm stuff -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local N = function(s) return s end local F = minetest.formspec_escape @@ -195,7 +195,7 @@ local professions = { { -- TODO: replace with empty map - { { "mcl_core:emerald", 7, 11}, { "mcl_maps:filled_map", 1, 1 } }, + { { "mcl_core:emerald", 7, 11}, { "mcl_maps:empty_map", 1, 1 } }, }, -- TODO: special maps @@ -516,7 +516,7 @@ local function show_trade_formspec(playername, trader, tradenum) "size[9,8.75]" .."background[-0.19,-0.25;9.41,9.49;mobs_mc_trading_formspec_bg.png]" ..disabled_img - .."label[4,0;"..F(minetest.colorize(mcl_colors.DARK_GRAY, S(profession))).."]" + .."label[4,0;"..F(minetest.colorize("#313131", S(profession))).."]" .."list[current_player;main;0,4.5;9,3;9]" .."list[current_player;main;0,7.74;9,1;]" ..b_prev..b_next @@ -927,6 +927,7 @@ end) --[=======[ MOB REGISTRATION AND SPAWNING ]=======] mobs:register_mob("mobs_mc:villager", { + description = S("Villager"), type = "npc", spawn_class = "passive", hp_min = 20, @@ -961,14 +962,18 @@ mobs:register_mob("mobs_mc:villager", { }, }, visual_size = {x=2.75, y=2.75}, + rotate = 270, + skittish = true, makes_footstep_sound = true, walk_velocity = 1.2, - run_velocity = 2.4, + run_velocity = 3, drops = {}, can_despawn = false, -- TODO: sounds sounds = { random = "mobs_mc_villager", + damage = "mobs_mc_villager_hurt", + death = "mobs_mc_villager_hurt", distance = 10, }, animation = { @@ -1075,8 +1080,8 @@ mobs:register_mob("mobs_mc:villager", { mobs:spawn_specific( -"mobs_mc:villager", -"overworld", +"mobs_mc:villager", +"overworld", "ground", { "FlowerForest", @@ -1096,12 +1101,12 @@ mobs:spawn_specific( "ExtremeHillsM", "BirchForestM", }, -0, -minetest.LIGHT_MAX+1, -30, -20, -4, -mobs_mc.spawn_height.water+1, +0, +minetest.LIGHT_MAX+1, +30, +20, +4, +mobs_mc.spawn_height.water+1, mobs_mc.spawn_height.overworld_max) -- spawn eggs diff --git a/mods/ENTITIES/mobs_mc/villager_evoker.lua b/mods/ENTITIES/mobs_mc/villager_evoker.lua index abe0e9ca..030da547 100644 --- a/mods/ENTITIES/mobs_mc/villager_evoker.lua +++ b/mods/ENTITIES/mobs_mc/villager_evoker.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### EVOKER @@ -12,6 +12,7 @@ local S = minetest.get_translator("mobs_mc") local pr = PseudoRandom(os.time()*666) mobs:register_mob("mobs_mc:evoker", { + description = S("Evoker"), type = "monster", spawn_class = "hostile", physical = true, @@ -34,7 +35,7 @@ mobs:register_mob("mobs_mc:evoker", { walk_velocity = 0.2, run_velocity = 1.4, group_attack = true, - attack_type = "dogfight", + attack_type = "punch", -- Summon vexes custom_attack = function(self, to_attack) local r = pr:next(2,4) diff --git a/mods/ENTITIES/mobs_mc/villager_illusioner.lua b/mods/ENTITIES/mobs_mc/villager_illusioner.lua index 0bbe2a5f..bec5762e 100644 --- a/mods/ENTITIES/mobs_mc/villager_illusioner.lua +++ b/mods/ENTITIES/mobs_mc/villager_illusioner.lua @@ -3,13 +3,14 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") -local mod_bows = minetest.get_modpath("mcl_bows") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) +local mod_bows = minetest.get_modpath("mcl_bows") mobs:register_mob("mobs_mc:illusioner", { + description = S("Illusioner"), type = "monster", spawn_class = "hostile", - attack_type = "shoot", + attack_type = "projectile", shoot_interval = 2.5, shoot_offset = 1.5, arrow = "mcl_bows:arrow_entity", @@ -17,7 +18,7 @@ mobs:register_mob("mobs_mc:illusioner", { if mod_bows then -- 1-4 damage per arrow local dmg = math.random(1, 4) - mcl_bows.shoot_arrow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg) + mobs.shoot_projectile_handling("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg) end end, hp_min = 32, diff --git a/mods/ENTITIES/mobs_mc/villager_vindicator.lua b/mods/ENTITIES/mobs_mc/villager_vindicator.lua index 56b29506..6a6999b9 100644 --- a/mods/ENTITIES/mobs_mc/villager_vindicator.lua +++ b/mods/ENTITIES/mobs_mc/villager_vindicator.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### VINDICATOR @@ -11,6 +11,7 @@ local S = minetest.get_translator("mobs_mc") mobs:register_mob("mobs_mc:vindicator", { + description = S("Vindicator"), type = "monster", spawn_class = "hostile", physical = false, @@ -36,7 +37,7 @@ mobs:register_mob("mobs_mc:vindicator", { reach = 2, walk_velocity = 1.2, run_velocity = 2.4, - attack_type = "dogfight", + attack_type = "punch", drops = { {name = mobs_mc.items.emerald, chance = 1, diff --git a/mods/ENTITIES/mobs_mc/villager_zombie.lua b/mods/ENTITIES/mobs_mc/villager_zombie.lua index 325cf595..088839b6 100644 --- a/mods/ENTITIES/mobs_mc/villager_zombie.lua +++ b/mods/ENTITIES/mobs_mc/villager_zombie.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### ZOMBIE VILLAGER @@ -26,8 +26,12 @@ local professions = { } mobs:register_mob("mobs_mc:villager_zombie", { + description = S("Zombie Villager"), type = "monster", spawn_class = "hostile", + hostile = true, + rotate = 270, + eye_height = 1.65, hp_min = 20, hp_max = 20, xp_min = 5, @@ -38,20 +42,20 @@ mobs:register_mob("mobs_mc:villager_zombie", { visual = "mesh", mesh = "mobs_mc_villager_zombie.b3d", textures = { - {"mobs_mc_zombie_butcher.png"}, - {"mobs_mc_zombie_farmer.png"}, - {"mobs_mc_zombie_librarian.png"}, - {"mobs_mc_zombie_priest.png"}, - {"mobs_mc_zombie_smith.png"}, - {"mobs_mc_zombie_villager.png"} + {"mobs_mc_empty.png", "mobs_mc_zombie_butcher.png", "mobs_mc_empty.png"}, + {"mobs_mc_empty.png", "mobs_mc_zombie_farmer.png", "mobs_mc_empty.png"}, + {"mobs_mc_empty.png", "mobs_mc_zombie_librarian.png", "mobs_mc_empty.png"}, + {"mobs_mc_empty.png", "mobs_mc_zombie_priest.png", "mobs_mc_empty.png"}, + {"mobs_mc_empty.png", "mobs_mc_zombie_smith.png", "mobs_mc_empty.png"}, + {"mobs_mc_empty.png", "mobs_mc_zombie_villager.png", "mobs_mc_empty.png"}, }, visual_size = {x=2.75, y=2.75}, makes_footstep_sound = true, damage = 3, reach = 2, walk_velocity = 1.2, - run_velocity = 2.4, - attack_type = "dogfight", + run_velocity = 3.5, + attack_type = "punch", group_attack = true, drops = { {name = mobs_mc.items.rotten_flesh, @@ -147,8 +151,8 @@ mobs:register_mob("mobs_mc:villager_zombie", { }) mobs:spawn_specific( -"mobs_mc:villager_zombie", -"overworld", +"mobs_mc:villager_zombie", +"overworld", "ground", { "FlowerForest_underground", @@ -231,15 +235,14 @@ mobs:spawn_specific( "MesaBryce_sandlevel", "Mesa_sandlevel", }, -0, -7, -30, -4090, -4, -mobs_mc.spawn_height.overworld_min, +0, +7, +30, +4090, +4, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) --mobs:spawn_specific("mobs_mc:villager_zombie", "overworld", "ground", 0, 7, 30, 60000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- spawn eggs mobs:register_egg("mobs_mc:villager_zombie", S("Zombie Villager"), "mobs_mc_spawn_icon_zombie_villager.png", 0) - diff --git a/mods/ENTITIES/mobs_mc/witch.lua b/mods/ENTITIES/mobs_mc/witch.lua index f9f9b8d1..34492a1b 100644 --- a/mods/ENTITIES/mobs_mc/witch.lua +++ b/mods/ENTITIES/mobs_mc/witch.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### WITCH @@ -13,6 +13,7 @@ local S = minetest.get_translator("mobs_mc") mobs:register_mob("mobs_mc:witch", { + description = S("Witch"), type = "monster", spawn_class = "hostile", hp_min = 26, @@ -33,7 +34,7 @@ mobs:register_mob("mobs_mc:witch", { run_velocity = 2.4, pathfinding = 1, group_attack = true, - attack_type = "dogshoot", + attack_type = "projectile", arrow = "mobs_mc:potion_arrow", shoot_interval = 2.5, shoot_offset = 1, diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index 8e7f7eb9..22e095d9 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -3,13 +3,14 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### WITHER --################### mobs:register_mob("mobs_mc:wither", { + description = S("Wither"), type = "monster", spawn_class = "hostile", hp_max = 300, @@ -25,7 +26,6 @@ mobs:register_mob("mobs_mc:wither", { {"mobs_mc_wither.png"}, }, visual_size = {x=4, y=4}, - makes_footstep_sound = true, view_range = 16, fear_height = 4, walk_velocity = 2, @@ -52,7 +52,7 @@ mobs:register_mob("mobs_mc:wither", { }, lava_damage = 0, fire_damage = 0, - attack_type = "dogshoot", + attack_type = "projectile", explosion_strength = 8, dogshoot_stop = true, arrow = "mobs_mc:wither_skull", @@ -73,14 +73,14 @@ mobs:register_mob("mobs_mc:wither", { self.object:set_properties({textures={self.base_texture}}) self.armor = {undead = 80, fleshy = 80} end - mcl_bossbars.update_boss(self, "Wither", "dark_purple") + mcl_bossbars.update_boss(self.object, "Wither", "dark_purple") end, on_spawn = function(self) minetest.sound_play("mobs_mc_wither_spawn", {object=self.object, gain=1.0, max_hear_distance=64}) end, }) -local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false +--local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false mobs:register_arrow("mobs_mc:wither_skull", { visual = "sprite", diff --git a/mods/ENTITIES/mobs_mc/wolf.lua b/mods/ENTITIES/mobs_mc/wolf.lua index b1c077d4..0b685d40 100644 --- a/mods/ENTITIES/mobs_mc/wolf.lua +++ b/mods/ENTITIES/mobs_mc/wolf.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local default_walk_chance = 50 @@ -19,16 +19,35 @@ end -- Wolf local wolf = { + description = S("Wolf"), type = "animal", spawn_class = "passive", can_despawn = true, + neutral = true, hp_min = 8, hp_max = 8, xp_min = 1, xp_max = 3, + rotate = 270, passive = false, group_attack = true, - collisionbox = {-0.3, -0.01, -0.3, 0.3, 0.84, 0.3}, + + --head code + has_head = false, + head_bone = "head", + + swap_y_with_x = false, + reverse_head_yaw = false, + + head_bone_pos_y = 3.6, + head_bone_pos_z = -0.6, + + head_height_offset = 1.0525, + head_direction_offset = 0.5, + head_pitch_modifier = 0, + --end head code + + collisionbox = {-0.3, -0.00, -0.3, 0.3, 0.85, 0.3}, visual = "mesh", mesh = "mobs_mc_wolf.b3d", textures = { @@ -52,7 +71,7 @@ local wolf = { run_velocity = 3, damage = 4, reach = 2, - attack_type = "dogfight", + attack_type = "punch", fear_height = 4, follow = mobs_mc.follow.wolf, on_rightclick = function(self, clicker) @@ -74,6 +93,7 @@ local wolf = { dog:set_yaw(yaw) ent = dog:get_luaentity() ent.owner = clicker:get_player_name() + ent.tamed = true -- cornfirm taming minetest.sound_play("mobs_mc_wolf_bark", {object=dog, max_hear_distance=16}, true) -- Replace wolf @@ -138,23 +158,35 @@ dog.owner = "" -- TODO: Start sitting by default dog.order = "roam" dog.owner_loyal = true -dog.follow_velocity = 3.2 +dog.follow_velocity = 3.2 -- Automatically teleport dog to owner dog.do_custom = mobs_mc.make_owner_teleport_function(12) -dog.follow = mobs_mc.follow.dog dog.attack_animals = nil dog.specific_attack = nil +dog.breed_distance = 1.5 +dog.baby_size = 0.5 +dog.follow_distance = 2 +dog.follow = "mcl_mobitems:beef" + dog.on_rightclick = function(self, clicker) local item = clicker:get_wielded_item() - if mobs:protect(self, clicker) then + --owner is broken for this + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then return - elseif item:get_name() ~= "" and mobs:capture_mob(self, clicker, 0, 2, 80, false, nil) then + end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) return - elseif is_food(item:get_name()) then + end + + if is_food(item:get_name()) then -- Feed to increase health local hp = self.health - local hp_add = 0 + local hp_add -- Use eatable group to determine health boost local eatable = minetest.get_item_group(item, "eatable") if eatable > 0 then @@ -254,12 +286,12 @@ mobs:spawn_specific( "ExtremeHillsM", "BirchForestM", }, -0, -minetest.LIGHT_MAX+1, -30, -9000, -7, -mobs_mc.spawn_height.water+3, +0, +minetest.LIGHT_MAX+1, +30, +9000, +7, +mobs_mc.spawn_height.water+3, mobs_mc.spawn_height.overworld_max) mobs:register_egg("mobs_mc:wolf", S("Wolf"), "mobs_mc_spawn_icon_wolf.png", 0) diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index fed83f23..e1247d8b 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### ZOMBIE @@ -46,8 +46,11 @@ table.insert(drops_zombie, { }) local zombie = { + description = S("Zombie"), type = "monster", spawn_class = "hostile", + hostile = true, + rotate = 270, hp_min = 20, hp_max = 20, xp_min = 5, @@ -58,7 +61,11 @@ local zombie = { visual = "mesh", mesh = "mobs_mc_zombie.b3d", textures = { - {"mobs_mc_zombie.png"}, + { + "mobs_mc_empty.png", -- armor + "mobs_mc_zombie.png", -- texture + "mobs_mc_empty.png", -- wielded_item + } }, visual_size = {x=3, y=3}, makes_footstep_sound = true, @@ -69,8 +76,25 @@ local zombie = { damage = "mobs_mc_zombie_hurt", distance = 16, }, - walk_velocity = .8, - run_velocity = 1.6, + + --head code + has_head = false, + head_bone = "Head", + + swap_y_with_x = true, + reverse_head_yaw = true, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + + eye_height = 1.65, + walk_velocity = 1, + run_velocity = 3.5, damage = 3, reach = 2, fear_height = 4, @@ -88,7 +112,8 @@ local zombie = { ignited_by_sunlight = true, sunlight_damage = 2, view_range = 16, - attack_type = "dogfight", + attack_type = "punch", + punch_timer_cooloff = 0.5, harmed_by_heal = true, } @@ -98,6 +123,7 @@ mobs:register_mob("mobs_mc:zombie", zombie) -- A smaller and more dangerous variant of the zombie local baby_zombie = table.copy(zombie) +baby_zombie.description = S("Baby Zombie") baby_zombie.collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.94, 0.25} baby_zombie.xp_min = 12 baby_zombie.xp_max = 12 @@ -111,7 +137,14 @@ mobs:register_mob("mobs_mc:baby_zombie", baby_zombie) -- Husk. -- Desert variant of the zombie local husk = table.copy(zombie) -husk.textures = {{"mobs_mc_husk.png"}} +husk.description = S("Husk") +husk.textures = { + { + "mobs_mc_empty.png", -- armor + "mobs_mc_husk.png", -- texture + "mobs_mc_empty.png", -- wielded_item + } + } husk.ignited_by_sunlight = false husk.sunlight_damage = 0 husk.drops = drops_common @@ -122,6 +155,7 @@ mobs:register_mob("mobs_mc:husk", husk) -- Baby husk. -- A smaller and more dangerous variant of the husk local baby_husk = table.copy(husk) +baby_husk.description = S("Baby Husk") baby_husk.collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.94, 0.25} baby_husk.xp_min = 12 baby_husk.xp_max = 12 @@ -136,8 +170,8 @@ mobs:register_mob("mobs_mc:baby_husk", baby_husk) -- Spawning mobs:spawn_specific( -"mobs_mc:zombie", -"overworld", +"mobs_mc:zombie", +"overworld", "ground", { "FlowerForest_underground", @@ -220,17 +254,17 @@ mobs:spawn_specific( "MesaBryce_sandlevel", "Mesa_sandlevel", }, -0, -7, -30, -6000, -4, -mobs_mc.spawn_height.overworld_min, +0, +7, +30, +6000, +4, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- Baby zombie is 20 times less likely than regular zombies mobs:spawn_specific( -"mobs_mc:baby_zombie", -"overworld", +"mobs_mc:baby_zombie", +"overworld", "ground", { "FlowerForest_underground", @@ -313,18 +347,18 @@ mobs:spawn_specific( "MesaBryce_sandlevel", "Mesa_sandlevel", }, -0, -7, -30, -60000, -4, -mobs_mc.spawn_height.overworld_min, +0, +7, +30, +60000, +4, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific( -"mobs_mc:husk", -"overworld", +"mobs_mc:husk", +"overworld", "ground", { "Desert", @@ -332,29 +366,29 @@ mobs:spawn_specific( "Savanna", "Savanna_beach", }, -0, -7, -30, -6500, -4, -mobs_mc.spawn_height.overworld_min, +0, +7, +30, +6500, +4, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific( -"mobs_mc:baby_husk", -"overworld", -"ground", +"mobs_mc:baby_husk", +"overworld", +"ground", { "Desert", "SavannaM", "Savanna", "Savanna_beach", }, -0, -7, -30, -65000, -4, -mobs_mc.spawn_height.overworld_min, +0, +7, +30, +65000, +4, +mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) -- Spawn eggs diff --git a/mods/ENTITIES/mobs_mc/zombiepig.lua b/mods/ENTITIES/mobs_mc/zombiepig.lua index ebd8ce48..b4088dee 100644 --- a/mods/ENTITIES/mobs_mc/zombiepig.lua +++ b/mods/ENTITIES/mobs_mc/zombiepig.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### ZOMBIE PIGMAN @@ -11,16 +11,20 @@ local S = minetest.get_translator("mobs_mc") local pigman = { + description = S("Zombie Pigman"), -- type="animal", passive=false: This combination is needed for a neutral mob which becomes hostile, if attacked type = "animal", passive = false, + neutral = true, + rotate = 270, spawn_class = "passive", + hostile_cooldown = 15, --seconds hp_min = 20, hp_max = 20, xp_min = 6, xp_max = 6, armor = {undead = 90, fleshy = 90}, - attack_type = "dogfight", + attack_type = "punch", group_attack = { "mobs_mc:pigman", "mobs_mc:baby_pigman" }, damage = 9, reach = 2, @@ -40,6 +44,22 @@ local pigman = { damage = "mobs_mc_zombiepig_hurt", distance = 16, }, + + --head code + has_head = false, + head_bone = "head", + + swap_y_with_x = true, + reverse_head_yaw = true, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + jump = true, makes_footstep_sound = true, walk_velocity = .8, @@ -94,6 +114,7 @@ mobs:register_mob("mobs_mc:pigman", pigman) -- A smaller and more dangerous variant of the pigman local baby_pigman = table.copy(pigman) +baby_pigman.description = S("Baby Zombie Pigman") baby_pigman.collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.94, 0.25} baby_pigman.xp_min = 13 baby_pigman.xp_max = 13 @@ -112,33 +133,33 @@ mobs:register_mob("mobs_mc:baby_pigman", baby_pigman) -- Regular spawning in the Nether mobs:spawn_specific( -"mobs_mc:pigman", -"nether", +"mobs_mc:pigman", +"nether", "ground", { "Nether" }, -0, +0, minetest.LIGHT_MAX+1, -30, -6000, -3, -mobs_mc.spawn_height.nether_min, +30, +6000, +3, +mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) -- Baby zombie is 20 times less likely than regular zombies mobs:spawn_specific( -"mobs_mc:baby_pigman", -"nether", +"mobs_mc:baby_pigman", +"nether", "ground", { "Nether" -}, -0, -minetest.LIGHT_MAX+1, -30, -100000, -4, -mobs_mc.spawn_height.nether_min, +}, +0, +minetest.LIGHT_MAX+1, +30, +100000, +4, +mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) -- Spawning in Nether portals in the Overworld diff --git a/mods/ENTITIES/mobs_mc_gameconfig/init.lua b/mods/ENTITIES/mobs_mc_gameconfig/init.lua index 06d7eb87..27cb4b4b 100644 --- a/mods/ENTITIES/mobs_mc_gameconfig/init.lua +++ b/mods/ENTITIES/mobs_mc_gameconfig/init.lua @@ -200,14 +200,14 @@ end mobs_mc.override.enderman_block_texture_overrides = { ["mcl_core:cactus"] = ctable, -- FIXME: replace colorize colors with colors from palette - ["mcl_core:dirt_with_grass"] = - { - "mcl_core_grass_block_top.png^[colorize:green:90", - "default_dirt.png", - "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", - "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", - "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", - "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)"} + ["mcl_core:dirt_with_grass"] = { + "mcl_core_grass_block_top.png^[colorize:green:90", + "default_dirt.png", + "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", + "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", + "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", + "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", + }, } -- List of nodes on which mobs can spawn diff --git a/mods/ENVIRONMENT/lightning/init.lua b/mods/ENVIRONMENT/lightning/init.lua index 345f733d..3d5955d6 100644 --- a/mods/ENVIRONMENT/lightning/init.lua +++ b/mods/ENVIRONMENT/lightning/init.lua @@ -1,6 +1,7 @@ --[[ Copyright (C) 2016 - Auke Kok +Adapted by MineClone2 contributors "lightning" is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -9,9 +10,8 @@ of the license, or (at your option) any later version. --]] -local S = minetest.get_translator("lightning") +local S = minetest.get_translator(minetest.get_current_modname()) -local has_mcl_death_msg = minetest.get_modpath("mcl_death_messages") local get_connected_players = minetest.get_connected_players local line_of_sight = minetest.line_of_sight local get_node = minetest.get_node @@ -23,22 +23,22 @@ local add_entity = minetest.add_entity local get_objects_inside_radius = minetest.get_objects_inside_radius local get_item_group = minetest.get_item_group -lightning = {} - -lightning.interval_low = 17 -lightning.interval_high = 503 -lightning.range_h = 100 -lightning.range_v = 50 -lightning.size = 100 --- disable this to stop lightning mod from striking -lightning.auto = true +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, +} local rng = PcgRandom(32321123312123) local ps = {} local ttl = -1 -local revertsky = function(dtime) +local function revertsky(dtime) if ttl == 0 then return end @@ -97,7 +97,7 @@ end -- lightning strike API -- * pos: optional, if not given a random pos will be chosen -- * returns: bool - success if a strike happened -lightning.strike = function(pos) +function lightning.strike(pos) if lightning.auto then after(rng:next(lightning.interval_low, lightning.interval_high), lightning.strike) end @@ -135,52 +135,44 @@ lightning.strike = function(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] local lua = obj:get_luaentity() - if obj:is_player() then - -- Player damage - if has_mcl_death_msg then - mcl_death_messages.player_damage(obj, S("@1 was struck by lightning.", obj:get_player_name())) - end - obj:set_hp(obj:get_hp()-5, { type = "punch", from = "mod" }) - -- Mobs - elseif lua and lua._cmi_is_mob then - -- pig → zombie pigman (no damage) - if lua.name == "mobs_mc:pig" then - local rot = obj:get_yaw() - obj:remove() - obj = add_entity(pos2, "mobs_mc:pigman") - obj:set_yaw(rot) + -- pig → zombie pigman (no damage) + 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) - elseif 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.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 - elseif 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 mobs: Just damage + 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 - obj:set_hp(obj:get_hp()-5, { type = "punch", from = "mod" }) + 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 + 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 + else + mcl_util.deal_damage(obj, 5, {type = "lightning_bolt"}) end end diff --git a/mods/ENVIRONMENT/lightning/mod.conf b/mods/ENVIRONMENT/lightning/mod.conf index b0d75631..346a4a0b 100644 --- a/mods/ENVIRONMENT/lightning/mod.conf +++ b/mods/ENVIRONMENT/lightning/mod.conf @@ -2,5 +2,4 @@ name = lightning author = sofar description = A mod that adds thunder and lightning effects. depends = mcl_fire -optional_depends = mcl_death_messages diff --git a/mods/ENVIRONMENT/lightning/screenshot.png b/mods/ENVIRONMENT/lightning/screenshot.png deleted file mode 100644 index 8d3a047c..00000000 Binary files a/mods/ENVIRONMENT/lightning/screenshot.png and /dev/null differ diff --git a/mods/ENVIRONMENT/mcl_moon/init.lua b/mods/ENVIRONMENT/mcl_moon/init.lua index 4ee2623a..200c6ca4 100644 --- a/mods/ENVIRONMENT/mcl_moon/init.lua +++ b/mods/ENVIRONMENT/mcl_moon/init.lua @@ -4,18 +4,16 @@ local SHEET_W = 4 local SHEET_H = 2 -- Randomize initial moon phase, based on map seed -local phase_offset local mg_seed = minetest.get_mapgen_setting("seed") local rand = PseudoRandom(mg_seed) local phase_offset = rand:next(0, MOON_PHASES - 1) -rand = nil minetest.log("info", "[mcl_moon] Moon phase offset of this world: "..phase_offset) mcl_moon = {} mcl_moon.MOON_PHASES = MOON_PHASES -mcl_moon.get_moon_phase = function() +function mcl_moon.get_moon_phase() local after_midday = 0 -- Moon phase changes after midday local tod = minetest.get_timeofday() @@ -25,7 +23,7 @@ mcl_moon.get_moon_phase = function() return (minetest.get_day_count() + phase_offset + after_midday) % MOON_PHASES end -local get_moon_texture = function() +local function get_moon_texture() local phase = mcl_moon.get_moon_phase() local x = phase % MOON_PHASES_HALF local y diff --git a/mods/ENVIRONMENT/mcl_void_damage/init.lua b/mods/ENVIRONMENT/mcl_void_damage/init.lua index ee40ed70..084028dd 100644 --- a/mods/ENVIRONMENT/mcl_void_damage/init.lua +++ b/mods/ENVIRONMENT/mcl_void_damage/init.lua @@ -1,11 +1,10 @@ -local S = minetest.get_translator("mcl_void_damage") -local enable_damage = minetest.settings:get_bool("enable_damage") +local S = minetest.get_translator(minetest.get_current_modname()) +--local enable_damage = minetest.settings:get_bool("enable_damage") local pos_to_dim = mcl_worlds.pos_to_dimension local dim_change = mcl_worlds.dimension_change local is_in_void = mcl_worlds.is_in_void local get_spawn_pos = mcl_spawn.get_player_spawn_pos -local death_msg = mcl_death_messages.player_damage local send_chat = minetest.chat_send_player local get_connected = minetest.get_connected_players @@ -40,10 +39,9 @@ minetest.register_on_mods_loaded(function() end self._void_timer = 0 - local pos = obj:get_pos() - local void, void_deadly = is_in_void(pos) + local _, void_deadly = is_in_void(pos) if void_deadly then - local ent = obj:get_luaentity() + --local ent = obj:get_luaentity() obj:remove() return end @@ -63,7 +61,7 @@ minetest.register_globalstep(function(dtime) for p=1, #players do local player = players[p] local pos = player:get_pos() - local void, void_deadly = is_in_void(pos) + local _, void_deadly = is_in_void(pos) if void_deadly then local immortal_val = player:get_armor_groups().immortal local is_immortal = false @@ -80,8 +78,7 @@ minetest.register_globalstep(function(dtime) elseif enable_damage and not is_immortal then -- Damage enabled, not immortal: Deal void damage (4 HP / 0.5 seconds) if player:get_hp() > 0 then - death_msg(player, S("@1 fell into the endless void.", player:get_player_name())) - player:set_hp(player:get_hp() - VOID_DAMAGE) + mcl_util.deal_damage(player, VOID_DAMAGE, {type = "out_of_world"}) end end end diff --git a/mods/ENVIRONMENT/mcl_void_damage/mod.conf b/mods/ENVIRONMENT/mcl_void_damage/mod.conf index 3f34fa5a..1358e521 100644 --- a/mods/ENVIRONMENT/mcl_void_damage/mod.conf +++ b/mods/ENVIRONMENT/mcl_void_damage/mod.conf @@ -1,4 +1,4 @@ name = mcl_void_damage author = Wuzzy description = Deal damage to entities stuck in the deep void -depends = mcl_worlds, mcl_death_messages +depends = mcl_worlds diff --git a/mods/ENVIRONMENT/mcl_weather/init.lua b/mods/ENVIRONMENT/mcl_weather/init.lua index e4ebfb2d..e1324299 100644 --- a/mods/ENVIRONMENT/mcl_weather/init.lua +++ b/mods/ENVIRONMENT/mcl_weather/init.lua @@ -1,4 +1,4 @@ -local modpath = minetest.get_modpath("mcl_weather") +local modpath = minetest.get_modpath(minetest.get_current_modname()) mcl_weather = {} @@ -12,6 +12,6 @@ dofile(modpath.."/snow.lua") dofile(modpath.."/rain.lua") dofile(modpath.."/nether_dust.lua") -if minetest.get_modpath("lightning") ~= nil then +if minetest.get_modpath("lightning") then dofile(modpath.."/thunder.lua") end diff --git a/mods/ENVIRONMENT/mcl_weather/nether_dust.lua b/mods/ENVIRONMENT/mcl_weather/nether_dust.lua index 16cdc948..d328dae2 100644 --- a/mods/ENVIRONMENT/mcl_weather/nether_dust.lua +++ b/mods/ENVIRONMENT/mcl_weather/nether_dust.lua @@ -2,7 +2,7 @@ mcl_weather.nether_dust = {} mcl_weather.nether_dust.particles_count = 99 -- calculates coordinates and draw particles for Nether dust -mcl_weather.nether_dust.add_dust_particles = function(player) +function mcl_weather.nether_dust.add_dust_particles(player) for i=mcl_weather.nether_dust.particles_count, 1,-1 do local rpx, rpy, rpz = mcl_weather.get_random_pos_by_player_look_dir(player) minetest.add_particle({ diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index d8425784..220b6100 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -20,7 +20,7 @@ mcl_weather.rain = { init_done = false, } -mcl_weather.rain.sound_handler = function(player) +function mcl_weather.rain.sound_handler(player) return minetest.sound_play("weather_rain", { to_player = player:get_player_name(), loop = true, @@ -28,7 +28,7 @@ mcl_weather.rain.sound_handler = function(player) end -- set skybox based on time (uses skycolor api) -mcl_weather.rain.set_sky_box = function() +function mcl_weather.rain.set_sky_box() if mcl_weather.state == "rain" then mcl_weather.skycolor.add_layer( "weather-pack-rain-sky", @@ -46,8 +46,7 @@ end -- creating manually parctiles instead of particles spawner because of easier to control -- spawn position. -mcl_weather.rain.add_rain_particles = function(player) - +function mcl_weather.rain.add_rain_particles(player) mcl_weather.rain.last_rp_count = 0 for i=mcl_weather.rain.particles_count, 1,-1 do local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player) @@ -70,7 +69,7 @@ mcl_weather.rain.add_rain_particles = function(player) end -- Simple random texture getter -mcl_weather.rain.get_texture = function() +function mcl_weather.rain.get_texture() local texture_name local random_number = math.random() if random_number > 0.33 then @@ -85,7 +84,7 @@ end -- register player for rain weather. -- basically needs for origin sky reference and rain sound controls. -mcl_weather.rain.add_player = function(player) +function mcl_weather.rain.add_player(player) if mcl_weather.players[player:get_player_name()] == nil then local player_meta = {} player_meta.origin_sky = {player:get_sky()} @@ -95,9 +94,9 @@ end -- remove player from player list effected by rain. -- be sure to remove sound before removing player otherwise soundhandler reference will be lost. -mcl_weather.rain.remove_player = function(player) +function mcl_weather.rain.remove_player(player) local player_meta = mcl_weather.players[player:get_player_name()] - if player_meta ~= nil and player_meta.origin_sky ~= nil then + if player_meta and player_meta.origin_sky then player:set_clouds({color="#FFF0F0E5"}) mcl_weather.players[player:get_player_name()] = nil end @@ -119,14 +118,14 @@ end) -- adds and removes rain sound depending how much rain particles around player currently exist. -- have few seconds delay before each check to avoid on/off sound too often -- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance. -mcl_weather.rain.update_sound = function(player) +function mcl_weather.rain.update_sound(player) local player_meta = mcl_weather.players[player:get_player_name()] - if player_meta ~= nil then - if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > minetest.get_gametime() then + if player_meta then + if player_meta.sound_updated and player_meta.sound_updated + 5 > minetest.get_gametime() then return false end - if player_meta.sound_handler ~= nil then + if player_meta.sound_handler then if mcl_weather.rain.last_rp_count == 0 then minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0) player_meta.sound_handler = nil @@ -140,9 +139,9 @@ mcl_weather.rain.update_sound = function(player) end -- rain sound removed from player. -mcl_weather.rain.remove_sound = function(player) +function mcl_weather.rain.remove_sound(player) local player_meta = mcl_weather.players[player:get_player_name()] - if player_meta ~= nil and player_meta.sound_handler ~= nil then + if player_meta and player_meta.sound_handler then minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0) player_meta.sound_handler = nil player_meta.sound_updated = nil @@ -150,7 +149,7 @@ mcl_weather.rain.remove_sound = function(player) end -- callback function for removing rain -mcl_weather.rain.clear = function() +function mcl_weather.rain.clear() mcl_weather.rain.raining = false mcl_weather.rain.sky_last_update = -1 mcl_weather.rain.init_done = false @@ -166,11 +165,10 @@ minetest.register_globalstep(function(dtime) if mcl_weather.state ~= "rain" then return false end - mcl_weather.rain.make_weather() end) -mcl_weather.rain.make_weather = function() +function mcl_weather.rain.make_weather() if mcl_weather.rain.init_done == false then mcl_weather.rain.raining = true mcl_weather.rain.set_sky_box() @@ -190,7 +188,7 @@ mcl_weather.rain.make_weather = function() end -- Switch the number of raindrops: "thunder" for many raindrops, otherwise for normal raindrops -mcl_weather.rain.set_particles_mode = function(mode) +function mcl_weather.rain.set_particles_mode(mode) if mode == "thunder" then mcl_weather.rain.particles_count = PARTICLES_COUNT_THUNDER else @@ -249,7 +247,7 @@ if mcl_weather.allow_abm then end end end - }) + }) -- Wetten the soil minetest.register_abm({ @@ -264,7 +262,7 @@ if mcl_weather.allow_abm then end end end - }) + }) end if mcl_weather.reg_weathers.rain == nil then diff --git a/mods/ENVIRONMENT/mcl_weather/screenshot.png b/mods/ENVIRONMENT/mcl_weather/screenshot.png deleted file mode 100644 index 1ee3ea05..00000000 Binary files a/mods/ENVIRONMENT/mcl_weather/screenshot.png and /dev/null differ diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index 061634fc..6b89c33b 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -11,7 +11,7 @@ mcl_weather.skycolor = { -- Update interval. update_interval = 15, - -- Main sky colors: starts from midnight to midnight. + -- Main sky colors: starts from midnight to midnight. -- Please do not set directly. Use add_layer instead. colors = {}, @@ -205,8 +205,8 @@ mcl_weather.skycolor = { -- Returns first player sky color. I assume that all players are in same color layout. get_current_bg_color = function() local players = mcl_weather.skycolor.utils.get_players(nil) - for _, player in ipairs(players) do - return player:get_sky() + if players[1] then + return players[1]:get_sky() end return nil end @@ -235,7 +235,7 @@ minetest.register_globalstep(function(dtime) end) -local initsky = function(player) +local function initsky(player) if (mcl_weather.skycolor.active) then mcl_weather.skycolor.force_update = true end diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index 3a0c539e..9f89a3a0 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -5,80 +5,80 @@ mcl_weather.snow = {} mcl_weather.snow.particles_count = 15 mcl_weather.snow.init_done = false --- calculates coordinates and draw particles for snow weather -mcl_weather.snow.add_snow_particles = function(player) - mcl_weather.rain.last_rp_count = 0 - for i=mcl_weather.snow.particles_count, 1,-1 do - local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player) - random_pos_y = math.random() + math.random(player:get_pos().y - 1, player:get_pos().y + 7) - if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then - mcl_weather.rain.last_rp_count = mcl_weather.rain.last_rp_count + 1 - minetest.add_particle({ - pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z}, - velocity = {x = math.random(-100,100)*0.001, y = math.random(-300,-100)*0.004, z = math.random(-100,100)*0.001}, - acceleration = {x = 0, y=0, z = 0}, - expirationtime = 8.0, - size = 1, - collisiondetection = true, - collision_removal = true, - object_collision = false, - vertical = false, - texture = mcl_weather.snow.get_texture(), - playername = player:get_player_name() - }) - end - end +-- calculates coordinates and draw particles for snow weather +function mcl_weather.snow.add_snow_particles(player) + mcl_weather.rain.last_rp_count = 0 + for i=mcl_weather.snow.particles_count, 1,-1 do + local random_pos_x, _, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player) + local random_pos_y = math.random() + math.random(player:get_pos().y - 1, player:get_pos().y + 7) + if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then + mcl_weather.rain.last_rp_count = mcl_weather.rain.last_rp_count + 1 + minetest.add_particle({ + pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z}, + velocity = {x = math.random(-100,100)*0.001, y = math.random(-300,-100)*0.004, z = math.random(-100,100)*0.001}, + acceleration = {x = 0, y=0, z = 0}, + expirationtime = 8.0, + size = 1, + collisiondetection = true, + collision_removal = true, + object_collision = false, + vertical = false, + texture = mcl_weather.snow.get_texture(), + playername = player:get_player_name() + }) + end + end end -mcl_weather.snow.set_sky_box = function() - mcl_weather.skycolor.add_layer( - "weather-pack-snow-sky", - {{r=0, g=0, b=0}, - {r=85, g=86, b=86}, - {r=135, g=135, b=135}, - {r=85, g=86, b=86}, - {r=0, g=0, b=0}}) - mcl_weather.skycolor.active = true - for _, player in pairs(get_connected_players()) do - player:set_clouds({color="#ADADADE8"}) - end - mcl_weather.skycolor.active = true +function mcl_weather.snow.set_sky_box() + mcl_weather.skycolor.add_layer( + "weather-pack-snow-sky", + {{r=0, g=0, b=0}, + {r=85, g=86, b=86}, + {r=135, g=135, b=135}, + {r=85, g=86, b=86}, + {r=0, g=0, b=0}}) + mcl_weather.skycolor.active = true + for _, player in pairs(get_connected_players()) do + player:set_clouds({color="#ADADADE8"}) + end + mcl_weather.skycolor.active = true end -mcl_weather.snow.clear = function() - mcl_weather.skycolor.remove_layer("weather-pack-snow-sky") - mcl_weather.snow.init_done = false +function mcl_weather.snow.clear() + mcl_weather.skycolor.remove_layer("weather-pack-snow-sky") + mcl_weather.snow.init_done = false end -- Simple random texture getter -mcl_weather.snow.get_texture = function() - return "weather_pack_snow_snowflake"..math.random(1,2)..".png" +function mcl_weather.snow.get_texture() + return "weather_pack_snow_snowflake"..math.random(1,2)..".png" end local timer = 0 minetest.register_globalstep(function(dtime) - if mcl_weather.state ~= "snow" then - return false - end - - timer = timer + dtime; - if timer >= 0.5 then - timer = 0 - else - return - end + if mcl_weather.state ~= "snow" then + return false + end - if mcl_weather.snow.init_done == false then - mcl_weather.snow.set_sky_box() - mcl_weather.snow.init_done = true - end + timer = timer + dtime; + if timer >= 0.5 then + timer = 0 + else + return + end - for _, player in pairs(get_connected_players()) do - if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then - return false - end - mcl_weather.snow.add_snow_particles(player) - end + if mcl_weather.snow.init_done == false then + mcl_weather.snow.set_sky_box() + mcl_weather.snow.init_done = true + end + + for _, player in pairs(get_connected_players()) do + if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then + return false + end + mcl_weather.snow.add_snow_particles(player) + end end) -- register snow weather diff --git a/mods/ENVIRONMENT/mcl_weather/thunder.lua b/mods/ENVIRONMENT/mcl_weather/thunder.lua index ece67317..f8e5a037 100644 --- a/mods/ENVIRONMENT/mcl_weather/thunder.lua +++ b/mods/ENVIRONMENT/mcl_weather/thunder.lua @@ -4,60 +4,58 @@ local get_connected_players = minetest.get_connected_players lightning.auto = false mcl_weather.thunder = { - next_strike = 0, - min_delay = 3, - max_delay = 12, - init_done = false, + next_strike = 0, + min_delay = 3, + max_delay = 12, + init_done = false, } minetest.register_globalstep(function(dtime) - if mcl_weather.get_weather() ~= "thunder" then - return false - end - - mcl_weather.rain.set_particles_mode("thunder") - mcl_weather.rain.make_weather() + if mcl_weather.get_weather() ~= "thunder" then + return false + end - if mcl_weather.thunder.init_done == false then - mcl_weather.skycolor.add_layer( - "weather-pack-thunder-sky", - {{r=0, g=0, b=0}, - {r=40, g=40, b=40}, - {r=85, g=86, b=86}, - {r=40, g=40, b=40}, - {r=0, g=0, b=0}}) - mcl_weather.skycolor.active = true - for _, player in pairs(get_connected_players()) do - player:set_clouds({color="#3D3D3FE8"}) - end - mcl_weather.thunder.init_done = true - end - - if (mcl_weather.thunder.next_strike <= minetest.get_gametime()) then - lightning.strike() - local delay = math.random(mcl_weather.thunder.min_delay, mcl_weather.thunder.max_delay) - mcl_weather.thunder.next_strike = minetest.get_gametime() + delay - end + mcl_weather.rain.set_particles_mode("thunder") + mcl_weather.rain.make_weather() + if mcl_weather.thunder.init_done == false then + mcl_weather.skycolor.add_layer("weather-pack-thunder-sky", { + {r=0, g=0, b=0}, + {r=40, g=40, b=40}, + {r=85, g=86, b=86}, + {r=40, g=40, b=40}, + {r=0, g=0, b=0}, + }) + mcl_weather.skycolor.active = true + for _, player in pairs(get_connected_players()) do + player:set_clouds({color="#3D3D3FE8"}) + end + mcl_weather.thunder.init_done = true + end + if (mcl_weather.thunder.next_strike <= minetest.get_gametime()) then + lightning.strike() + local delay = math.random(mcl_weather.thunder.min_delay, mcl_weather.thunder.max_delay) + mcl_weather.thunder.next_strike = minetest.get_gametime() + delay + end end) -mcl_weather.thunder.clear = function() - mcl_weather.rain.clear() - mcl_weather.skycolor.remove_layer("weather-pack-thunder-sky") - mcl_weather.skycolor.remove_layer("lightning") - mcl_weather.thunder.init_done = false +function mcl_weather.thunder.clear() + mcl_weather.rain.clear() + mcl_weather.skycolor.remove_layer("weather-pack-thunder-sky") + mcl_weather.skycolor.remove_layer("lightning") + mcl_weather.thunder.init_done = false end -- register thunderstorm weather if mcl_weather.reg_weathers.thunder == nil then - mcl_weather.reg_weathers.thunder = { - clear = mcl_weather.thunder.clear, - light_factor = 0.33333, - -- 10min - 20min - min_duration = 600, - max_duration = 1200, - transitions = { - [100] = "rain", - } - } + mcl_weather.reg_weathers.thunder = { + clear = mcl_weather.thunder.clear, + light_factor = 0.33333, + -- 10min - 20min + min_duration = 600, + max_duration = 1200, + transitions = { + [100] = "rain", + }, + } end diff --git a/mods/ENVIRONMENT/mcl_weather/weather_core.lua b/mods/ENVIRONMENT/mcl_weather/weather_core.lua index d3772dc7..34f69406 100644 --- a/mods/ENVIRONMENT/mcl_weather/weather_core.lua +++ b/mods/ENVIRONMENT/mcl_weather/weather_core.lua @@ -1,27 +1,29 @@ -local S = minetest.get_translator("mcl_weather") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math -- weather states, 'none' is default, other states depends from active mods mcl_weather.state = "none" - + -- player list for saving player meta info mcl_weather.players = {} - + -- default weather check interval for global step mcl_weather.check_interval = 5 - + -- weather min duration mcl_weather.min_duration = 600 - + -- weather max duration mcl_weather.max_duration = 9000 -- weather calculated end time mcl_weather.end_time = nil - + -- registered weathers mcl_weather.reg_weathers = {} --- global flag to disable/enable ABM logic. +-- global flag to disable/enable ABM logic. mcl_weather.allow_abm = true mcl_weather.reg_weathers["none"] = { @@ -37,7 +39,7 @@ mcl_weather.reg_weathers["none"] = { local storage = minetest.get_mod_storage() -- Save weather into mod storage, so it can be loaded after restarting the server -local save_weather = function() +local function save_weather() if not mcl_weather.end_time then return end storage:set_string("mcl_weather_state", mcl_weather.state) storage:set_int("mcl_weather_end_time", mcl_weather.end_time) @@ -45,17 +47,17 @@ local save_weather = function() end minetest.register_on_shutdown(save_weather) -mcl_weather.get_rand_end_time = function(min_duration, max_duration) +function mcl_weather.get_rand_end_time(min_duration, max_duration) local r - if min_duration ~= nil and max_duration ~= nil then + if min_duration and max_duration then r = math.random(min_duration, max_duration) else r = math.random(mcl_weather.min_duration, mcl_weather.max_duration) - end + end return minetest.get_gametime() + r end -mcl_weather.get_current_light_factor = function() +function mcl_weather.get_current_light_factor() if mcl_weather.state == "none" then return nil else @@ -66,7 +68,7 @@ end -- Returns true if pos is outdoor. -- Outdoor is defined as any node in the Overworld under open sky. -- FIXME: Nodes below glass also count as “outdoor”, this should not be the case. -mcl_weather.is_outdoor = function(pos) +function mcl_weather.is_outdoor(pos) local cpos = {x=pos.x, y=pos.y+1, z=pos.z} local dim = mcl_worlds.pos_to_dimension(cpos) if minetest.get_node_light(cpos, 0.5) == 15 and dim == "overworld" then @@ -77,11 +79,11 @@ end -- checks if player is undewater. This is needed in order to -- turn off weather particles generation. -mcl_weather.is_underwater = function(player) +function mcl_weather.is_underwater(player) local ppos = player:get_pos() local offset = player:get_eye_offset() - local player_eye_pos = {x = ppos.x + offset.x, - y = ppos.y + offset.y + 1.5, + local player_eye_pos = {x = ppos.x + offset.x, + y = ppos.y + offset.y + 1.5, z = ppos.z + offset.z} local node_level = minetest.get_node_level(player_eye_pos) if node_level == 8 or node_level == 7 then @@ -91,14 +93,12 @@ mcl_weather.is_underwater = function(player) end -- trying to locate position for particles by player look direction for performance reason. --- it is costly to generate many particles around player so goal is focus mainly on front view. -mcl_weather.get_random_pos_by_player_look_dir = function(player) +-- it is costly to generate many particles around player so goal is focus mainly on front view. +function mcl_weather.get_random_pos_by_player_look_dir(player) local look_dir = player:get_look_dir() local player_pos = player:get_pos() - local random_pos_x = 0 - local random_pos_y = 0 - local random_pos_z = 0 + local random_pos_x, random_pos_y, random_pos_z if look_dir.x > 0 then if look_dir.z > 0 then @@ -123,6 +123,7 @@ mcl_weather.get_random_pos_by_player_look_dir = function(player) end local t, wci = 0, mcl_weather.check_interval + minetest.register_globalstep(function(dtime) t = t + dtime if t < wci then return end @@ -146,7 +147,7 @@ minetest.register_globalstep(function(dtime) end) -- Sets random weather (which could be 'none' (no weather)). -mcl_weather.set_random_weather = function(weather_name, weather_meta) +function mcl_weather.set_random_weather(weather_name, weather_meta) if weather_meta == nil then return end local transitions = weather_meta.transitions local random_roll = math.random(0,100) @@ -166,11 +167,11 @@ end -- * explicit_end_time is OPTIONAL. If specified, explicitly set the -- gametime (minetest.get_gametime) in which the weather ends. -- * changer is OPTIONAL, for logging purposes. -mcl_weather.change_weather = function(new_weather, explicit_end_time, changer_name) +function mcl_weather.change_weather(new_weather, explicit_end_time, changer_name) local changer_name = changer_name or debug.getinfo(2).name.."()" - if (mcl_weather.reg_weathers ~= nil and mcl_weather.reg_weathers[new_weather] ~= nil) then - if (mcl_weather.state ~= nil and mcl_weather.reg_weathers[mcl_weather.state] ~= nil) then + if (mcl_weather.reg_weathers and mcl_weather.reg_weathers[new_weather]) then + if (mcl_weather.state and mcl_weather.reg_weathers[mcl_weather.state]) then mcl_weather.reg_weathers[mcl_weather.state].clear() end @@ -199,7 +200,7 @@ mcl_weather.change_weather = function(new_weather, explicit_end_time, changer_na return false end -mcl_weather.get_weather = function() +function mcl_weather.get_weather() return mcl_weather.state end @@ -208,7 +209,7 @@ minetest.register_privilege("weather_manager", { give_to_singleplayer = false }) --- Weather command definition. Set +-- Weather command definition. Set minetest.register_chatcommand("weather", { params = "(clear | rain | snow | thunder) []", description = S("Changes the weather to the specified parameter."), @@ -268,12 +269,12 @@ minetest.register_chatcommand("toggledownfall", { -- Configuration setting which allows user to disable ABM for weathers (if they use it). -- Weather mods expected to be use this flag before registering ABM. local weather_allow_abm = minetest.settings:get_bool("weather_allow_abm") -if weather_allow_abm ~= nil and weather_allow_abm == false then +if weather_allow_abm == false then mcl_weather.allow_abm = false -end +end -local load_weather = function() +local function load_weather() local weather = storage:get_string("mcl_weather_state") if weather and weather ~= "" then mcl_weather.state = weather diff --git a/mods/HELP/doc/doc/init.lua b/mods/HELP/doc/doc/init.lua index 9057cda8..30490075 100644 --- a/mods/HELP/doc/doc/init.lua +++ b/mods/HELP/doc/doc/init.lua @@ -1,6 +1,10 @@ -local S = minetest.get_translator("doc") +local S = minetest.get_translator(minetest.get_current_modname()) local F = function(f) return minetest.formspec_escape(S(f)) end +local mod_central_messages = minetest.get_modpath("central_message") +local mod_inventory_plus = minetest.get_modpath("inventory_plus") + +local math = math local colorize = minetest.colorize doc = {} @@ -35,10 +39,10 @@ doc.FORMSPEC.ENTRY_HEIGHT = doc.FORMSPEC.ENTRY_END_Y - doc.FORMSPEC.ENTRY_START_ -- Internal helper variables local DOC_INTRO = S("This is the help.") -local COLOR_NOT_VIEWED = mcl_colors.AQUA -local COLOR_VIEWED = mcl_colors.WHITE -local COLOR_HIDDEN = mcl_colors.GRAY -local COLOR_ERROR = mcl_colors.RED +local COLOR_NOT_VIEWED = "#00FFFF" -- cyan +local COLOR_VIEWED = "#FFFFFF" -- white +local COLOR_HIDDEN = "#999999" -- gray +local COLOR_ERROR = "#FF0000" -- red local CATEGORYFIELDSIZE = { WIDTH = math.ceil(doc.FORMSPEC.WIDTH / 4), @@ -63,7 +67,7 @@ local set_category_order_was_called = false local function get_entry(category_id, entry_id) local category = doc.data.categories[category_id] local entry - if category ~= nil then + if category then entry = category.entries[entry_id] end if category == nil or entry == nil then @@ -93,7 +97,7 @@ end -- Add a new category function doc.add_category(id, def) - if doc.data.categories[id] == nil and id ~= nil then + if doc.data.categories[id] == nil and id then doc.data.categories[id] = {} doc.data.categories[id].entries = {} doc.data.categories[id].entry_count = 0 @@ -123,7 +127,7 @@ end -- Add a new entry function doc.add_entry(category_id, entry_id, def) local cat = doc.data.categories[category_id] - if cat ~= nil then + if cat then local hidden = def.hidden or (def.hidden == nil and cat.def.hide_entries_by_default) if hidden then cat.hidden_count = cat.hidden_count + 1 @@ -177,7 +181,7 @@ function doc.mark_entry_as_revealed(playername, category_id, entry_id) doc.data.players[playername].entry_textlist_needs_updating = true -- Notify player of entry revelation if doc.data.players[playername].stored_data.notify_on_reveal == true then - if minetest.get_modpath("central_message") ~= nil then + if mod_central_messages then local cat = doc.data.categories[category_id] cmsg.push_message_player(minetest.get_player_by_name(playername), S("New help entry unlocked: @1 > @2", cat.def.name, entry.name)) end @@ -224,7 +228,7 @@ function doc.mark_all_entries_as_revealed(playername) msg = S("All help entries are already revealed.") end -- Notify - if minetest.get_modpath("central_message") ~= nil then + if mod_central_messages then cmsg.push_message_player(minetest.get_player_by_name(playername), msg) else minetest.chat_send_player(playername, msg) @@ -233,7 +237,7 @@ end -- Returns true if the specified entry has been viewed by the player function doc.entry_viewed(playername, category_id, entry_id) - local entry, category_id, entry_id = get_entry(category_id, entry_id) + local _, category_id, entry_id = get_entry(category_id, entry_id) if doc.data.players[playername].stored_data.viewed[category_id] == nil then return false else @@ -243,7 +247,7 @@ end -- Returns true if the specified entry is hidden from the player function doc.entry_revealed(playername, category_id, entry_id) - local entry, category_id, entry_id = get_entry(category_id, entry_id) + local _, category_id, entry_id = get_entry(category_id, entry_id) local hidden = doc.data.categories[category_id].entries[entry_id].hidden if doc.data.players[playername].stored_data.revealed[category_id] == nil then return not hidden @@ -302,7 +306,7 @@ function doc.show_entry(playername, category_id, entry_id, ignore_hidden) minetest.show_formspec(playername, "doc:error_no_categories", doc.formspec_error_no_categories()) return end - local entry, category_id, entry_id = get_entry(category_id, entry_id) + local _, category_id, entry_id = get_entry(category_id, entry_id) if ignore_hidden or doc.entry_revealed(playername, category_id, entry_id) then local playerdata = doc.data.players[playername] playerdata.category = category_id @@ -427,7 +431,7 @@ end -- Returns the currently viewed entry and/or category of the player function doc.get_selection(playername) local playerdata = doc.data.players[playername] - if playerdata ~= nil then + if playerdata then local cat = playerdata.category if cat then local entry = playerdata.entry @@ -448,18 +452,18 @@ end doc.entry_builders = {} -- Scrollable freeform text -doc.entry_builders.text = function(data) +function doc.entry_builders.text(data) local formstring = doc.widgets.text(data, doc.FORMSPEC.ENTRY_START_X, doc.FORMSPEC.ENTRY_START_Y, doc.FORMSPEC.ENTRY_WIDTH - 0.4, doc.FORMSPEC.ENTRY_HEIGHT) return formstring end -- Scrollable freeform text with an optional standard gallery (3 rows, 3:2 aspect ratio) -doc.entry_builders.text_and_gallery = function(data, playername) +function doc.entry_builders.text_and_gallery(data, playername) -- How much height the image gallery “steals” from the text widget local stolen_height = 0 local formstring = "" -- Only add the gallery if images are in the data, otherwise, the text widget gets all of the space - if data.images ~= nil then + if data.images then local gallery gallery, stolen_height = doc.widgets.gallery(data.images, playername, nil, doc.FORMSPEC.ENTRY_END_Y + 0.2, nil, nil, nil, nil, false) formstring = formstring .. gallery @@ -476,7 +480,7 @@ end doc.widgets = {} -- Scrollable freeform text -doc.widgets.text = function(data, x, y, width, height) +function doc.widgets.text(data, x, y, width, height) if x == nil then x = doc.FORMSPEC.ENTRY_START_X end @@ -502,7 +506,7 @@ end -- Image gallery -- Currently, only one gallery per entry is supported. TODO: Add support for multiple galleries in an entry (low priority) -doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, rows, align_left, align_top) +function doc.widgets.gallery(imagedata, playername, x, y, aspect_ratio, width, rows, align_left, align_top) if playername == nil then return nil end -- emergency exit local formstring = "" @@ -587,13 +591,11 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, formstring = formstring .. "label["..nx..","..ny..";"..i.."]" pos = pos + 1 end - local bw, bh - return formstring, ih end -- Direct formspec -doc.entry_builders.formspec = function(data) +function doc.entry_builders.formspec(data) return data end @@ -607,7 +609,7 @@ do minetest.log("action", "[doc] doc.mt opened.") local string = file:read() io.close(file) - if(string ~= nil) then + if string then local savetable = minetest.deserialize(string) for name, players_stored_data in pairs(savetable.players_stored_data) do doc.data.players[name] = {} @@ -674,13 +676,13 @@ function doc.formspec_main(playername) local data = doc.data.categories[id] local bw = doc.FORMSPEC.WIDTH / math.floor(((doc.data.category_count-1) / CATEGORYFIELDSIZE.HEIGHT)+1) -- Skip categories which do not exist - if data ~= nil then + if data then -- Category buton local button = "button["..((x-1)*bw)..","..y..";"..bw..",1;doc_button_category_"..id..";"..minetest.formspec_escape(data.def.name).."]" local tooltip = "" -- Optional description - if data.def.description ~= nil then - tooltip = "tooltip[doc_button_category_"..id..";"..minetest.formspec_escape(data.def.description).."]" + if data.def.description then + tooltip = "tooltip[doc_button_category_"..id..";"..minetest.formspec_escape(data.def.description).."]" end formstring = formstring .. button .. tooltip y = y + 1 @@ -703,7 +705,7 @@ function doc.formspec_main(playername) end end local sel = doc.data.categories[doc.data.players[playername].category] - if sel ~= nil then + if sel then formstring = formstring .. ";" formstring = formstring .. doc.data.categories[doc.data.players[playername].category].order_position end @@ -713,7 +715,7 @@ function doc.formspec_main(playername) notify_checkbox_y = doc.FORMSPEC.HEIGHT-1 end local text - if minetest.get_modpath("central_message") then + if mod_central_messages then text = F("Notify me when new help is available") else text = F("Play notification sound when new help is available") @@ -770,7 +772,7 @@ function doc.generate_entry_list(cid, playername) if name == nil or name == "" then name = S("Nameless entry (@1)", eid) if doc.entry_viewed(playername, cid, eid) then - viewedprefix = mcl_colors.RED + viewedprefix = "#FF4444" else viewedprefix = COLOR_ERROR end @@ -804,7 +806,7 @@ function doc.get_sorted_entry_names(cid) local cat = doc.data.categories[cid] local used_eids = {} -- Helper function to extract the entry ID out of the output table - local extract = function(entry_table) + local function extract(entry_table) local eids = {} for k,v in pairs(entry_table) do local eid = v.eid @@ -946,7 +948,7 @@ function doc.process_form(player,formname,fields) local playername = player:get_player_name() --[[ process clicks on the tab header ]] if(formname == "doc:main" or formname == "doc:category" or formname == "doc:entry") then - if fields.doc_header ~= nil then + if fields.doc_header then local tab = tonumber(fields.doc_header) local formspec, subformname, contents local cid, eid @@ -961,7 +963,7 @@ function doc.process_form(player,formname,fields) elseif(tab==3) then doc.data.players[playername].galidx = 1 contents = doc.formspec_entry(cid, eid, playername) - if cid ~= nil and eid ~= nil then + if cid and eid then doc.mark_entry_as_viewed(playername, cid, eid) end subformname = "entry" @@ -986,7 +988,7 @@ function doc.process_form(player,formname,fields) if fields["doc_mainlist"] then local event = minetest.explode_textlist_event(fields["doc_mainlist"]) local cid = doc.data.category_order[event.index] - if cid ~= nil then + if cid then if event.type == "CHG" then doc.data.players[playername].catsel = nil doc.data.players[playername].category = cid @@ -1016,10 +1018,10 @@ function doc.process_form(player,formname,fields) elseif(formname == "doc:category") then if fields["doc_button_goto_entry"] then local cid = doc.data.players[playername].category - if cid ~= nil then + if cid then local eid = nil local eids, catsel = doc.data.players[playername].entry_ids, doc.data.players[playername].catsel - if eids ~= nil and catsel ~= nil then + if eids and catsel then eid = eids[catsel] end doc.data.players[playername].galidx = 1 @@ -1042,7 +1044,7 @@ function doc.process_form(player,formname,fields) local cid = doc.data.players[playername].category local eid = nil local eids, catsel = doc.data.players[playername].entry_ids, event.index - if eids ~= nil and catsel ~= nil then + if eids and catsel then eid = eids[catsel] end doc.mark_entry_as_viewed(playername, cid, eid) @@ -1103,7 +1105,7 @@ function doc.process_form(player,formname,fields) minetest.show_formspec(playername, "doc:entry", formspec) end else - if fields["doc_inventory_plus"] and minetest.get_modpath("inventory_plus") then + if fields["doc_inventory_plus"] and mod_inventory_plus then doc.show_doc(playername) return end @@ -1171,18 +1173,18 @@ minetest.register_on_joinplayer(function(player) end -- Add button for Inventory++ - if minetest.get_modpath("inventory_plus") ~= nil then + if mod_inventory_plus then inventory_plus.register_button(player, "doc_inventory_plus", S("Help")) end end) ---[[ Add buttons for inventory mods ]] -local button_action = function(player) +local function button_action(player) doc.show_doc(player:get_player_name()) end -- Unified Inventory -if minetest.get_modpath("unified_inventory") ~= nil then +if minetest.get_modpath("unified_inventory") then unified_inventory.register_button("doc", { type = "image", image = "doc_button_icon_hires.png", @@ -1192,7 +1194,7 @@ if minetest.get_modpath("unified_inventory") ~= nil then end -- sfinv_buttons -if minetest.get_modpath("sfinv_buttons") ~= nil then +if minetest.get_modpath("sfinv_buttons") then sfinv_buttons.register_button("doc", { image = "doc_button_icon_lores.png", tooltip = S("Collection of help texts"), diff --git a/mods/HELP/doc/doc/mod.conf b/mods/HELP/doc/doc/mod.conf index 54064551..0f65ddff 100644 --- a/mods/HELP/doc/doc/mod.conf +++ b/mods/HELP/doc/doc/mod.conf @@ -2,4 +2,3 @@ name = doc author = Wuzzy description = A simple in-game documentation system which enables mods to add help entries based on templates. optional_depends = unified_inventory, sfinv_buttons, central_message, inventory_plus -depends = mcl_colors diff --git a/mods/HELP/doc/doc/screenshot.png b/mods/HELP/doc/doc/screenshot.png deleted file mode 100644 index 90946a99..00000000 Binary files a/mods/HELP/doc/doc/screenshot.png and /dev/null differ diff --git a/mods/HELP/doc/doc_identifier/init.lua b/mods/HELP/doc/doc_identifier/init.lua index 2e041ae2..c1c2043d 100644 --- a/mods/HELP/doc/doc_identifier/init.lua +++ b/mods/HELP/doc/doc_identifier/init.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("doc_identifier") +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_doc_basics = minetest.get_modpath("doc_basics") local doc_identifier = {} @@ -6,15 +8,16 @@ doc_identifier.registered_objects = {} -- API doc.sub.identifier = {} -doc.sub.identifier.register_object = function(object_name, category_id, entry_id) + +function doc.sub.identifier.register_object(object_name, category_id, entry_id) doc_identifier.registered_objects[object_name] = { category = category_id, entry = entry_id } end -- END OF API -doc_identifier.identify = function(itemstack, user, pointed_thing) +function doc_identifier.identify(itemstack, user, pointed_thing) local username = user:get_player_name() - local show_message = function(username, itype, param) + local function show_message(username, itype, param) local vsize = 2 local message if itype == "error_item" then @@ -24,9 +27,9 @@ doc_identifier.identify = function(itemstack, user, pointed_thing) elseif itype == "error_unknown" then vsize = vsize + 2 local mod - if param ~= nil then + if param then local colon = string.find(param, ":") - if colon ~= nil and colon > 1 then + if colon and colon > 1 then mod = string.sub(param,1,colon-1) end end @@ -36,8 +39,8 @@ doc_identifier.identify = function(itemstack, user, pointed_thing) S("• The author of the game or a mod has made a mistake") message = message .. "\n\n" - if mod ~= nil then - if minetest.get_modpath(mod) ~= nil then + if mod then + if minetest.get_modpath(mod) then message = message .. S("It appears to originate from the mod “@1”, which is enabled.", mod) message = message .. "\n" else @@ -45,7 +48,7 @@ doc_identifier.identify = function(itemstack, user, pointed_thing) message = message .. "\n" end end - if param ~= nil then + if param then message = message .. S("Its identifier is “@1”.", param) end elseif itype == "error_ignore" then @@ -66,8 +69,8 @@ doc_identifier.identify = function(itemstack, user, pointed_thing) if pointed_thing.type == "node" then local pos = pointed_thing.under local node = minetest.get_node(pos) - if minetest.registered_nodes[node.name] ~= nil then - local nodedef = minetest.registered_nodes[node.name] + if minetest.registered_nodes[node.name] then + --local nodedef = minetest.registered_nodes[node.name] if(node.name == "ignore") then show_message(username, "error_ignore") elseif doc.entry_exists("nodes", node.name) then @@ -82,14 +85,14 @@ doc_identifier.identify = function(itemstack, user, pointed_thing) local object = pointed_thing.ref local le = object:get_luaentity() if object:is_player() then - if minetest.get_modpath("doc_basics") ~= nil and doc.entry_exists("basics", "players") then + if mod_doc_basics and doc.entry_exists("basics", "players") then doc.show_entry(username, "basics", "players", true) else -- Fallback message show_message(username, "player") end -- luaentity exists - elseif le ~= nil then + elseif le then local ro = doc_identifier.registered_objects[le.name] -- Dropped items if le.name == "__builtin:item" then @@ -112,7 +115,7 @@ doc_identifier.identify = function(itemstack, user, pointed_thing) doc.show_entry(username, "nodes", itemstring, true) end -- A known registered object - elseif ro ~= nil then + elseif ro then doc.show_entry(username, ro.category, ro.entry, true) -- Undefined object (error) elseif minetest.registered_entities[le.name] == nil then @@ -195,10 +198,10 @@ minetest.register_craft({ {"group:stick", ""} } }) -if minetest.get_modpath("mcl_core") ~= nil then +if minetest.get_modpath("mcl_core") then minetest.register_craft({ output = "doc_identifier:identifier_solid", - recipe = { { "mcl_core:glass" }, + recipe = { { "mcl_core:glass" }, { "group:stick" } } }) end diff --git a/mods/HELP/doc/doc_identifier/screenshot.png b/mods/HELP/doc/doc_identifier/screenshot.png deleted file mode 100644 index 13b2540d..00000000 Binary files a/mods/HELP/doc/doc_identifier/screenshot.png and /dev/null differ diff --git a/mods/HELP/doc/doc_items/init.lua b/mods/HELP/doc/doc_items/init.lua index b0be3e12..325ad9ab 100644 --- a/mods/HELP/doc/doc_items/init.lua +++ b/mods/HELP/doc/doc_items/init.lua @@ -1,6 +1,12 @@ -local S = minetest.get_translator("doc_items") +local S = minetest.get_translator(minetest.get_current_modname()) local N = function(s) return s end +local math = math +local string = string + +local tostring = tostring +local pairs = pairs + doc.sub.items = {} -- Template texts @@ -34,13 +40,17 @@ local suppressed = { local forbidden_core_factoids = {} -- Helper functions -local yesno = function(bool) - if bool==true then return S("Yes") - elseif bool==false then return S("No") - else return "N/A" end +local function yesno(bool) + if bool == true then + return S("Yes") + elseif bool == false then + return S("No") + else + return "N/A" + end end -local groups_to_string = function(grouptable, filter) +local function groups_to_string(grouptable, filter) local gstring = "" local groups_count = 0 for id, value in pairs(grouptable) do @@ -50,7 +60,7 @@ local groups_to_string = function(grouptable, filter) -- List seperator gstring = gstring .. S(", ") end - if groupdefs[id] ~= nil and doc.sub.items.settings.friendly_group_names == true then + if groupdefs[id] and doc.sub.items.settings.friendly_group_names == true then gstring = gstring .. groupdefs[id] else gstring = gstring .. id @@ -66,7 +76,7 @@ local groups_to_string = function(grouptable, filter) end -- Removes all text after the first newline (including the newline) -local scrub_newlines = function(text) +local function scrub_newlines(text) local spl = string.split(text, "\n") if spl and #spl > 0 then return spl[1] @@ -76,7 +86,7 @@ local scrub_newlines = function(text) end --[[ Append a newline to text, unless it already ends with a newline. ]] -local newline = function(text) +local function newline(text) if string.sub(text, #text, #text) == "\n" or text == "" then return text else @@ -85,7 +95,7 @@ local newline = function(text) end --[[ Make sure the text ends with two newlines by appending any missing newlines at the end, if neccessary. ]] -local newline2 = function(text) +local function newline2(text) if string.sub(text, #text-1, #text) == "\n\n" or text == "" then return text elseif string.sub(text, #text, #text) == "\n" then @@ -97,7 +107,7 @@ end -- Extract suitable item description for formspec -local description_for_formspec = function(itemstring) +local function description_for_formspec(itemstring) if minetest.registered_items[itemstring] == nil then -- Huh? The item doesn't exist for some reason. Better give a dummy string minetest.log("warning", "[doc] Unknown item detected: "..tostring(itemstring)) @@ -111,26 +121,26 @@ local description_for_formspec = function(itemstring) end end -local get_entry_name = function(itemstring) +local function get_entry_name(itemstring) local def = minetest.registered_items[itemstring] - if def._doc_items_entry_name ~= nil then + if def._doc_items_entry_name then return def._doc_items_entry_name - elseif item_name_overrides[itemstring] ~= nil then + elseif item_name_overrides[itemstring] then return item_name_overrides[itemstring] else return def.description end end -doc.sub.items.get_group_name = function(groupname) - if groupdefs[groupname] ~= nil and doc.sub.items.settings.friendly_group_names == true then +function doc.sub.items.get_group_name(groupname) + if groupdefs[groupname] and doc.sub.items.settings.friendly_group_names == true then return groupdefs[groupname] else return groupname end end -local burntime_to_text = function(burntime) +local function burntime_to_text(burntime) if burntime == nil then return S("unknown") elseif burntime == 1 then @@ -146,16 +156,16 @@ end * Full punch interval * Damage groups ]] -local factoid_toolcaps = function(tool_capabilities, check_uses) +local function factoid_toolcaps(tool_capabilities, check_uses) if forbidden_core_factoids.tool_capabilities then return "" end local formstring = "" if check_uses == nil then check_uses = false end - if tool_capabilities ~= nil and tool_capabilities ~= {} then + if tool_capabilities and tool_capabilities ~= {} then local groupcaps = tool_capabilities.groupcaps - if groupcaps ~= nil then + if groupcaps then local miningcapstr = "" local miningtimesstr = "" local miningusesstr = "" @@ -164,7 +174,7 @@ local factoid_toolcaps = function(tool_capabilities, check_uses) local useslines = 0 for k,v in pairs(groupcaps) do -- Mining capabilities - local minrating, maxrating + --[[local minrating, maxrating if v.times then for rating, time in pairs(v.times) do if minrating == nil then minrating = rating else @@ -177,7 +187,7 @@ local factoid_toolcaps = function(tool_capabilities, check_uses) else minrating = 1 maxrating = 1 - end + end]] local maxlevel = v.maxlevel if not maxlevel then -- Default from tool.h @@ -188,7 +198,7 @@ local factoid_toolcaps = function(tool_capabilities, check_uses) caplines = caplines + 1 for rating=3, 1, -1 do - if v.times ~= nil and v.times[rating] ~= nil then + if v.times and v.times[rating] then local maxtime = v.times[rating] local mintime local mintimestr, maxtimestr @@ -255,7 +265,7 @@ local factoid_toolcaps = function(tool_capabilities, check_uses) -- Weapon data local damage_groups = tool_capabilities.damage_groups - if damage_groups ~= nil then + if damage_groups then formstring = formstring .. S("This is a melee weapon which deals damage by punching.") .. "\n" -- Damage groups formstring = formstring .. S("Maximum damage per hit:") .. "\n" @@ -266,7 +276,7 @@ local factoid_toolcaps = function(tool_capabilities, check_uses) -- Full punch interval local punch = 1.0 - if tool_capabilities.full_punch_interval ~= nil then + if tool_capabilities.full_punch_interval then punch = tool_capabilities.full_punch_interval end formstring = formstring .. S("Full punch interval: @1 s", string.format("%.1f", punch)) @@ -282,7 +292,7 @@ end - Digging times/groups - level group ]] -local factoid_mining_node = function(data) +local function factoid_mining_node(data) if forbidden_core_factoids.node_mining then return "" end @@ -292,7 +302,7 @@ local factoid_mining_node = function(data) -- Check if there are no mining groups at all local nogroups = true for groupname,_ in pairs(mininggroups) do - if data.def.groups[groupname] ~= nil or groupname == "dig_immediate" then + if data.def.groups[groupname] or groupname == "dig_immediate" then nogroups = false break end @@ -324,7 +334,7 @@ local factoid_mining_node = function(data) local minegroupcount = 0 for group,_ in pairs(mininggroups) do local rating = data.def.groups[group] - if rating ~= nil then + if rating then mstring = mstring .. S("• @1: @2", doc.sub.items.get_group_name(group), rating).."\n" minegroupcount = minegroupcount + 1 end @@ -344,18 +354,18 @@ local factoid_mining_node = function(data) end -- Pointing range of itmes -local range_factoid = function(itemstring, def) +local function range_factoid(itemstring, def) local handrange = minetest.registered_items[""].range local itemrange = def.range if itemstring == "" then - if handrange ~= nil then + if handrange then return S("Range: @1", itemrange) else return S("Range: 4") end else if handrange == nil then handrange = 4 end - if itemrange ~= nil then + if itemrange then return S("Range: @1", itemrange) else return S("Range: @1 (@2)", get_entry_name(""), handrange) @@ -364,14 +374,14 @@ local range_factoid = function(itemstring, def) end -- Smelting fuel factoid -local factoid_fuel = function(itemstring, ctype) +local function factoid_fuel(itemstring, ctype) if forbidden_core_factoids.fuel then return "" end local formstring = "" local result, decremented = minetest.get_craft_result({method = "fuel", items = {itemstring}}) - if result ~= nil and result.time > 0 then + if result and result.time > 0 then local base local burntext = burntime_to_text(result.time) if ctype == "tools" then @@ -392,7 +402,7 @@ local factoid_fuel = function(itemstring, ctype) end -- Shows the itemstring of an item -local factoid_itemstring = function(itemstring, playername) +local function factoid_itemstring(itemstring, playername) if forbidden_core_factoids.itemstring then return "" end @@ -405,7 +415,7 @@ local factoid_itemstring = function(itemstring, playername) end end -local entry_image = function(data) +local function entry_image(data) local formstring = "" -- No image for air if data.itemstring ~= "air" then @@ -414,7 +424,7 @@ local entry_image = function(data) formstring = formstring .. "image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;".. minetest.registered_items[""].wield_image.."]" -- Other items - elseif data.image ~= nil then + elseif data.image then formstring = formstring .. "image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;"..data.image.."]" else formstring = formstring .. "item_image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;"..data.itemstring.."]" @@ -432,9 +442,9 @@ factoid_generators.craftitems = {} --[[ Returns a list of all registered factoids for the specified category and type * category_id: Identifier of the Documentation System category in which the factoid appears * factoid_type: If set, oly returns factoid with a matching factoid_type. - If nil, all factoids for this category will be generated + If nil, all factoids for this category will be generated * data: Entry data to parse ]] -local factoid_custom = function(category_id, factoid_type, data) +local function factoid_custom(category_id, factoid_type, data) local ftable = factoid_generators[category_id] local datastring = "" -- Custom factoids are inserted here @@ -450,17 +460,17 @@ local factoid_custom = function(category_id, factoid_type, data) end -- Shows core information shared by all items, to be inserted at the top -local factoids_header = function(data, ctype) +local function factoids_header(data, ctype) local datastring = "" if not forbidden_core_factoids.basics then local longdesc = data.longdesc local usagehelp = data.usagehelp - if longdesc ~= nil then + if longdesc then datastring = datastring .. S("Description: @1", longdesc) datastring = newline2(datastring) end - if usagehelp ~= nil then + if usagehelp then datastring = datastring .. S("Usage help: @1", usagehelp) datastring = newline2(datastring) end @@ -484,7 +494,7 @@ local factoids_header = function(data, ctype) datastring = datastring .. S("This item points to liquids.").."\n" end end - if data.def.on_use ~= nil then + if data.def.on_use then if ctype == "nodes" then datastring = datastring .. S("Punches with this block don't work as usual; melee combat and mining are either not possible or work differently.").."\n" elseif ctype == "tools" then @@ -510,7 +520,7 @@ local factoids_header = function(data, ctype) end -- Shows less important information shared by all items, to be inserted at the bottom -local factoids_footer = function(data, playername, ctype) +local function factoids_footer(data, playername, ctype) local datastring = "" datastring = datastring .. factoid_custom(ctype, "groups", data) datastring = newline2(datastring) @@ -518,7 +528,7 @@ local factoids_footer = function(data, playername, ctype) -- Show other “exposable” groups if not forbidden_core_factoids.groups then local gstring, gcount = groups_to_string(data.def.groups, miscgroups) - if gstring ~= nil then + if gstring then if gcount == 1 then if ctype == "nodes" then datastring = datastring .. S("This block belongs to the @1 group.", gstring) .. "\n" @@ -577,11 +587,8 @@ doc.add_category("nodes", { description = S("Item reference of blocks and other things which are capable of occupying space"), build_formspec = function(data, playername) if data then - local formstring = "" - local datastring = "" - - formstring = entry_image(data) - datastring = factoids_header(data, "nodes") + local formstring = entry_image(data) + local datastring = factoids_header(data, "nodes") local liquid = data.def.liquidtype ~= "none" and minetest.get_item_group(data.itemstring, "fake_liquid") == 0 if not forbidden_core_factoids.basics then @@ -600,7 +607,7 @@ doc.add_category("nodes", { datastring = datastring .. S("This block is a liquid with these properties:") .. "\n" local range, renew, viscos if data.def.liquid_range then range = data.def.liquid_range else range = 8 end - if data.def.liquid_renewable ~= nil then renew = data.def.liquid_renewable else renew = true end + if data.def.liquid_renewable then renew = data.def.liquid_renewable else renew = true end if data.def.liquid_viscosity then viscos = data.def.liquid_viscosity else viscos = 0 end if renew then datastring = datastring .. S("• Renewable") .. "\n" @@ -620,7 +627,7 @@ doc.add_category("nodes", { --- Direct interaction with the player ---- Damage (very important) if not forbidden_core_factoids.node_damage then - if data.def.damage_per_second ~= nil and data.def.damage_per_second > 1 then + if data.def.damage_per_second and data.def.damage_per_second > 1 then datastring = datastring .. S("This block causes a damage of @1 hit points per second.", data.def.damage_per_second) .. "\n" elseif data.def.damage_per_second == 1 then datastring = datastring .. S("This block causes a damage of @1 hit point per second.", data.def.damage_per_second) .. "\n" @@ -633,7 +640,7 @@ doc.add_category("nodes", { end end local fdap = data.def.groups.fall_damage_add_percent - if fdap ~= nil and fdap ~= 0 then + if fdap and fdap ~= 0 then if fdap > 0 then datastring = datastring .. S("The fall damage on this block is increased by @1%.", fdap) .. "\n" elseif fdap <= -100 then @@ -655,11 +662,11 @@ doc.add_category("nodes", { datastring = datastring .. S("This block can be climbed.").."\n" end local bouncy = data.def.groups.bouncy - if bouncy ~= nil and bouncy ~= 0 then + if bouncy and bouncy ~= 0 then datastring = datastring .. S("This block will make you bounce off with an elasticity of @1%.", bouncy).."\n" end local slippery = data.def.groups.slippery - if slippery ~= nil and slippery ~= 0 then + if slippery and slippery ~= 0 then datastring = datastring .. S("This block is slippery.") .. "\n" end datastring = datastring .. factoid_custom("nodes", "movement", data) @@ -759,7 +766,7 @@ doc.add_category("nodes", { datastring = newline2(datastring) --- List nodes/groups to which this node connects to - if not forbidden_core_factoids.connects_to and data.def.connects_to ~= nil then + if not forbidden_core_factoids.connects_to and data.def.connects_to then local nodes = {} local groups = {} for c=1,#data.def.connects_to do @@ -774,7 +781,7 @@ doc.add_category("nodes", { local nstring = "" for n=1,#nodes do local name - if item_name_overrides[nodes[n]] ~= nil then + if item_name_overrides[nodes[n]] then name = item_name_overrides[nodes[n]] else name = description_for_formspec(nodes[n]) @@ -782,7 +789,7 @@ doc.add_category("nodes", { if n > 1 then nstring = nstring .. S(", ") end - if name ~= nil then + if name then nstring = nstring .. name else nstring = nstring .. S("Unknown Node") @@ -813,9 +820,9 @@ doc.add_category("nodes", { datastring = newline2(datastring) -- Non-default drops - if not forbidden_core_factoids.drops and data.def.drop ~= nil and data.def.drop ~= data.itemstring and data.itemstring ~= "air" then + if not forbidden_core_factoids.drops and data.def.drop and data.def.drop ~= data.itemstring and data.itemstring ~= "air" then -- TODO: Calculate drop probabilities of max > 1 like for max == 1 - local get_desc = function(stack) + local function get_desc(stack) return description_for_formspec(stack:get_name()) end if data.def.drop == "" then @@ -831,10 +838,10 @@ doc.add_category("nodes", { datastring = datastring .. S("This block will drop the following when mined: @1.", desc).."\n" end end - elseif type(data.def.drop) == "table" and data.def.drop.items ~= nil then + elseif type(data.def.drop) == "table" and data.def.drop.items then local max = data.def.drop.max_items local dropstring = "" - local dropstring_base = "" + local dropstring_base if max == nil then dropstring_base = N("This block will drop the following items when mined: @1.") elseif max == 1 then @@ -852,7 +859,7 @@ doc.add_category("nodes", { local rarity_history = {} for i=1,#data.def.drop.items do local local_rarity = data.def.drop.items[i].rarity - local chance = 1 + local chance local rarity = 1 if local_rarity == nil then local_rarity = 1 @@ -885,7 +892,7 @@ doc.add_category("nodes", { if chance > 0 then probtable = {} probtable.items = {} - for j=1,#data.def.drop.items[i].items do + for j = 1, #data.def.drop.items[i].items do local dropstack = ItemStack(data.def.drop.items[i].items[j]) local itemstring = dropstack:get_name() local desc = get_desc(dropstack) @@ -907,7 +914,7 @@ doc.add_category("nodes", { -- Do some cleanup of the probability table if max == 1 or max == nil then -- Sort by rarity - local comp = function(p1, p2) + local function comp(p1, p2) return p1.rarity < p2.rarity end table.sort(probtables, comp) @@ -937,7 +944,6 @@ doc.add_category("nodes", { end local rarity = probtable.rarity - local raritystring = "" -- No percentage if there's only one possible guaranteed drop if not(rarity == 1 and #data.def.drop.items == 1) then local chance = (1/rarity)*100 @@ -957,7 +963,7 @@ doc.add_category("nodes", { dropstring = dropstring .. dropstring_this pcount = pcount + 1 end - if max ~= nil and max > 1 then + if max and max > 1 then datastring = datastring .. S(dropstring_base, max, dropstring) else datastring = datastring .. S(dropstring_base, dropstring) @@ -992,15 +998,15 @@ doc.add_category("tools", { if entries[2].eid == "" then return false end local comp = {} - for e=1, 2 do + for e = 1, 2 do comp[e] = {} end -- No tool capabilities: Instant loser - if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities ~= nil then return false end - if entries[2].data.def.tool_capabilities == nil and entries[1].data.def.tool_capabilities ~= nil then return true end + if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities then return false end + if entries[2].data.def.tool_capabilities == nil and entries[1].data.def.tool_capabilities then return true end -- No tool capabilities for both: Compare by uses if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities == nil then - for e=1, 2 do + for e = 1, 2 do if type(entries[e].data.def._doc_items_durability) == "number" then comp[e].uses = entries[e].data.def._doc_items_durability else @@ -1055,7 +1061,7 @@ doc.add_category("tools", { comp[e].count = groupcount comp[e].group = group comp[e].mintime = mintime - if realuses ~= nil then + if realuses then comp[e].uses = realuses elseif type(entries[e].data.def._doc_items_durability) == "number" then comp[e].uses = entries[e].data.def._doc_items_durability @@ -1086,11 +1092,8 @@ doc.add_category("tools", { end, build_formspec = function(data, playername) if data then - local formstring = "" - local datastring = "" - - formstring = entry_image(data) - datastring = factoids_header(data, "tools") + local formstring = entry_image(data) + local datastring = factoids_header(data, "tools") -- Overwritten durability info if type(data.def._doc_items_durability) == "number" then @@ -1120,11 +1123,8 @@ doc.add_category("craftitems", { description = S("Item reference of items which are neither blocks, tools or weapons (esp. crafting items)"), build_formspec = function(data, playername) if data then - local formstring = "" - local datastring = "" - - formstring = entry_image(data) - datastring = factoids_header(data, "craftitems") + local formstring = entry_image(data) + local datastring = factoids_header(data, "craftitems") datastring = datastring .. factoids_footer(data, playername, "craftitems") formstring = formstring .. doc.widgets.text(datastring, nil, nil, doc.FORMSPEC.ENTRY_WIDTH - 1.2) @@ -1166,9 +1166,9 @@ local function gather_descs() -- 1st pass: Gather groups of interest for id, def in pairs(minetest.registered_items) do -- Gather all groups used for mining - if def.tool_capabilities ~= nil then + if def.tool_capabilities then local groupcaps = def.tool_capabilities.groupcaps - if groupcaps ~= nil then + if groupcaps then for k,v in pairs(groupcaps) do if mininggroups[k] ~= true then mininggroups[k] = true @@ -1179,7 +1179,7 @@ local function gather_descs() -- ... and gather all groups which appear in crafting recipes local crafts = minetest.get_all_craft_recipes(id) - if crafts ~= nil then + if crafts then for c=1,#crafts do for k,v in pairs(crafts[c].items) do if string.sub(v,1,6) == "group:" then @@ -1194,7 +1194,7 @@ local function gather_descs() end -- ... and gather all groups used in connects_to - if def.connects_to ~= nil then + if def.connects_to then for c=1, #def.connects_to do if string.sub(def.connects_to[c],1,6) == "group:" then local group = string.sub(def.connects_to[c],7,-1) @@ -1213,7 +1213,7 @@ local function gather_descs() else help.longdesc["air"] = S("A transparent block, basically empty space. It is usually left behind after digging something.") end - if minetest.registered_items["ignore"]._doc_items_create_entry ~= nil then + if minetest.registered_items["ignore"]._doc_items_create_entry then suppressed["ignore"] = minetest.registered_items["ignore"]._doc_items_create_entry == true end @@ -1242,23 +1242,23 @@ local function gather_descs() }) end - local add_entries = function(deftable, category_id) + local function add_entries(deftable, category_id) for id, def in pairs(deftable) do local name, ld, uh, im local forced = false - if def._doc_items_create_entry == true and def ~= nil then forced = true end + if def._doc_items_create_entry == true and def then forced = true end name = get_entry_name(id) if not (((def.description == nil or def.description == "") and def._doc_items_entry_name == nil) or (def._doc_items_create_entry == false) or (suppressed[id] == true)) or forced then if def._doc_items_longdesc then ld = def._doc_items_longdesc end - if help.longdesc[id] ~= nil then + if help.longdesc[id] then ld = help.longdesc[id] end if def._doc_items_usagehelp then uh = def._doc_items_usagehelp end - if help.usagehelp[id] ~= nil then + if help.usagehelp[id] then uh = help.usagehelp[id] end if def._doc_items_image then @@ -1269,7 +1269,6 @@ local function gather_descs() if type(def._doc_items_hidden) == "boolean" then hidden = def._doc_items_hidden end - local custom_image name = scrub_newlines(name) local infotable = { name = name, @@ -1308,13 +1307,13 @@ local function reveal_item(playername, itemstring) if itemstring == nil or itemstring == "" or playername == nil or playername == "" then return false end - if minetest.registered_nodes[itemstring] ~= nil then + if minetest.registered_nodes[itemstring] then category_id = "nodes" - elseif minetest.registered_tools[itemstring] ~= nil then + elseif minetest.registered_tools[itemstring] then category_id = "tools" - elseif minetest.registered_craftitems[itemstring] ~= nil then + elseif minetest.registered_craftitems[itemstring] then category_id = "craftitems" - elseif minetest.registered_items[itemstring] ~= nil then + elseif minetest.registered_items[itemstring] then category_id = "craftitems" else return false @@ -1334,7 +1333,7 @@ end minetest.register_on_dignode(function(pos, oldnode, digger) if digger == nil then return end local playername = digger:get_player_name() - if playername ~= nil and playername ~= "" and oldnode ~= nil then + if playername and playername ~= "" and oldnode then reveal_item(playername, oldnode.name) reveal_items_in_inventory(digger) end @@ -1343,7 +1342,7 @@ end) minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) if puncher == nil then return end local playername = puncher:get_player_name() - if playername ~= nil and playername ~= "" and node ~= nil then + if playername and playername ~= "" and node then reveal_item(playername, node.name) end end) @@ -1351,7 +1350,7 @@ end) minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing) if placer == nil then return end local playername = placer:get_player_name() - if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then + if playername and playername ~= "" and itemstack and not itemstack:is_empty() then reveal_item(playername, itemstack:get_name()) end end) @@ -1359,7 +1358,7 @@ end) minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) if player == nil then return end local playername = player:get_player_name() - if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then + if playername and playername ~= "" and itemstack and not itemstack:is_empty() then reveal_item(playername, itemstack:get_name()) end end) @@ -1371,7 +1370,7 @@ minetest.register_on_player_inventory_action(function(player, action, inventory, if action == "take" or action == "put" then itemstack = inventory_info.stack end - if itemstack ~= nil and playername ~= nil and playername ~= "" and (not itemstack:is_empty()) then + if itemstack and playername and playername ~= "" and (not itemstack:is_empty()) then reveal_item(playername, itemstack:get_name()) end end) @@ -1379,9 +1378,9 @@ end) minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing) if user == nil then return end local playername = user:get_player_name() - if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then + if playername and playername ~= "" and itemstack and not itemstack:is_empty() then reveal_item(playername, itemstack:get_name()) - if replace_with_item ~= nil then + if replace_with_item then reveal_item(playername, replace_with_item) end end @@ -1391,10 +1390,12 @@ minetest.register_on_joinplayer(function(player) reveal_items_in_inventory(player) end) ---[[ Periodically check all items in player inventory and reveal them all. +--[[ +Periodically check all items in player inventory and reveal them all. TODO: Check whether there's a serious performance impact on servers with many players. -TODO: If possible, try to replace this functionality by updating the revealed items as - soon the player obtained a new item (probably needs new Minetest callbacks). ]] +TODO: If possible, try to replace this functionality by updating the revealed items as soon the player obtained a new item (probably needs new Minetest callbacks). +]] + local checktime = 8 local timer = 0 minetest.register_globalstep(function(dtime) diff --git a/mods/HELP/doc/doc_items/locale/doc_items.de.tr b/mods/HELP/doc/doc_items/locale/doc_items.de.tr index 90747c38..f14c9931 100644 --- a/mods/HELP/doc/doc_items/locale/doc_items.de.tr +++ b/mods/HELP/doc/doc_items/locale/doc_items.de.tr @@ -10,9 +10,9 @@ # Itemname (ca. 25%) @1 (ca. @2%)=@1 (ca. @2%) # List separator (e.g. “one, two, three”) -, =, +, =, # Final list separator (e.g. “One, two and three”) - and = und + and = und 1 second=1 Sekunde A transparent block, basically empty space. It is usually left behind after digging something.=Ein transparenter Block, praktisch leerer Raum. Er wird üblicherweise hinterlassen, nachdem man etwas ausgegraben hat. Air=Luft @@ -32,7 +32,7 @@ Item reference of items which are neither blocks, tools or weapons (esp. craftin Liquids can flow into this block and destroy it.=Flüssigkeiten können in diesen Block hereinfließen und ihn zerstören. Maximum stack size: @1=Maximale Stapelgröße: @1 Mining level: @1=Grabestufe: @1 -Mining ratings:=Grabewertungen: +Mining ratings:=Grabewertungen: • @1, rating @2: @3 s - @4 s=• @1, Wertung @2: @3 s - @4 s • @1, rating @2: @3 s=• @1, Wertung @2: @3 s Mining times:=Grabezeiten: @@ -76,9 +76,8 @@ This block connects to these blocks: @1.=Dieser Block verbindet sich mit den fol This block connects to this block: @1.=Dieser Block verbindet sich mit diesem Block: @1. This block decreases your breath and causes a drowning damage of @1 hit point every 2 seconds.=Dieser Block reduziert Ihren Atem und verursacht beim Ertrinken einen Schaden von @1 Trefferpunkt alle 2 Sekunden. This block decreases your breath and causes a drowning damage of @1 hit points every 2 seconds.=Dieser Block reduziert Ihren Atem und verursacht beim Ertrinken einen Schaden von @1 Trefferpunkten alle 2 Sekunden. -This block glows faintly. It is barely noticable.=Dieser Block leuchtet schwach. Es ist kaum merklich. This block is a light source with a light level of @1.=Dieser Block ist eine Lichtquelle mit einer Helligkeitsstufe von @1. -This block glows faintly with a light level of @1.=Dieser Block leuchtet schwach mit einer Helligkeitsstufe von @1. +This block glows faintly with a light level of @1.=Dieser Block leuchtet schwach mit einer Helligkeitsstufe von @1. This block is a building block for creating various buildings.=Dieser Block ist für den Bau diverser Gebäude vorgesehen. This block is a liquid with these properties:=Dieser Block ist eine Flüssigkeit mit folgenden Eigenschaften: This block is affected by gravity and can fall.=Dieser Block wird von der Schwerkraft beeinflusst und kann fallen. diff --git a/mods/HELP/doc/doc_items/locale/template.txt b/mods/HELP/doc/doc_items/locale/template.txt index 484e40ec..77f10786 100644 --- a/mods/HELP/doc/doc_items/locale/template.txt +++ b/mods/HELP/doc/doc_items/locale/template.txt @@ -2,7 +2,7 @@ Using it as fuel turns it into: @1.= @1 seconds= # Item count times item name -%@1×@2= +@1×@2= # Itemname (25%) @1 (@2%)= # Itemname (<0.5%) diff --git a/mods/HELP/doc/doc_items/screenshot.png b/mods/HELP/doc/doc_items/screenshot.png deleted file mode 100644 index 8e7f5656..00000000 Binary files a/mods/HELP/doc/doc_items/screenshot.png and /dev/null differ diff --git a/mods/HELP/mcl_craftguide/init.lua b/mods/HELP/mcl_craftguide/init.lua index 829fc418..378b420f 100644 --- a/mods/HELP/mcl_craftguide/init.lua +++ b/mods/HELP/mcl_craftguide/init.lua @@ -33,7 +33,6 @@ local fmt, find, gmatch, match, sub, split, lower = local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil local pairs, next, unpack = pairs, next, unpack -local vec_add, vec_mul = vector.add, vector.multiply local DEFAULT_SIZE = 10 local MIN_LIMIT, MAX_LIMIT = 10, 12 @@ -418,9 +417,9 @@ local function get_tooltip(item, groups, cooktime, burntime) -- and just print the normal item name without special formatting if groups[1] == "compass" or groups[1] == "clock" then groupstr = reg_items[item].description - elseif group_names[groups[1]] then + elseif g then -- Use the special group name string - groupstr = minetest.colorize(gcol, group_names[groups[1]]) + groupstr = minetest.colorize(gcol, g) else --[[ Fallback: Generic group explanation: This always works, but the internally used group name (which @@ -546,7 +545,7 @@ local function get_recipe_fs(data, iY) if custom_recipe or shapeless or recipe.type == "cooking" then local icon = custom_recipe and custom_recipe.icon or - shapeless and "shapeless" or "furnace" + shapeless and "shapeless" or "furnace" if recipe.type == "cooking" then icon = "default_furnace_front_active.png" @@ -639,7 +638,7 @@ local function make_formspec(name) fs[#fs + 1] = "background9[1,1;1,1;mcl_base_textures_background9.png;true;7]" fs[#fs + 1] = fmt([[ tooltip[size_inc;%s] - tooltip[size_dec;%s] ]], + tooltip[size_dec;%s] ]], ESC(S("Increase window size")), ESC(S("Decrease window size"))) @@ -657,9 +656,9 @@ local function make_formspec(name) ]] fs[#fs + 1] = fmt([[ tooltip[search;%s] - tooltip[clear;%s] - tooltip[prev;%s] - tooltip[next;%s] ]], + tooltip[clear;%s] + tooltip[prev;%s] + tooltip[next;%s] ]], ESC(S("Search")), ESC(S("Reset")), ESC(S("Previous page")), @@ -668,7 +667,7 @@ local function make_formspec(name) fs[#fs + 1] = fmt("label[%f,%f;%s]", sfinv_only and 6.3 or data.iX - 2.2, 0.22, - ESC(colorize(mcl_colors.DARK_GRAY, fmt("%s / %u", data.pagenum, data.pagemax)))) + ESC(colorize("#383838", fmt("%s / %u", data.pagenum, data.pagemax)))) fs[#fs + 1] = fmt([[ image_button[%f,0.12;0.8,0.8;craftguide_prev_icon.png;prev;] @@ -727,7 +726,7 @@ local function make_formspec(name) return concat(fs) end -local show_fs = function(player, name) +local function show_fs(player, name) if sfinv_only then sfinv.set_player_inventory_formspec(player) else @@ -1001,7 +1000,7 @@ else end end) - local function on_use(user) + --[[local function on_use(user) local name = user:get_player_name() if next(recipe_filters) then @@ -1011,7 +1010,7 @@ else end show_formspec(name, "mcl_craftguide", make_formspec(name)) - end + end]] end @@ -1098,7 +1097,6 @@ if progressive_mode then local name = player:get_player_name() init_data(name) local meta = player:get_meta() - local name = player:get_player_name() local data = player_data[name] data.inv_items = deserialize(meta:get_string("inv_items")) or {} @@ -1144,7 +1142,7 @@ else end function mcl_craftguide.show(name) - local player = minetest.get_player_by_name(name) + local player = get_player_by_name(name) if next(recipe_filters) then local data = player_data[name] data.items_raw = get_filtered_items(player) diff --git a/mods/HELP/mcl_craftguide/screenshot.png b/mods/HELP/mcl_craftguide/screenshot.png deleted file mode 100644 index ebb8e4d7..00000000 Binary files a/mods/HELP/mcl_craftguide/screenshot.png and /dev/null differ diff --git a/mods/HELP/mcl_doc/init.lua b/mods/HELP/mcl_doc/init.lua index 6948aed0..9be688ec 100644 --- a/mods/HELP/mcl_doc/init.lua +++ b/mods/HELP/mcl_doc/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_doc") +local S = minetest.get_translator(minetest.get_current_modname()) -- Disable built-in factoids; it is planned to add custom ones as replacements doc.sub.items.disable_core_factoid("node_mining") @@ -50,8 +50,8 @@ end) doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def) local formstring = "" - if def.groups.leafdecay ~= nil then - if def.drop ~= "" and def.drop ~= nil and def.drop ~= itemstring then + if def.groups.leafdecay then + if def.drop ~= "" and def.drop and def.drop ~= itemstring then formstring = S("This block quickly decays when there is no wood block of any species within a distance of @1. When decaying, it disappears and may drop one of its regular drops. The block does not decay when the block has been placed by a player.", def.groups.leafdecay) else formstring = S("This block quickly decays and disappears when there is no wood block of any species within a distance of @1. The block does not decay when the block has been placed by a player.", def.groups.leafdecay) @@ -62,7 +62,6 @@ end) -- nodes which have flower placement rules doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def) - local datastring = "" if def.groups.place_flowerlike == 1 then return S("This plant can only grow on grass blocks and dirt. To survive, it needs to have an unobstructed view to the sky above or be exposed to a light level of 8 or higher.") elseif def.groups.place_flowerlike == 2 then @@ -130,7 +129,7 @@ end) -- Armor doc.sub.items.register_factoid(nil, "use", function(itemstring, def) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] local s = "" local head = minetest.get_item_group(itemstring, "armor_head") local torso = minetest.get_item_group(itemstring, "armor_torso") @@ -155,7 +154,7 @@ doc.sub.items.register_factoid(nil, "use", function(itemstring, def) return s end) doc.sub.items.register_factoid(nil, "groups", function(itemstring, def) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] local s = "" local use = minetest.get_item_group(itemstring, "mcl_armor_uses") local pts = minetest.get_item_group(itemstring, "mcl_armor_points") @@ -173,7 +172,6 @@ end) doc.sub.items.register_factoid(nil, "groups", function(itemstring, def) if def._repair_material then local mdef = minetest.registered_items[def._repair_material] - local desc if mdef and mdef.description and mdef.description ~= "" then return S("This item can be repaired at an anvil with: @1.", mdef.description) elseif def._repair_material == "group:wood" then @@ -291,7 +289,7 @@ doc.sub.items.register_factoid("nodes", "drops", function(itemstring, def) local itemname = item:get_name() local itemcount = item:get_count() local idef = minetest.registered_items[itemname] - local text = "" + local text if idef.description and idef.description ~= "" then text = idef.description else @@ -401,7 +399,7 @@ doc.sub.items.register_factoid("tools", "misc", function(itemstring, def) local formstring = "" -- Weapon data local damage_groups = tool_capabilities.damage_groups - if damage_groups ~= nil and damage_groups.fleshy ~= nil then + if damage_groups and damage_groups.fleshy then formstring = formstring .. S("This is a melee weapon which deals damage by punching.") .. "\n" -- Damage groups @@ -410,7 +408,7 @@ doc.sub.items.register_factoid("tools", "misc", function(itemstring, def) -- Full punch interval local punch = 1.0 - if tool_capabilities.full_punch_interval ~= nil then + if tool_capabilities.full_punch_interval then punch = tool_capabilities.full_punch_interval end formstring = formstring .. S("Full punch interval: @1 s", string.format("%.1f", punch)) diff --git a/mods/HELP/mcl_doc_basics/init.lua b/mods/HELP/mcl_doc_basics/init.lua index e700e82b..45ce7587 100644 --- a/mods/HELP/mcl_doc_basics/init.lua +++ b/mods/HELP/mcl_doc_basics/init.lua @@ -2,7 +2,7 @@ Basic help for MCL2. Fork of doc_basics ]] -local S = minetest.get_translator("mcl_doc_basics") +local S = minetest.get_translator(minetest.get_current_modname()) doc.add_category("basics", { diff --git a/mods/HELP/mcl_doc_basics/mcl_extension.lua b/mods/HELP/mcl_doc_basics/mcl_extension.lua index c6f9f0aa..a0f31a2c 100644 --- a/mods/HELP/mcl_doc_basics/mcl_extension.lua +++ b/mods/HELP/mcl_doc_basics/mcl_extension.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_doc_basics") +local S = minetest.get_translator(minetest.get_current_modname()) doc.add_entry("advanced", "creative", { name = S("Creative Mode"), diff --git a/mods/HELP/mcl_doc_basics/screenshot.png b/mods/HELP/mcl_doc_basics/screenshot.png deleted file mode 100644 index f0be2d7e..00000000 Binary files a/mods/HELP/mcl_doc_basics/screenshot.png and /dev/null differ diff --git a/mods/HELP/mcl_tt/init.lua b/mods/HELP/mcl_tt/init.lua index 9d011304..3451e76d 100644 --- a/mods/HELP/mcl_tt/init.lua +++ b/mods/HELP/mcl_tt/init.lua @@ -1,2 +1,4 @@ -dofile(minetest.get_modpath("mcl_tt").."/snippets_base.lua") -dofile(minetest.get_modpath("mcl_tt").."/snippets_mcl.lua") +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +dofile(modpath.."/snippets_base.lua") +dofile(modpath.."/snippets_mcl.lua") \ No newline at end of file diff --git a/mods/HELP/mcl_tt/snippets_base.lua b/mods/HELP/mcl_tt/snippets_base.lua index 8242f2c1..4e200d53 100644 --- a/mods/HELP/mcl_tt/snippets_base.lua +++ b/mods/HELP/mcl_tt/snippets_base.lua @@ -1,6 +1,6 @@ -local S = minetest.get_translator("mcl_tt") +local S = minetest.get_translator(minetest.get_current_modname()) -local function get_min_digtime(caps) +--[[local function get_min_digtime(caps) local mintime local unique = true local maxlevel = caps.maxlevel @@ -25,7 +25,7 @@ local function get_min_digtime(caps) end end return mintime, unique -end +end]] local function newline(str) if str ~= "" then @@ -47,7 +47,7 @@ tt.register_snippet(function(itemstring, toolcaps) local minestring = "" local capstr = "" local caplines = 0 - for k,v in pairs(groupcaps) do + for _,v in pairs(groupcaps) do local speedstr = "" local miningusesstr = "" -- Mining capabilities @@ -153,9 +153,9 @@ tt.register_snippet(function(itemstring, toolcaps) end) -- Weapon stats -tt.register_snippet(function(itemstring) +--[[tt.register_snippet(function(itemstring) local def = minetest.registered_items[itemstring] -end) +end)]] -- Food tt.register_snippet(function(itemstring) diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index 3d13df75..3c79f52e 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -1,8 +1,8 @@ -local S = minetest.get_translator("mcl_tt") +local S = minetest.get_translator(minetest.get_current_modname()) -- Armor tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] local s = "" local head = minetest.get_item_group(itemstring, "armor_head") local torso = minetest.get_item_group(itemstring, "armor_torso") @@ -26,7 +26,7 @@ tt.register_snippet(function(itemstring) return s end) tt.register_snippet(function(itemstring, _, itemstack) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] local s = "" local use = minetest.get_item_group(itemstring, "mcl_armor_uses") local pts = minetest.get_item_group(itemstring, "mcl_armor_points") @@ -75,7 +75,7 @@ tt.register_snippet(function(itemstring) end) tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] if minetest.get_item_group(itemstring, "crush_after_fall") == 1 then return S("Deals damage when falling"), mcl_colors.YELLOW end diff --git a/mods/HELP/tt/init.lua b/mods/HELP/tt/init.lua index afc421e4..819bf7b8 100644 --- a/mods/HELP/tt/init.lua +++ b/mods/HELP/tt/init.lua @@ -7,10 +7,14 @@ tt.NAME_COLOR = mcl_colors.YELLOW -- API tt.registered_snippets = {} -tt.register_snippet = function(func) +function tt.register_snippet(func) table.insert(tt.registered_snippets, func) end +function tt.register_priority_snippet(func) + table.insert(tt.registered_snippets, 1, func) +end + dofile(minetest.get_modpath(minetest.get_current_modname()).."/snippets.lua") -- Apply item description updates @@ -22,8 +26,6 @@ local function apply_snippets(desc, itemstring, toolcaps, itemstack) local str, snippet_color = tt.registered_snippets[s](itemstring, toolcaps, itemstack) if snippet_color == nil then snippet_color = tt.COLOR_DEFAULT - elseif snippet_color == false then - snippet_color = false end if str then if first then @@ -41,7 +43,7 @@ local function apply_snippets(desc, itemstring, toolcaps, itemstack) end local function should_change(itemstring, def) - return itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def ~= nil and def.description ~= nil and def.description ~= "" and def._tt_ignore ~= true + return itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def and def.description and def.description ~= "" and def._tt_ignore ~= true end local function append_snippets() @@ -58,7 +60,7 @@ end minetest.register_on_mods_loaded(append_snippets) -tt.reload_itemstack_description = function(itemstack) +function tt.reload_itemstack_description(itemstack) local itemstring = itemstack:get_name() local def = itemstack:get_definition() local meta = itemstack:get_meta() diff --git a/mods/HUD/awards/api.lua b/mods/HUD/awards/api.lua index 6601dd62..49b11a6c 100644 --- a/mods/HUD/awards/api.lua +++ b/mods/HUD/awards/api.lua @@ -14,11 +14,16 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + -- The global award namespace awards = { - show_mode = "hud" + show_mode = "hud", } -dofile(minetest.get_modpath("awards").."/api_helpers.lua") + +dofile(modpath.."/api_helpers.lua") -- Table Save Load Functions function awards.save() @@ -29,8 +34,6 @@ function awards.save() end end -local S = minetest.get_translator("awards") - function awards.init() awards.players = awards.load() awards.def = {} @@ -53,7 +56,7 @@ end function awards.register_trigger(name, func) awards.trigger_types[name] = func awards.on[name] = {} - awards['register_on_'..name] = function(func) + awards["register_on_"..name] = function(func) table.insert(awards.on[name], func) end end @@ -447,7 +450,7 @@ function awards.getFormspec(name, to, sid) first = false if def.secret and not award.got then - formspec = formspec .. mcl_colors.DARK_GRAY..minetest.formspec_escape(S("(Secret Award)")) + formspec = formspec .. "#707070" .. minetest.formspec_escape(S("(Secret Award)")) else local title = award.name if def and def.title then @@ -456,7 +459,7 @@ function awards.getFormspec(name, to, sid) if award.got then formspec = formspec .. minetest.formspec_escape(title) else - formspec = formspec .. mcl_colors.GRAY.. minetest.formspec_escape(title) + formspec = formspec .. "#ACACAC" .. minetest.formspec_escape(title) end end end diff --git a/mods/HUD/awards/chat_commands.lua b/mods/HUD/awards/chat_commands.lua index 88e799df..88bed0af 100644 --- a/mods/HUD/awards/chat_commands.lua +++ b/mods/HUD/awards/chat_commands.lua @@ -14,7 +14,7 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- -local S = minetest.get_translator("awards") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("awards", { params = S("[c|clear|disable|enable]"), diff --git a/mods/HUD/awards/init.lua b/mods/HUD/awards/init.lua index 63c9303c..9b46fd06 100644 --- a/mods/HUD/awards/init.lua +++ b/mods/HUD/awards/init.lua @@ -14,9 +14,11 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- -dofile(minetest.get_modpath("awards").."/api.lua") -dofile(minetest.get_modpath("awards").."/chat_commands.lua") -dofile(minetest.get_modpath("awards").."/sfinv.lua") -dofile(minetest.get_modpath("awards").."/unified_inventory.lua") -dofile(minetest.get_modpath("awards").."/triggers.lua") +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +dofile(modpath.."/api.lua") +dofile(modpath.."/chat_commands.lua") +dofile(modpath.."/sfinv.lua") +dofile(modpath.."/unified_inventory.lua") +dofile(modpath.."/triggers.lua") diff --git a/mods/HUD/awards/locale/awards.de.tr b/mods/HUD/awards/locale/awards.de.tr index 2fb04c4c..489a1968 100644 --- a/mods/HUD/awards/locale/awards.de.tr +++ b/mods/HUD/awards/locale/awards.de.tr @@ -1,7 +1,7 @@ # textdomain:awards @1: @2=@1: @2 @1 (got)=@1 (erhalten) -@1’s awards:=Auszeichnungen von @1: +@1’s awards:=Auszeichnungen von @: (Secret Award)=(Geheime Auszeichnung) Achievement gotten!=Auszeichnung erhalten! Achievement gotten:=Auszeichnung erhalten: @@ -27,7 +27,6 @@ Awards=Auszeichnungen @1/@2 deaths=@1/@2 Tode @1/@2 dug=@1/@2 abgebaut @1/@2 game joins=@1/@2 Spielen beigetreten -@1/@2 lines of chat=@1/@2 Chatzeilen @1/@2 placed=@1/@2 platziert Die @1 times.=Sterben Sie @1 mal. Die.=Sterben Sie. @@ -58,3 +57,7 @@ Invalid action.=Ungültige Aktion. Player is not online.=Spieler ist nicht online. Done.=Fertig. Achievement “@1” does not exist.=Auszeichnung »@1« existiert nicht. +@1 has made the achievement @2=@1 hat die Auszeichnung @2 erhalten +Write something in chat.=Schreiben Sie etwas in den Chat. +Write @1 chat messages.=Schreiben Sie @1 Chatnachrichten. +@1/@2 chat messages=@1/@2 Chatnachrichten diff --git a/mods/HUD/awards/locale/template.txt b/mods/HUD/awards/locale/template.txt index a1505b34..ac6a1d75 100644 --- a/mods/HUD/awards/locale/template.txt +++ b/mods/HUD/awards/locale/template.txt @@ -6,12 +6,11 @@ @1/@2 game joins= @1/@2 placed= @1 (got)= -@1: @1= +@1: @2= @1’s awards:= (Secret Award)= = = -A Cat in a Pop-Tart?!= Achievement gotten!= Achievement gotten:= Achievement gotten: @1= @@ -28,9 +27,9 @@ Join the game.= List awards in chat (deprecated)= Place a block: @1= Place blocks: @1×@2= -Secret Achievement gotten!= -Secret Achievement gotten:= -Secret Achievement gotten: @1= +Secret achievement gotten!= +Secret achievement gotten:= +Secret achievement gotten: @1= Show details of an achievement= Show, clear, disable or enable your achievements= Get this achievement to find out what it is.= @@ -60,3 +59,5 @@ Player is not online.= Done.= Achievement “@1” does not exist.= @1 has made the achievement @2= +Mine a block: @1= +Mine blocks: @1×@2= diff --git a/mods/HUD/awards/screenshot.png b/mods/HUD/awards/screenshot.png deleted file mode 100644 index ab9e19e5..00000000 Binary files a/mods/HUD/awards/screenshot.png and /dev/null differ diff --git a/mods/HUD/awards/sfinv.lua b/mods/HUD/awards/sfinv.lua index 5d02cbb5..3b41d29a 100644 --- a/mods/HUD/awards/sfinv.lua +++ b/mods/HUD/awards/sfinv.lua @@ -1,5 +1,5 @@ if minetest.get_modpath("sfinv") then - local S = minetest.get_translator("awards") + local S = minetest.get_translator(minetest.get_current_modname()) sfinv.register_page("awards:awards", { title = S("Awards"), diff --git a/mods/HUD/awards/triggers.lua b/mods/HUD/awards/triggers.lua index 318a4b28..c7194d2c 100644 --- a/mods/HUD/awards/triggers.lua +++ b/mods/HUD/awards/triggers.lua @@ -14,7 +14,7 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- -local S = minetest.get_translator("awards") +local S = minetest.get_translator(minetest.get_current_modname()) awards.register_trigger("dig", function(def) local tmp = { @@ -250,9 +250,7 @@ minetest.register_on_dignode(function(pos, oldnode, digger) local tnodedug = string.split(entry.node, ":") local tmod = tnodedug[1] local titem = tnodedug[2] - if not tmod or not titem or not data.count[tmod] or not data.count[tmod][titem] then - -- table running failed! - elseif data.count[tmod][titem] > entry.target-1 then + if tmod and titem and data.count[tmod] and data.count[tmod][titem] and data.count[tmod][titem] > entry.target-1 then return entry.award end elseif awards.get_total_item_count(data, "count") > entry.target-1 then @@ -277,9 +275,7 @@ minetest.register_on_placenode(function(pos, node, digger) local tnodedug = string.split(entry.node, ":") local tmod = tnodedug[1] local titem = tnodedug[2] - if not tmod or not titem or not data.place[tmod] or not data.place[tmod][titem] then - -- table running failed! - elseif data.place[tmod][titem] > entry.target-1 then + if tmod and titem and data.place[tmod] and data.place[tmod][titem] and data.place[tmod][titem] > entry.target-1 then return entry.award end elseif awards.get_total_item_count(data, "place") > entry.target-1 then @@ -303,9 +299,7 @@ minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, local titemstring = string.split(entry.item, ":") local tmod = titemstring[1] local titem = titemstring[2] - if not tmod or not titem or not data.eat[tmod] or not data.eat[tmod][titem] then - -- table running failed! - elseif data.eat[tmod][titem] > entry.target-1 then + if tmod and titem and data.eat[tmod] and data.eat[tmod][titem] and data.eat[tmod][titem] > entry.target-1 then return entry.award end elseif awards.get_total_item_count(data, "eat") > entry.target-1 then @@ -331,9 +325,7 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv local titemcrafted = string.split(entry.item, ":") local tmod = titemcrafted[1] local titem = titemcrafted[2] - if not tmod or not titem or not data.craft[tmod] or not data.craft[tmod][titem] then - -- table running failed! - elseif data.craft[tmod][titem] > entry.target-1 then + if tmod and titem and data.craft[tmod] and data.craft[tmod][titem] and data.craft[tmod][titem] > entry.target-1 then return entry.award end elseif awards.get_total_item_count(data, "craft") > entry.target-1 then @@ -390,7 +382,7 @@ end) minetest.register_on_chat_message(function(name, message) -- Run checks local idx = string.find(message,"/") - if not name or (idx ~= nil and idx <= 1) then + if not name or (idx and idx <= 1) then return end diff --git a/mods/HUD/awards/unified_inventory.lua b/mods/HUD/awards/unified_inventory.lua index be5ca5f9..3dc238e1 100644 --- a/mods/HUD/awards/unified_inventory.lua +++ b/mods/HUD/awards/unified_inventory.lua @@ -1,6 +1,5 @@ -if minetest.get_modpath("unified_inventory") ~= nil then - local S = minetest.get_translator("awards") - +if minetest.get_modpath("unified_inventory") then + local S = minetest.get_translator(minetest.get_current_modname()) unified_inventory.register_button("awards", { type = "image", image = "awards_ui_icon.png", diff --git a/mods/HUD/hudbars/default_settings.lua b/mods/HUD/hudbars/default_settings.lua index ce43cc8b..865a7cb6 100644 --- a/mods/HUD/hudbars/default_settings.lua +++ b/mods/HUD/hudbars/default_settings.lua @@ -37,7 +37,7 @@ hb.settings.alignment_pattern = hb.load_setting("hudbars_alignment_pattern", "st hb.settings.autohide_breath = hb.load_setting("hudbars_autohide_breath", "bool", true) local sorting = minetest.settings:get("hudbars_sorting") -if sorting ~= nil then +if sorting then hb.settings.sorting = {} hb.settings.sorting_reverse = {} for k,v in string.gmatch(sorting, "(%w+)=(%w+)") do diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 6f90aa03..08f1914c 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -1,17 +1,22 @@ -local S = minetest.get_translator("hudbars") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) + +local S = minetest.get_translator(modname) local N = function(s) return s end -hb = {} +local math = math +local table = table -hb.hudtables = {} - --- number of registered HUD bars -hb.hudbars_count = 0 - --- table which records which HUD bar slots have been “registered” so far; used for automatic positioning -hb.registered_slots = {} - -hb.settings = {} +hb = { + hudtables = {}, + -- number of registered HUD bars + hudbars_count = 0, + -- table which records which HUD bar slots have been “registered” so far; used for automatic positioning + registered_slots = {}, + settings = {}, + -- Table which contains all players with active default HUD bars (only for internal use) + players = {}, +} function hb.load_setting(sname, stype, defaultval, valid_values) local sval @@ -22,10 +27,10 @@ function hb.load_setting(sname, stype, defaultval, valid_values) elseif stype == "number" then sval = tonumber(minetest.settings:get(sname)) end - if sval ~= nil then - if valid_values ~= nil then + if sval then + if valid_values then local valid = false - for i=1,#valid_values do + for i = 1, #valid_values do if sval == valid_values[i] then valid = true end @@ -45,7 +50,8 @@ function hb.load_setting(sname, stype, defaultval, valid_values) end -- Load default settings -dofile(minetest.get_modpath("hudbars").."/default_settings.lua") +dofile(modpath.."/default_settings.lua") + if minetest.get_modpath("mcl_experience") and not minetest.is_creative_enabled("") then -- reserve some space for experience bar: hb.settings.start_offset_left.y = hb.settings.start_offset_left.y - 20 @@ -85,9 +91,6 @@ local function make_label(format_string, format_string_config, label, start_valu return ret end --- Table which contains all players with active default HUD bars (only for internal use) -hb.players = {} - function hb.value_to_barlength(value, max) if max == 0 then return 0 @@ -111,7 +114,7 @@ function hb.get_hudtable(identifier) end function hb.get_hudbar_position_index(identifier) - if hb.settings.sorting[identifier] ~= nil then + if hb.settings.sorting[identifier] then return hb.settings.sorting[identifier] else local i = 0 @@ -176,7 +179,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, direction, format_string_config.format_max_value = "%d" end - hudtable.add_all = function(player, hudtable, start_value, start_max, start_hidden) + function hudtable.add_all(player, hudtable, start_value, start_max, start_hidden) if start_value == nil then start_value = hudtable.default_start_value end if start_max == nil then start_max = hudtable.default_start_max end if start_hidden == nil then start_hidden = hudtable.default_start_hidden end @@ -212,7 +215,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, direction, offset = { x = offset.x - 1, y = offset.y - 1 }, z_index = 0, }) - if textures.icon ~= nil then + if textures.icon then ids.icon = player:hud_add({ hud_elem_type = "image", position = pos, @@ -332,7 +335,7 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon end local value_changed, max_changed = false, false - if new_value ~= nil then + if new_value then if new_value ~= hudtable.hudstate[name].value then hudtable.hudstate[name].value = new_value value_changed = true @@ -340,7 +343,7 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon else new_value = hudtable.hudstate[name].value end - if new_max_value ~= nil then + if new_max_value then if new_max_value ~= hudtable.hudstate[name].max then hudtable.hudstate[name].max = new_max_value max_changed = true @@ -350,29 +353,29 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon end if hb.settings.bar_type == "progress_bar" then - if new_icon ~= nil and hudtable.hudids[name].icon ~= nil then + if new_icon and hudtable.hudids[name].icon then player:hud_change(hudtable.hudids[name].icon, "text", new_icon) end - if new_bgicon ~= nil and hudtable.hudids[name].bgicon ~= nil then + if new_bgicon and hudtable.hudids[name].bgicon then player:hud_change(hudtable.hudids[name].bgicon, "text", new_bgicon) end - if new_bar ~= nil then + if new_bar then player:hud_change(hudtable.hudids[name].bar , "text", new_bar) end - if new_label ~= nil then + if new_label then hudtable.label = new_label local new_text = make_label(hudtable.format_string, hudtable.format_string_config, new_label, hudtable.hudstate[name].value, hudtable.hudstate[name].max) player:hud_change(hudtable.hudids[name].text, "text", new_text) end - if new_text_color ~= nil then + if new_text_color then player:hud_change(hudtable.hudids[name].text, "number", new_text_color) end else - if new_icon ~= nil and hudtable.hudids[name].bar ~= nil then + if new_icon and hudtable.hudids[name].bar then player:hud_change(hudtable.hudids[name].bar, "text", new_icon) end - if new_bgicon ~= nil and hudtable.hudids[name].bg ~= nil then + if new_bgicon and hudtable.hudids[name].bg then player:hud_change(hudtable.hudids[name].bg, "text", new_bgicon) end end @@ -423,7 +426,7 @@ function hb.hide_hudbar(player, identifier) local hudtable = hb.get_hudtable(identifier) if hudtable == nil then return false end if hb.settings.bar_type == "progress_bar" then - if hudtable.hudids[name].icon ~= nil then + if hudtable.hudids[name].icon then player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0}) end player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0}) @@ -443,7 +446,7 @@ function hb.unhide_hudbar(player, identifier) local value = hudtable.hudstate[name].value local max = hudtable.hudstate[name].max if hb.settings.bar_type == "progress_bar" then - if hudtable.hudids[name].icon ~= nil then + if hudtable.hudids[name].icon then player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1}) end if hudtable.hudstate[name].max ~= 0 then @@ -545,7 +548,7 @@ local function update_hud(player, has_damage) end minetest.register_on_player_hpchange(function(player) - if hb.players[player:get_player_name()] ~= nil then + if hb.players[player:get_player_name()] then update_health(player) end end) diff --git a/mods/HUD/hudbars/screenshot.png b/mods/HUD/hudbars/screenshot.png deleted file mode 100644 index 88ee3238..00000000 Binary files a/mods/HUD/hudbars/screenshot.png and /dev/null differ diff --git a/mods/HUD/mcl_achievements/init.lua b/mods/HUD/mcl_achievements/init.lua index 2f1db1fe..c963773d 100644 --- a/mods/HUD/mcl_achievements/init.lua +++ b/mods/HUD/mcl_achievements/init.lua @@ -3,7 +3,7 @@ -- If true, activates achievements from other Minecraft editions (XBox, PS, etc.) local non_pc_achievements = false -local S = minetest.get_translator("mcl_achievements") +local S = minetest.get_translator(minetest.get_current_modname()) -- Achievements from PC Edition diff --git a/mods/HUD/mcl_base_textures/textures/object_crosshair.png b/mods/HUD/mcl_base_textures/textures/object_crosshair.png index e5a400e9..8e94dcc6 100644 Binary files a/mods/HUD/mcl_base_textures/textures/object_crosshair.png and b/mods/HUD/mcl_base_textures/textures/object_crosshair.png differ diff --git a/mods/HUD/mcl_bossbars/init.lua b/mods/HUD/mcl_bossbars/init.lua index a95d533c..f1d99e01 100644 --- a/mods/HUD/mcl_bossbars/init.lua +++ b/mods/HUD/mcl_bossbars/init.lua @@ -39,7 +39,7 @@ local last_id = 0 function mcl_bossbars.add_bar(player, def, dynamic, priority) local name = player:get_player_name() local bars = mcl_bossbars.bars[name] - local bar = {text = def.text, priority = priority or 0} + local bar = {text = def.text, priority = priority or 0, timeout = def.timeout} bar.color, bar.image = get_color_info(def.color, def.percentage) if dynamic then for _, other in pairs(bars) do @@ -60,12 +60,12 @@ function mcl_bossbars.add_bar(player, def, dynamic, priority) bar.id = last_id + 1 last_id = bar.id mcl_bossbars.static[bar.id] = bar - return id + return bar.id end end function mcl_bossbars.remove_bar(id) - mcl_bossbars.static[id].bar.static = false + mcl_bossbars.static[id].id = nil mcl_bossbars.static[id] = nil end @@ -76,16 +76,23 @@ function mcl_bossbars.update_bar(id, def, priority) old.priority = priority or old.priority end -function mcl_bossbars.update_boss(luaentity, name, color) - local object = luaentity.object +function mcl_bossbars.update_boss(object, name, color) + local props = object:get_luaentity() + if not props or not props._cmi_is_mob then + props = object:get_properties() + props.health = object:get_hp() + end + local bardef = { - text = luaentity.nametag, - percentage = math.floor(luaentity.health / luaentity.hp_max * 100), color = color, + text = props.nametag, + percentage = math.floor(props.health / props.hp_max * 100), } + if not bardef.text or bardef.text == "" then bardef.text = name end + local pos = object:get_pos() for _, player in pairs(minetest.get_connected_players()) do local d = vector.distance(pos, player:get_pos()) @@ -112,7 +119,7 @@ minetest.register_on_leaveplayer(function(player) mcl_bossbars.bars[name] = nil end) -minetest.register_globalstep(function() +minetest.register_globalstep(function(dtime) for _, player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() local bars = mcl_bossbars.bars[name] @@ -127,7 +134,12 @@ minetest.register_globalstep(function() local hud = table.remove(huds, 1) if bar and bar.id then - table.insert(bars_new, bar) + if bar.timeout then + bar.timeout = bar.timeout - dtime + end + if not bar.timeout or bar.timeout > 0 then + table.insert(bars_new, bar) + end end if bar and not hud then diff --git a/mods/HUD/mcl_credits/init.lua b/mods/HUD/mcl_credits/init.lua index 1e8138ab..29437387 100644 --- a/mods/HUD/mcl_credits/init.lua +++ b/mods/HUD/mcl_credits/init.lua @@ -27,9 +27,10 @@ mcl_credits.people = { "Rootyjr", "Nicu", "aligator", + "Code-Sploit", + "NO11", }}, {"Contributors", 0x52FF00, { - "Code-Sploit", "Laurent Rocher", "HimbeerserverDE", "TechDudie", @@ -46,7 +47,6 @@ mcl_credits.people = { "Jared Moody", "Li0n", "Midgard", - "NO11", "Saku Laesvuori", "Yukitty", "ZedekThePD", @@ -55,6 +55,7 @@ mcl_credits.people = { "nickolas360", "yutyo", "ztianyang", + "j45", }}, {"MineClone5", 0xA60014, { "kay27", @@ -63,6 +64,38 @@ mcl_credits.people = { "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", @@ -74,7 +107,8 @@ mcl_credits.people = { "kingoscargames", "leorockway", "xMrVizzy", - "yutyo" + "yutyo", + "NO11", }}, {"Translations", 0x00FF60, { "Wuzzy", diff --git a/mods/HUD/mcl_death_messages/init.lua b/mods/HUD/mcl_death_messages/init.lua index 8ca68670..91e13995 100644 --- a/mods/HUD/mcl_death_messages/init.lua +++ b/mods/HUD/mcl_death_messages/init.lua @@ -1,307 +1,246 @@ -local S = minetest.get_translator("mcl_death_messages") -local N = function(s) return s end -local C = minetest.colorize +local S = minetest.get_translator(minetest.get_current_modname()) -local color_skyblue = mcl_colors.AQUA - -local function get_tool_name(item) - local name = item:get_meta():get_string("name") - if name ~= "" then - return name - end - local def = item:get_definition() - return def._tt_original_description or def.description - end - -mcl_death_messages = {} - --- Death messages -local msgs = { - ["arrow"] = { - N("@1 was fatally hit by an arrow."), - N("@1 has been killed by an arrow."), +mcl_death_messages = { + assist = {}, + messages = { + in_fire = { + _translator = S, + plain = "@1 went up in flames", + assist = "@1 walked into fire whilst fighting @2", + }, + lightning_bolt = { + _translator = S, + plain = "@1 was struck by lightning", + assist = "@1 was struck by lightning whilst fighting @2", + }, + on_fire = { + _translator = S, + plain = "@1 burned to death", + assist = "@1 was burnt to a crisp whilst fighting @2", + }, + lava = { + _translator = S, + plain = "@1 tried to swim in lava", + assist = "@1 tried to swim in lava to escape @2" + }, + hot_floor = { + _translator = S, + plain = "@1 discovered the floor was lava", + assist = "@1 walked into danger zone due to @2", + }, + in_wall = { + _translator = S, + plain = "@1 suffocated in a wall", + assist = "@1 suffocated in a wall whilst fighting @2", + }, + drown = { + _translator = S, + plain = "@1 drowned", + assist = "@1 drowned whilst trying to escape @2", + }, + starve = { + _translator = S, + plain = "@1 starved to death", + assist = "@1 starved to death whilst fighting @2", + }, + cactus = { + _translator = S, + plain = "@1 was pricked to death", + assist = "@1 walked into a cactus whilst trying to escape @2", + }, + fall = { + _translator = S, + plain = "@1 hit the ground too hard", + assist = "@1 hit the ground too hard whilst trying to escape @2", + -- "@1 fell from a high place" -- for fall distance > 5 blocks + -- "@1 fell while climbing" + -- "@1 fell off some twisting vines" + -- "@1 fell off some weeping vines" + -- "@1 fell off some vines" + -- "@1 fell off scaffolding" + -- "@1 fell off a ladder" + }, + fly_into_wall = { + _translator = S, + plain = "@1 experienced kinetic energy", + assist = "@1 experienced kinetic energy whilst trying to escape @2", + }, + out_of_world = { + _translator = S, + plain = "@1 fell out of the world", + assist = "@1 didn't want to live in the same world as @2", + }, + generic = { + _translator = S, + plain = "@1 died", + assist = "@1 died because of @2", + }, + magic = { + _translator = S, + plain = "@1 was killed by magic", + assist = "@1 was killed by magic whilst trying to escape @2", + killer = "@1 was killed by @2 using magic", + item = "@1 was killed by @2 using @3", + }, + dragon_breath = { + _translator = S, + plain = "@1 was roasted in dragon breath", + killer = "@1 was roasted in dragon breath by @2", + }, + wither = { + _translator = S, + plain = "@1 withered away", + escape = "@1 withered away whilst fighting @2", + }, + wither_skull = { + _translator = S, + plain = "@1 was killed by magic", + killer = "@1 was shot by a skull from @2", + }, + anvil = { + _translator = S, + plain = "@1 was squashed by a falling anvil", + escape = "@1 was squashed by a falling anvil whilst fighting @2", + }, + falling_node = { + _translator = S, + plain = "@1 was squashed by a falling block", + assist = "@1 was squashed by a falling block whilst fighting @2", + }, + mob = { + _translator = S, + killer = "@1 was slain by @2", + item = "@1 was slain by @2 using @3", + }, + player = { + _translator = S, + killer = "@1 was slain by @2", + item = "@1 was slain by @2 using @3" + }, + arrow = { + _translator = S, + killer = "@1 was shot by @2", + item = "@1 was shot by @2 using @3", + }, + fireball = { + _translator = S, + killer = "@1 was fireballed by @2", + item = "@1 was fireballed by @2 using @3", + }, + thorns = { + _translator = S, + killer = "@1 was killed trying to hurt @2", + item = "@1 was killed by @3 trying to hurt @2", -- yes, the order is intentional: @1 @3 @2 + }, + explosion = { + _translator = S, + plain = "@1 blew up", + killer = "@1 was blown up by @2", + item = "@1 was blown up by @2 using @3", + -- "@1 was killed by [Intentional Game Design]" -- for exploding bed in nether or end + }, + cramming = { + _translator = S, + plain = "@1 was squished too much", + assist = "@1 was squashed by @2", -- surprisingly "escape" is actually the correct subtype + }, + fireworks = { + _translator = S, + plain = "@1 went off with a bang", + item = "@1 went off with a bang due to a firework fired from @3 by @2", -- order is intentional + }, + -- Missing snowballs: The Minecraft wiki mentions them but the MC source code does not. }, - ["arrow_name"] = { - N("@1 was shot by @2 using [@3]"), - }, - ["arrow_skeleton"] = { - N("@1 was shot by Skeleton."), - }, - ["arrow_stray"] = { - N("@1 was shot by Stray."), - }, - ["arrow_illusioner"] = { - N("@1 was shot by Illusioner."), - }, - ["arrow_mob"] = { - N("@1 was shot."), - }, - ["drown"] = { - N("@1 forgot to breathe."), - N("@1 drowned."), - N("@1 ran out of oxygen."), - }, - ["murder"] = { - N("@1 was slain by @2 using [@3]"), - }, - ["murder_hand"] = { - N("@1 was slain by @2"), - }, - ["murder_any"] = { - N("@1 was killed."), - }, - ["mob_kill"] = { - N("@1 was slain by a mob."), - }, - ["blaze_fireball"] = { - N("@1 was burned to death by a Blaze's fireball."), - N("@1 was fireballed by a Blaze"), - }, - ["fire_charge"] = { - N("@1 was burned by a fire charge."), - }, - ["ghast_fireball"] = { - N("A Ghast scared @1 to death."), - N("@1 has been fireballed by a Ghast."), - }, - ["fall"] = { - N("@1 fell from a high cliff."), - N("@1 took fatal fall damage."), - N("@1 fell victim to gravity."), - N("@1 hit the ground too hard.") - }, - - ["other"] = { - N("@1 died."), - } } -local mobkills = { - ["mobs_mc:zombie"] = N("@1 was slain by Zombie."), - ["mobs_mc:baby_zombie"] = N("@1 was slain by Baby Zombie."), - ["mobs_mc:blaze"] = N("@1 was burnt to a crisp while fighting Blaze."), - ["mobs_mc:slime"] = N("@1 was slain by Slime."), - ["mobs_mc:witch"] = N("@1 was slain by Witch using magic."), - ["mobs_mc:magma_cube_tiny"] = N("@1 was slain by Magma Cube."), - ["mobs_mc:magma_cube_small"] = N("@1 was slain by Magma Cube."), - ["mobs_mc:magma_cube_big"] = N("@1 was slain by Magma Cube."), - ["mobs_mc:wolf"] = N("@1 was slain by Wolf."), - ["mobs_mc:cat"] = N("@1 was slain by Cat."), - ["mobs_mc:ocelot"] = N("@1 was slain by Ocelot."), - ["mobs_mc:enderdragon"] = N("@1 was slain by Enderdragon."), - ["mobs_mc:wither"] = N("@1 was slain by Wither."), - ["mobs_mc:enderman"] = N("@1 was slain by Enderman."), - ["mobs_mc:endermite"] = N("@1 was slain by Endermite."), - ["mobs_mc:ghast"] = N("@1 was fireballed by a Ghast."), - ["mobs_mc:guardian_elder"] = N("@1 was slain by Elder Guardian."), - ["mobs_mc:guardian"] = N("@1 was slain by Guardian."), - ["mobs_mc:iron_golem"] = N("@1 was slain by Iron Golem."), - ["mobs_mc:polar_bear"] = N("@1 was slain by Polar Bear."), - ["mobs_mc:killer_bunny"] = N("@1 was slain by Killer Bunny."), - ["mobs_mc:shulker"] = N("@1 was slain by Shulker."), - ["mobs_mc:silverfish"] = N("@1 was slain by Silverfish."), - ["mobs_mc:skeleton"] = N("@1 was shot by Skeleton."), - ["mobs_mc:stray"] = N("@1 was shot by Stray."), - ["mobs_mc:slime_tiny"] = N("@1 was slain by Slime."), - ["mobs_mc:slime_small"] = N("@1 was slain by Slime."), - ["mobs_mc:slime_big"] = N("@1 was slain by Slime."), - ["mobs_mc:spider"] = N("@1 was slain by Spider."), - ["mobs_mc:cave_spider"] = N("@1 was slain by Cave Spider."), - ["mobs_mc:vex"] = N("@1 was slain by Vex."), - ["mobs_mc:evoker"] = N("@1 was slain by Evoker."), - ["mobs_mc:illusioner"] = N("@1 was slain by Illusioner."), - ["mobs_mc:vindicator"] = N("@1 was slain by Vindicator."), - ["mobs_mc:villager_zombie"] = N("@1 was slain by Zombie Villager."), - ["mobs_mc:husk"] = N("@1 was slain by Husk."), - ["mobs_mc:baby_husk"] = N("@1 was slain by Baby Husk."), - ["mobs_mc:pigman"] = N("@1 was slain by Zombie Pigman."), - ["mobs_mc:baby_pigman"] = N("@1 was slain by Baby Zombie Pigman."), -} - --- Select death message -local dmsg = function(mtype, ...) - local r = math.random(1, #msgs[mtype]) - return S(msgs[mtype][r], ...) -end - --- Select death message for death by mob -local mmsg = function(mtype, ...) - if mobkills[mtype] then - return S(mobkills[mtype], ...) - else - return dmsg("mob_kill", ...) +local function get_item_killer_message(obj, messages, reason) + if messages.item then + local wielded = mcl_util.get_wielded_item(reason.source) + local itemname = wielded:get_meta():get_string("name") + if itemname ~= "" then + itemname = "[" .. itemname .. "]" + if mcl_enchanting.is_enchanted(wielded:get_name()) then + itemname = minetest.colorize(mcl_colors.AQUA, itemname) + end + return messages._translator(messages.item, mcl_util.get_object_name(obj), mcl_util.get_object_name(reason.source), itemname) + end end end -local last_damages = { } +local function get_plain_killer_message(obj, messages, reason) + return messages.killer and messages._translator(messages.killer, mcl_util.get_object_name(obj), mcl_util.get_object_name(reason.source)) +end -minetest.register_on_dieplayer(function(player, reason) - -- Death message - local message = minetest.settings:get_bool("mcl_showDeathMessages") --Maybe cache the setting? - if message == nil then - message = true +local function get_killer_message(obj, messages, reason) + return reason.source and (get_item_killer_message(obj, messages, reason) or get_plain_killer_message(obj, messages, reason)) +end + +local function get_assist_message(obj, messages, reason) + if messages.assist and mcl_death_messages.assist[obj] then + return messages._translator(messages.assist, mcl_util.get_object_name(obj), mcl_death_messages.assist[obj].name) end - if message then - local name = player:get_player_name() - if not name then - return - end - local msg - if last_damages[name] then - -- custom message - msg = last_damages[name].message - elseif reason.type == "node_damage" then - local pos = player:get_pos() - -- Check multiple nodes because players occupy multiple nodes - -- (we add one additional node because the check may fail if the player was - -- just barely touching the node with the head) - local posses = { pos, {x=pos.x,y=pos.y+1,z=pos.z}, {x=pos.x,y=pos.y+2,z=pos.z}} - local highest_damage = 0 - local highest_damage_def = nil - -- Show message for node that dealt the most damage - for p=1, #posses do - local def = minetest.registered_nodes[minetest.get_node(posses[p]).name] - local dmg = def.damage_per_second - if dmg and dmg > highest_damage then - highest_damage = dmg - highest_damage_def = def - end - end - if highest_damage_def and highest_damage_def._mcl_node_death_message then - local field = highest_damage_def._mcl_node_death_message - local field_msg - if type(field) == "table" then - field_msg = field[math.random(1, #field)] - else - field_msg = field - end - local textdomain - if highest_damage_def.mod_origin then - textdomain = highest_damage_def.mod_origin - else - textdomain = "mcl_death_messages" - end - -- We assume the textdomain of the death message in the node definition - -- equals the modname. - msg = minetest.translate(textdomain, field_msg, name) - end - elseif reason.type == "drown" then - msg = dmsg("drown", name) - elseif reason.type == "punch" then - -- Punches - local hitter = reason.object +end - -- Player was slain by potions - if not hitter then return end - - local hittername, hittertype, hittersubtype, shooter - local hitter_toolname = get_tool_name(hitter:get_wielded_item()) +local function get_plain_message(obj, messages, reason) + if messages.plain then + return messages._translator(messages.plain, mcl_util.get_object_name(obj)) + end +end - -- Custom message - if last_damages[name] then - msg = last_damages[name].message - -- Unknown hitter - elseif hitter == nil then - msg = dmsg("murder_any", name) - -- Player - elseif hitter:is_player() then - hittername = hitter:get_player_name() - if hittername ~= nil then - if hitter_toolname == "" then - msg = dmsg("murder_hand", name, hittername) - else - msg = dmsg("murder", name, hittername, C(color_skyblue, hitter_toolname)) - end - else - msg = dmsg("murder_any", name) - end - -- Mob (according to Common Mob Interface) - elseif hitter:get_luaentity()._cmi_is_mob then - if hitter:get_luaentity().nametag and hitter:get_luaentity().nametag ~= "" then - hittername = hitter:get_luaentity().nametag - end - hittersubtype = hitter:get_luaentity().name - if hittername then - msg = dmsg("murder", name, hittername) - elseif hittersubtype ~= nil and hittersubtype ~= "" then - msg = mmsg(hittersubtype, name) - else - msg = dmsg("murder_any", name) - end - -- Arrow - elseif hitter:get_luaentity().name == "mcl_bows:arrow_entity" or hitter:get_luaentity().name == "mobs_mc:arrow_entity" and not killed_by_potion then - local shooter - if hitter:get_luaentity()._shooter then - shooter = hitter:get_luaentity()._shooter - end - local is_mob = false - local s_ent = shooter and shooter:get_luaentity() - if shooter == nil then - msg = dmsg("arrow", name) - elseif shooter:is_player() then - msg = dmsg("arrow_name", name, shooter:get_player_name(), C(color_skyblue, get_tool_name(shooter:get_wielded_item()))) - elseif s_ent and s_ent._cmi_is_mob then - if s_ent.nametag ~= "" then - msg = dmsg("arrow_name", name, shooter:get_player_name(), get_tool_name(shooter:get_wielded_item())) - elseif s_ent.name == "mobs_mc:skeleton" then - msg = dmsg("arrow_skeleton", name) - elseif s_ent.name == "mobs_mc:stray" then - msg = dmsg("arrow_stray", name) - elseif s_ent.name == "mobs_mc:illusioner" then - msg = dmsg("arrow_illusioner", name) - else - msg = dmsg("arrow_mob", name) - end - else - msg = dmsg("arrow", name) - end - -- Blaze fireball - elseif hitter:get_luaentity().name == "mobs_mc:blaze_fireball" then - if hitter:get_luaentity()._shot_from_dispenser then - msg = dmsg("fire_charge", name) - else - msg = dmsg("blaze_fireball", name) - end - -- Ghast fireball - elseif hitter:get_luaentity().name == "mobs_monster:fireball" then - msg = dmsg("ghast_fireball", name) - end - -- Falling - elseif reason.type == "fall" then - msg = dmsg("fall", name) - -- Other - elseif reason.type == "set_hp" then - if last_damages[name] then - msg = last_damages[name].message - end +local function get_fallback_message(obj, messages, reason) + return "mcl_death_messages.messages." .. reason.type .. " " .. mcl_util.get_object_name(obj) +end + +local function fallback_translator(s) + return s +end + +mcl_damage.register_on_death(function(obj, reason) + if not minetest.settings:get_bool("mcl_showDeathMessages", true) then + return + end + + local send_to + + if obj:is_player() then + send_to = true + end + + -- ToDo: add mob death messages for owned mobs, only send to owner (sent_to = "player name") + + if send_to then + local messages = mcl_death_messages.messages[reason.type] or {} + messages._translator = messages._translator or fallback_translator + + local message = + get_killer_message(obj, messages, reason) or + get_assist_message(obj, messages, reason) or + get_plain_message(obj, messages, reason) or + get_fallback_message(obj, messages, reason) + + if send_to == true then + minetest.chat_send_all(message) + else + minetest.chat_send_player(send_to, message) end - if not msg then - msg = dmsg("other", name) - end - minetest.chat_send_all(msg) - last_damages[name] = nil end end) --- dmg_sequence_number is used to discard old damage events -local dmg_sequence_number = 0 -local start_damage_reset_countdown = function (player, sequence_number) - minetest.after(1, function(playername, sequence_number) - if last_damages[playername] and last_damages[playername].sequence_number == sequence_number then - last_damages[playername] = nil +mcl_damage.register_on_damage(function(obj, damage, reason) + if obj:get_hp() - damage > 0 then + if reason.source then + mcl_death_messages.assist[obj] = {name = mcl_util.get_object_name(reason.source), timeout = 5} + else + mcl_death_messages.assist[obj] = nil end - end, player:get_player_name(), sequence_number) -end - --- Send a custom death mesage when damaging a player via set_hp or punch. --- To be called directly BEFORE damaging a player via set_hp or punch. --- The next time the player dies due to a set_hp, the message will be shown. --- The player must die via set_hp within 0.1 seconds, otherwise the message will be discarded. -function mcl_death_messages.player_damage(player, message) - last_damages[player:get_player_name()] = { message = message, sequence_number = dmg_sequence_number } - start_damage_reset_countdown(player, dmg_sequence_number) - dmg_sequence_number = dmg_sequence_number + 1 - if dmg_sequence_number >= 65535 then - dmg_sequence_number = 0 end -end \ No newline at end of file +end) + +minetest.register_globalstep(function(dtime) + for obj, tbl in pairs(mcl_death_messages.assist) do + tbl.timeout = tbl.timeout - dtime + if not obj:is_player() and not obj:get_luaentity() or tbl.timeout > 0 then + mcl_death_messages.assist[obj] = nil + end + end +end) diff --git a/mods/HUD/mcl_death_messages/locale/mcl_death_messages.de.tr b/mods/HUD/mcl_death_messages/locale/mcl_death_messages.de.tr index ffb567b8..39235dff 100644 --- a/mods/HUD/mcl_death_messages/locale/mcl_death_messages.de.tr +++ b/mods/HUD/mcl_death_messages/locale/mcl_death_messages.de.tr @@ -1,59 +1,58 @@ # textdomain: mcl_death_messages -@1 was fatally hit by an arrow.=@1 wurde tödlich von einem Pfeil getroffen. -@1 has been killed by an arrow.=@1 wurde von einem Pfeil getötet. -@1 was shot by an arrow from @2.=@1 wurde mit einem Pfeil von @2 abgeschossen. -@1 was shot by an arrow from a skeleton.=@1 wurde von einem Skelett mit Pfeil und Bogen abgeschossen. -@1 was shot by an arrow from a stray.=@1 wurde von einem Eiswanderer mit Pfeil und Bogen abgeschossen. -@1 was shot by an arrow from an illusioner.=@1 wurde von einem Illusionisten mit Pfeil und Bogen abgeschossen. -@1 was shot by an arrow.=@1 wurde mit einem Pfeil abgeschossen. -@1 forgot to breathe.=@1 vergaß, zu atmen. -@1 drowned.=@1 ertrank. -@1 ran out of oxygen.=@1 ging die Luft aus. -@1 was killed by @2.=@1 wurde von @2 getötet. -@1 was killed.=@1 wurde getötet. -@1 was killed by a mob.=@1 wurde von einem Mob getötet. -@1 was burned to death by a blaze's fireball.=@1 wurde von einem Feuerball einer Lohe zu Tode verbrannt. -@1 was killed by a fireball from a blaze.=@1 wurde von einem Feuerball einer Lohe getötet. -@1 was burned by a fire charge.=@1 wurde von einer Feuerkugel verbrannt. -A ghast scared @1 to death.=Ein Ghast hat @1 zu Tode erschrocken. -@1 has been fireballed by a ghast.=@1 wurde von einem Ghast mit einer Feuerkugel abgeschossen. -@1 fell from a high cliff.=@1 stürzte von einer hohen Klippe. -@1 took fatal fall damage.=@1 nahm tödlichen Fallschaden. -@1 fell victim to gravity.=@1 fiel der Schwerkraft zum Opfer. -@1 died.=@1 starb. -@1 was killed by a zombie.=@1 wurde von einem Zombie getötet. -@1 was killed by a baby zombie.=@1 wurde von einem Zombiebaby getötet. -@1 was killed by a blaze.=@1 wurde von einer Lohe getötet. -@1 was killed by a slime.=@1 wurde von einem Schleim getötet. -@1 was killed by a witch.=@1 wurde von einer Hexe getötet. -@1 was killed by a magma cube.=@1 wurde von einem Magmakubus getötet. -@1 was killed by a wolf.=@1 wurde von einem Wolf getötet. -@1 was killed by a cat.=@1 wurde von einer Katze getötet. -@1 was killed by an ocelot.=@1 wurde von einem Ozelot getötet. -@1 was killed by an ender dragon.=@1 wurde von einem Enderdrachen getötet. -@1 was killed by a wither.=@1 wurde von einem Wither getötet. -@1 was killed by an enderman.=@1 wurde von einem Enderman getötet. -@1 was killed by an endermite.=@1 wurde von einer Endermilbe getötet. -@1 was killed by a ghast.=@1 wurde von einem Ghast getötet. -@1 was killed by an elder guardian.=@1 wurde von einem Großen Wächter getötet. -@1 was killed by a guardian.=@1 wurde von einem Wächter getötet. -@1 was killed by an iron golem.=@1 wurde von einem Eisengolem getötet. -@1 was killed by a polar_bear.=@1 wurde von einem Eisbären getötet. -@1 was killed by a killer bunny.=@1 wurde von einem Killerkaninchen getötet. -@1 was killed by a shulker.=@1 wurde von einem Schulker getötet. -@1 was killed by a silverfish.=@1 wurde von einem Silberfischchen getötet. -@1 was killed by a skeleton.=@1 wurde von einem Skelett getötet. -@1 was killed by a stray.=@1 wurde von einem Eiswanderer getötet. -@1 was killed by a slime.=@1 wurde von einem Schleim getötet. -@1 was killed by a spider.=@1 wurde von einer Spinne getötet. -@1 was killed by a cave spider.=@1 wurde von einer Höhlenspinne getötet. -@1 was killed by a vex.=@1 wurde von einem Plagegeist getötet. -@1 was killed by an evoker.=@1 wurde von einem Magier getötet. -@1 was killed by an illusioner.=@1 wurde von einem Illusionisten getötet. -@1 was killed by a vindicator.=@1 wurde von einem Diener getötet. -@1 was killed by a zombie villager.=@1 wurde von einem Dorfbewohnerzombie getötet. -@1 was killed by a husk.=@1 wurde von einem Wüstenzombie getötet. -@1 was killed by a baby husk.=@1 wurde von einem Wüstenzombiebaby getötet. -@1 was killed by a zombie pigman.=@1 wurde von einem Schweinezombie getötet. -@1 was killed by a baby zombie pigman.=@1 wurde von einem Schweinezombiebaby getötet. -@1 was slain by @2.= +@1 went up in flames=@1 ging in Flammen auf +@1 walked into fire whilst fighting @2=@1 ist während eines Kampfes mit @2 in ein Feuer gelaufen +@1 was struck by lightning=@1 wurde von einem Blitz erschlagen +@1 was struck by lightning whilst fighting @2=@1 wurde während eines Kampfes mit @2 von einem Blitz erschlagen +@1 burned to death=@1 ist verbrannt +@1 was burnt to a crisp whilst fighting @2=@1 ist während eines Kampfes mit @2 verbrannt +@1 tried to swim in lava=@1 hat versucht, in Lava zu schwimmen +@1 tried to swim in lava to escape @2=@1 hat versucht, in Lava zu schwimmen, um @2 zu entkommen +@1 discovered the floor was lava=@1 hat festgestellt, dass der Boden Lava ist +@1 walked into danger zone due to @2=@1 ist wegen @2 in eine Gefahrenzone gelaufen +@1 suffocated in a wall=@1 ist in einer Mauer erstickt +@1 suffocated in a wall whilst fighting @2=@1 ist während eines Kampfes mit @2 in einer Mauer erstickt +@1 drowned=@1 ist ertrunken +@1 drowned whilst trying to escape @2=@1 ist während dem Versuch, @2 zu entkommen, ertrunken +@1 starved to death=@1 ist verhungert +@1 starved to death whilst fighting @2=@1 ist während eines Kampfes mit @2 verhungert +@1 was pricked to death=@1 wurde zu Tode gestochen +@1 walked into a cactus whilst trying to escape @2=@1 ist während dem Versuch, @2 zu entkommen, in einen Kaktus gelaufen +@1 hit the ground too hard=@1 ist zu hart auf dem Boden aufgetroffen +@1 hit the ground too hard whilst trying to escape @2=@1 ist während dem Versuch, @2 zu entkommen, zu hart auf dem Boden aufgetroffen +@1 experienced kinetic energy=@1 hat kinetische Energie erfahren +@1 experienced kinetic energy whilst trying to escape @2=@1 hat während dem Versuch, @2 zu entkommen, kinetische Energie erfahren +@1 fell out of the world=@1 ist aus der Welt gefallen +@1 didn't want to live in the same world as @2=@1 wollte nicht in der gleichen Welt wie @2 leben +@1 died=@1 ist gestorben +@1 died because of @2=@1 ist wegen @2 gestorben +@1 was killed by magic=@1 wurde von Magie getötet +@1 was killed by magic whilst trying to escape @2=@1 wurde während dem Versuch, @2 zu entkommen, von Magie getötet +@1 was killed by @2 using magic=@1 wurde von @2 mit Magie getötet +@1 was killed by @2 using @3=@1 wurde von @2 mit @3 getötet +@1 was roasted in dragon breath=@1 wurde in Drachenatem geröstet +@1 was roasted in dragon breath by @2=@1 wurde in Drachenatem von @2 geröstet +@1 withered away=@1 ist davon gewithert +@1 withered away whilst fighting @2=@1 ist während einem Kampf mit @2 davon gewithert +@1 was killed by magic=@1 wurde von Magie getötet +@1 was shot by a skull from @2=@1 wurde von einem Schädel von @2 erschossen +@1 was squashed by a falling anvil=@1 wurde von einem fallenden Amboss erquetscht +@1 was squashed by a falling anvil whilst fighting @2=@1 wurde während einem Kampf mit @2 von einem fallenden Amboss erquetscht +@1 was squashed by a falling block=@1 wurde von einem fallenden Block erquetscht +@1 was squashed by a falling block whilst fighting @2=@1 wurde während einem Kampf mit @2 von einem fallenden Block erquetscht +@1 was slain by @2=@1 wurde von @2 erschlagen +@1 was slain by @2 using @3=@1 wurde von @2 mit @3 erschlagen +@1 was slain by @2=@1 wurde von @2 erschlagen +@1 was slain by @2 using @3=@1 wurde von @2 mit @3 erschlagen +@1 was shot by @2=@1 wurde von @2 erschossen +@1 was shot by @2 using @3=@1 wurde von @2 mit @3 erschossen +@1 was fireballed by @2=@1 wurde von @2 gefeuerballt +@1 was fireballed by @2 using @3=@1 wurde von @2 mit @3 gefeuerballt +@1 was killed trying to hurt @2=@1 ist bei dem Versuch, @2 zu verletzten gestorben +@1 was killed by @3 trying to hurt @2=@1 ist bei dem Versuch, @2 zu verletzten, von @3 getötet worden +@1 blew up=@1 ist gesprengt worden +@1 was blown up by @2=@1 wurde von @2 gesprengt +@1 was blown up by @2 using @3=@1 wurde von @2 mit @3 gesprengt +@1 was squished too much=@1 war zu gequetscht +@1 was squashed by @2=@1 wurde von @2 erquetscht +@1 went off with a bang=@1 ging mit einem Knall ab +@1 went off with a bang due to a firework fired from @3 by @2=@1 ging mit einem Knall wegen eines Feuerwerks, das mit @3 von @2 gefeuert wurde, ab diff --git a/mods/HUD/mcl_death_messages/locale/template.txt b/mods/HUD/mcl_death_messages/locale/template.txt index d1e3b832..67ba9fd1 100644 --- a/mods/HUD/mcl_death_messages/locale/template.txt +++ b/mods/HUD/mcl_death_messages/locale/template.txt @@ -1,59 +1,58 @@ # textdomain: mcl_death_messages -@1 was fatally hit by an arrow.= -@1 has been killed with an arrow.= -@1 was shot by an arrow from @2.= -@1 was shot by an arrow from a skeleton.= -@1 was shot by an arrow from a stray.= -@1 was shot by an arrow from an illusioner.= -@1 was shot by an arrow.= -@1 forgot to breathe.= -@1 drowned.= -@1 ran out of oxygen.= -@1 was killed by @2.= -@1 was killed.= -@1 was killed by a mob.= -@1 was burned to death by a blaze's fireball.= -@1 was killed by a fireball from a blaze.= -@1 was burned by a fire charge.= -A ghast scared @1 to death.= -@1 has been fireballed by a ghast.= -@1 fell from a high cliff.= -@1 took fatal fall damage.= -@1 fell victim to gravity.= -@1 died.= -@1 was killed by a zombie.= -@1 was killed by a baby zombie.= -@1 was killed by a blaze.= -@1 was killed by a slime.= -@1 was killed by a witch.= -@1 was killed by a magma cube.= -@1 was killed by a wolf.= -@1 was killed by a cat.= -@1 was killed by an ocelot.= -@1 was killed by an ender dragon.= -@1 was killed by a wither.= -@1 was killed by an enderman.= -@1 was killed by an endermite.= -@1 was killed by a ghast.= -@1 was killed by an elder guardian.= -@1 was killed by a guardian.= -@1 was killed by an iron golem.= -@1 was killed by a polar_bear.= -@1 was killed by a killer bunny.= -@1 was killed by a shulker.= -@1 was killed by a silverfish.= -@1 was killed by a skeleton.= -@1 was killed by a stray.= -@1 was killed by a slime.= -@1 was killed by a spider.= -@1 was killed by a cave spider.= -@1 was killed by a vex.= -@1 was killed by an evoker.= -@1 was killed by an illusioner.= -@1 was killed by a vindicator.= -@1 was killed by a zombie villager.= -@1 was killed by a husk.= -@1 was killed by a baby husk.= -@1 was killed by a zombie pigman.= -@1 was killed by a baby zombie pigman.= -@1 was slain by @2.= +@1 went up in flames= +@1 walked into fire whilst fighting @2= +@1 was struck by lightning= +@1 was struck by lightning whilst fighting @2= +@1 burned to death= +@1 was burnt to a crisp whilst fighting @2= +@1 tried to swim in lava= +@1 tried to swim in lava to escape @2= +@1 discovered the floor was lava= +@1 walked into danger zone due to @2= +@1 suffocated in a wall= +@1 suffocated in a wall whilst fighting @2= +@1 drowned= +@1 drowned whilst trying to escape @2= +@1 starved to death= +@1 starved to death whilst fighting @2= +@1 was pricked to death= +@1 walked into a cactus whilst trying to escape @2= +@1 hit the ground too hard= +@1 hit the ground too hard whilst trying to escape @2= +@1 experienced kinetic energy= +@1 experienced kinetic energy whilst trying to escape @2= +@1 fell out of the world= +@1 didn't want to live in the same world as @2= +@1 died= +@1 died because of @2= +@1 was killed by magic= +@1 was killed by magic whilst trying to escape @2= +@1 was killed by @2 using magic= +@1 was killed by @2 using @3= +@1 was roasted in dragon breath= +@1 was roasted in dragon breath by @2= +@1 withered away= +@1 withered away whilst fighting @2= +@1 was killed by magic= +@1 was shot by a skull from @2= +@1 was squashed by a falling anvil= +@1 was squashed by a falling anvil whilst fighting @2= +@1 was squashed by a falling block= +@1 was squashed by a falling block whilst fighting @2= +@1 was slain by @2= +@1 was slain by @2 using @3= +@1 was slain by @2= +@1 was slain by @2 using @3= +@1 was shot by @2= +@1 was shot by @2 using @3= +@1 was fireballed by @2= +@1 was fireballed by @2 using @3= +@1 was killed trying to hurt @2= +@1 was killed by @3 trying to hurt @2= +@1 blew up= +@1 was blown up by @2= +@1 was blown up by @2 using @3= +@1 was squished too much= +@1 was squashed by @2= +@1 went off with a bang= +@1 went off with a bang due to a firework fired from @3 by @2= diff --git a/mods/HUD/mcl_experience/init.lua b/mods/HUD/mcl_experience/init.lua index df733e13..e514ffc1 100644 --- a/mods/HUD/mcl_experience/init.lua +++ b/mods/HUD/mcl_experience/init.lua @@ -1,5 +1,11 @@ -local S = minetest.get_translator("mcl_experience") +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 @@ -34,7 +40,7 @@ minetest.register_on_mods_loaded(function() registered_nodes = minetest.registered_nodes end) -local load_data = function(player) +local function load_data(player) local name = player:get_player_name() pool[name] = {} local temp_pool = pool[name] @@ -46,7 +52,7 @@ local load_data = function(player) end -- saves data to be utilized on next login -local save_data = function(player) +local function save_data(player) local name = player:get_player_name() local temp_pool = pool[name] local meta = player:get_meta() @@ -64,7 +70,7 @@ minetest.register_on_leaveplayer(function(player) end) -- create instance of new hud -hud_manager.add_hud = function(player,hud_name,def) +function hud_manager.add_hud(player,hud_name,def) local name = player:get_player_name() if minetest.is_creative_enabled(name) then return @@ -94,7 +100,7 @@ hud_manager.add_hud = function(player,hud_name,def) end -- delete instance of hud -hud_manager.remove_hud = function(player,hud_name) +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]) @@ -103,7 +109,7 @@ hud_manager.remove_hud = function(player,hud_name) end -- change element of hud -hud_manager.change_hud = function(data) +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) @@ -111,12 +117,12 @@ hud_manager.change_hud = function(data) end -- gets if hud exists -hud_manager.hud_exists = function(player,hud_name) +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) + return true else - return(false) + return false end end ------------------- @@ -127,7 +133,7 @@ minetest.register_on_leaveplayer(function(player) end) -- is used for shutdowns to save all data -local save_all = function() +local function save_all() for name,_ in pairs(pool) do local player = minetest.get_player_by_name(name) if player then @@ -144,7 +150,7 @@ end) function mcl_experience.get_player_xp_level(player) local name = player:get_player_name() - return(pool[name].level) + return pool[name].level end function mcl_experience.set_player_xp_level(player,level) @@ -262,35 +268,7 @@ function mcl_experience.add_experience(player, experience) 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 unbreaking_level = mcl_enchanting.get_enchantment(stack, "unbreaking") - local uses - local armor_uses = minetest.get_item_group(stack:get_name(), "mcl_armor_uses") - if armor_uses > 0 then - uses = armor_uses - if unbreaking_level > 0 then - uses = uses / (0.6 + 0.4 / (unbreaking_level + 1)) - end - else - local def = stack:get_definition() - if def then - local fixed_uses = def._mcl_uses - if fixed_uses then - uses = fixed_uses - if unbreaking_level > 0 then - uses = uses * (unbreaking_level + 1) - end - end - end - if not uses then - local toolcaps = stack:get_tool_capabilities() - local groupcaps = toolcaps.groupcaps - for _, v in pairs(groupcaps) do - uses = v.uses - break - end - end - end - uses = uses or 0 + local uses = mcl_util.calculate_durability(stack) local multiplier = 2 * 65535 / uses local repair = experience * multiplier local new_wear = wear - repair @@ -302,10 +280,6 @@ function mcl_experience.add_experience(player, experience) end stack:set_wear(math.floor(new_wear)) inv:set_stack(list, index, stack) - if can.list == "armor" then - local armor_inv = minetest.get_inventory({type = "detached", name = player:get_player_name() .. "_armor"}) - armor_inv:set_stack(list, index, stack) - end end local old_bar, old_xp, old_level = temp_pool.bar, temp_pool.xp, temp_pool.level @@ -360,14 +334,12 @@ minetest.register_on_dieplayer(function(player) mcl_experience.throw_experience(player:get_pos(), xp_amount) end) - -local name 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, data +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 diff --git a/mods/HUD/mcl_hbarmor/init.lua b/mods/HUD/mcl_hbarmor/init.lua index 89b2db7a..34ac205a 100644 --- a/mods/HUD/mcl_hbarmor/init.lua +++ b/mods/HUD/mcl_hbarmor/init.lua @@ -1,35 +1,34 @@ -local S = minetest.get_translator("mcl_hbarmor") +local S = minetest.get_translator(minetest.get_current_modname()) -if (not armor) or (not armor.def) then - minetest.log("error", "[mcl_hbarmor] Outdated mcl_armor version. Please update your version of mcl_armor!") -end +local math = math +local tonumber = tonumber -local mcl_hbarmor = {} +local get_connected_players = minetest.get_connected_players --- HUD statbar values -mcl_hbarmor.armor = {} +local mcl_hbarmor = { + -- HUD statbar values + armor = {}, + -- Stores if player's HUD bar has been initialized so far. + player_active = {}, + -- Time difference in seconds between updates to the HUD armor bar. + -- Increase this number for slow servers. + tick = 0.1, + -- If true, the armor bar is hidden when the player does not wear any armor + autohide = true, +} --- Stores if player's HUD bar has been initialized so far. -mcl_hbarmor.player_active = {} +local tick_config = minetest.settings:get("mcl_hbarmor_tick") --- Time difference in seconds between updates to the HUD armor bar. --- Increase this number for slow servers. -mcl_hbarmor.tick = 0.1 - --- If true, the armor bar is hidden when the player does not wear any armor -mcl_hbarmor.autohide = true - -set = minetest.settings:get("mcl_hbarmor_tick") -if tonumber(set) ~= nil then - mcl_hbarmor.tick = tonumber(set) +if tonumber(tick_config) then + mcl_hbarmor.tick = tonumber(tick_config) end -local must_hide = function(playername, arm) +local function must_hide(playername, arm) return arm == 0 end -local arm_printable = function(arm) +local function arm_printable(arm) return math.ceil(math.floor(arm+0.5)) end @@ -60,11 +59,8 @@ end hb.register_hudbar("armor", 0xFFFFFF, S("Armor"), { icon = "hbarmor_icon.png", bgicon = "hbarmor_bgicon.png", bar = "hbarmor_bar.png" }, 0, 0, 20, mcl_hbarmor.autohide) function mcl_hbarmor.get_armor(player) - if not player or not armor.def then - return false - end local name = player:get_player_name() - local pts = armor:get_armor_points(player) + local pts = player:get_meta():get_int("mcl_armor:armor_points") if not pts then return false else @@ -113,12 +109,13 @@ end) local main_timer = 0 local timer = 0 minetest.register_globalstep(function(dtime) + --TODO: replace this by playerglobalstep API then implemented main_timer = main_timer + dtime timer = timer + dtime if main_timer > mcl_hbarmor.tick or timer > 4 then if minetest.settings:get_bool("enable_damage") then if main_timer > mcl_hbarmor.tick then main_timer = 0 end - for _,player in pairs(minetest.get_connected_players()) do + for _,player in pairs(get_connected_players()) do local name = player:get_player_name() if mcl_hbarmor.player_active[name] == true then local ret = mcl_hbarmor.get_armor(player) diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index a69fcef5..6eac1c32 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_inventory") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape -- Prepare player info table @@ -7,8 +7,7 @@ local players = {} -- Containing all the items for each Creative Mode tab local inventory_lists = {} -local show_armor = minetest.get_modpath("mcl_armor") ~= nil -local mod_player = minetest.get_modpath("mcl_player") ~= nil +--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"} @@ -34,13 +33,13 @@ 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 is_redstone = function(def) + 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 is_tool = function(def) - return def.groups.tool or (def.tool_capabilities ~= nil and def.tool_capabilities.damage_groups == nil) + local function is_tool(def) + return def.groups.tool or (def.tool_capabilities and def.tool_capabilities.damage_groups == nil) end - local is_weapon_or_armor = function(def) + 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 @@ -162,7 +161,7 @@ end local function init(player) local playername = player:get_player_name() - local inv = minetest.create_detached_inventory("creative_"..playername, { + 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 @@ -204,12 +203,12 @@ local offset = {} -- string offset: local boffset = {} -- local hoch = {} local filtername = {} -local bg = {} +--local bg = {} local noffset_x_start = -0.24 local noffset_x = noffset_x_start local noffset_y = -0.25 -local next_noffset = function(id, right) +local function next_noffset(id, right) if right then noffset[id] = { 8.94, noffset_y } else @@ -258,7 +257,6 @@ hoch["mobs"] = "_down" hoch["matr"] = "_down" hoch["inv"] = "_down" -filtername = {} filtername["blocks"] = S("Building Blocks") filtername["deco"] = S("Decoration Blocks") filtername["redstone"] = S("Redstone") @@ -273,9 +271,9 @@ filtername["brew"] = S("Brewing") filtername["matr"] = S("Materials") filtername["inv"] = S("Survival Inventory") -local dark_bg = "crafting_creative_bg_dark.png" +--local dark_bg = "crafting_creative_bg_dark.png" -local function reset_menu_item_bg() +--[[local function reset_menu_item_bg() bg["blocks"] = dark_bg bg["deco"] = dark_bg bg["redstone"] = dark_bg @@ -290,11 +288,11 @@ local function reset_menu_item_bg() bg["matr"] = dark_bg bg["inv"] = dark_bg bg["default"] = dark_bg -end +end]] -mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_size, show, page, filter) - reset_menu_item_bg() +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() @@ -303,7 +301,7 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz if page == "nix" then local inv = minetest.get_inventory({type="detached", name="creative_"..playername}) inv_size = inv:get_size("main") - elseif page ~= nil and page ~= "inv" then + elseif page and page ~= "inv" then inv_size = #(inventory_lists[page]) else inv_size = 0 @@ -311,190 +309,171 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz end local pagemax = math.max(1, math.floor((inv_size-1) / (9*5) + 1)) local name = "nix" - local formspec = "" local main_list local listrings = "listring[detached:creative_"..playername..";main]".. "listring[current_player;main]".. "listring[detached:trash;main]" - if page ~= nil then + if page then name = page if players[playername] then players[playername].page = page end end - bg[name] = "crafting_creative_bg.png" + --bg[name] = "crafting_creative_bg.png" - local inv_bg = "crafting_inventory_creative.png" - if name == "inv" then - inv_bg = "crafting_inventory_creative_survival.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 - local img, img_player - if mod_player then - img_player = mcl_player.player_get_preview(player) - else - img_player = "player.png" - end - img = img_player - player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]" - if show_armor and armor.textures[playername] and armor.textures[playername].preview then - img = armor.textures[playername].preview - local s1 = img:find("character_preview") - if s1 ~= nil then - s1 = img:sub(s1+21) - img = img_player..s1 - end - player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]" - end - 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[detached:"..playername.."_armor;armor;2.5,1.3;1,1;1]".. - "list[detached:"..playername.."_armor;armor;2.5,2.75;1,1;2]".. - "list[detached:"..playername.."_armor;armor;5.5,1.3;1,1;3]".. - "list[detached:"..playername.."_armor;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]" + -- 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 - -- 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;]" + player_preview = "image[3.9,1.4;1.2333,2.4666;"..mcl_player.player_get_preview(player).."]" 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]" + -- 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 - local caption = "" - if name ~= "inv" and filtername[name] then - caption = "label[0,1.2;"..F(minetest.colorize(mcl_colors.DARK_GRAY, filtername[name])).."]" + 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 - 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 + -- 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")).."]" - 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 ~= nil then formspec = formspec .. "p"..tostring(pagenum) end + -- 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 @@ -564,7 +543,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) elseif fields.search == "" and not fields.creative_next and not fields.creative_prev then set_inv_page("all", player) page = "nix" - elseif fields.search ~= nil and not fields.creative_next and not fields.creative_prev then + 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 @@ -577,7 +556,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end -- Figure out current scroll bar from formspec - local formspec = player:get_inventory_formspec() + --local formspec = player:get_inventory_formspec() local start_i = players[name].start_i @@ -597,7 +576,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if page == "nix" then local inv = minetest.get_inventory({type="detached", name="creative_"..name}) inv_size = inv:get_size("main") - elseif page ~= nil and page ~= "inv" then + elseif page and page ~= "inv" then inv_size = #(inventory_lists[page]) else inv_size = 0 @@ -612,7 +591,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) players[name].start_i = start_i local filter = "" - if not fields.nix and fields.search ~= nil and fields.search ~= "" then + if not fields.nix and fields.search and fields.search ~= "" then filter = fields.search players[name].filter = filter end @@ -645,7 +624,7 @@ if minetest.is_creative_enabled("") then end mcl_inventory.update_inventory_formspec = function(player) - local page = nil + local page local name = player:get_player_name() @@ -656,14 +635,14 @@ if minetest.is_creative_enabled("") then end -- Figure out current scroll bar from formspec - local formspec = player:get_inventory_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 ~= nil and page ~= "inv" then + elseif page and page ~= "inv" then inv_size = #(inventory_lists[page]) else inv_size = 0 diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index e9da9486..c197bfdd 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -1,11 +1,10 @@ -local S = minetest.get_translator("mcl_inventory") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape mcl_inventory = {} -local show_armor = minetest.get_modpath("mcl_armor") ~= nil -local mod_player = minetest.get_modpath("mcl_player") ~= nil -local mod_craftguide = minetest.get_modpath("mcl_craftguide") ~= nil +--local mod_player = minetest.get_modpath("mcl_player") +--local mod_craftguide = minetest.get_modpath("mcl_craftguide") -- Returns a single itemstack in the given inventory to the main inventory, or drop it when there's no space left function return_item(itemstack, dropper, pos, inv) @@ -61,30 +60,12 @@ local function set_inventory(player, armor_change_only) inv:set_width("craft", 2) inv:set_size("craft", 4) - local player_name = player:get_player_name() - -- 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, 1.0, 0.0, 2.25, 4.5, "") else - local img, img_player - if mod_player then - img_player = mcl_player.player_get_preview(player) - else - img_player = "player.png" - end - img = img_player - player_preview = "image[0.6,0.2;2,4;"..img.."]" - if show_armor and armor.textures[player_name] and armor.textures[player_name].preview then - img = armor.textures[player_name].preview - local s1 = img:find("character_preview") - if s1 ~= nil then - s1 = img:sub(s1+21) - img = img_player..s1 - end - player_preview = "image[1.1,0.2;2,4;"..img.."]" - end + player_preview = "image[1.1,0.2;2,4;"..mcl_player.player_get_preview(player).."]" end local armor_slots = {"helmet", "chestplate", "leggings", "boots"} @@ -99,20 +80,20 @@ local function set_inventory(player, armor_change_only) "background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png]".. player_preview.. --armor - "list[detached:"..player_name.."_armor;armor;0,0;1,1;1]".. - "list[detached:"..player_name.."_armor;armor;0,1;1,1;2]".. - "list[detached:"..player_name.."_armor;armor;0,2;1,1;3]".. - "list[detached:"..player_name.."_armor;armor;0,3;1,1;4]".. + "list[current_player;armor;0,0;1,1;1]".. + "list[current_player;armor;0,1;1,1;2]".. + "list[current_player;armor;0,2;1,1;3]".. + "list[current_player;armor;0,3;1,1;4]".. mcl_formspec.get_itemslot_bg(0,0,1,1).. mcl_formspec.get_itemslot_bg(0,1,1,1).. mcl_formspec.get_itemslot_bg(0,2,1,1).. mcl_formspec.get_itemslot_bg(0,3,1,1).. armor_slot_imgs.. -- craft and inventory - "label[0,4;"..F(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,4;"..F(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,7.74;9,1;]".. - "label[4,0.5;"..F(minetest.colorize(mcl_colors.DARK_GRAY, S("Crafting"))).."]".. + "label[4,0.5;"..F(minetest.colorize("#313131", S("Crafting"))).."]".. "list[current_player;craft;4,1;2,2]".. "list[current_player;craftpreview;7,1.5;1,1;]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. @@ -133,10 +114,10 @@ local function set_inventory(player, armor_change_only) "tooltip[__mcl_achievements;"..F(S("Achievements")).."]".. -- for shortcuts "listring[current_player;main]".. - "listring[current_player;craft]".. - "listring[current_player;main]".. - "listring[detached:"..player_name.."_armor;armor]" - + "listring[current_player;armor]".. + "listring[current_player;main]" .. + "listring[current_player;craft]" .. + "listring[current_player;main]" player:set_inventory_formspec(form) end @@ -153,7 +134,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) if not minetest.is_creative_enabled("") then - mcl_inventory.update_inventory_formspec = function(player) + function mcl_inventory.update_inventory_formspec(player) set_inventory(player) end end @@ -176,18 +157,10 @@ minetest.register_on_joinplayer(function(player) player:hud_set_hotbar_image("mcl_inventory_hotbar.png") player:hud_set_hotbar_selected_image("mcl_inventory_hotbar_selected.png") - if show_armor then - local set_player_armor_original = armor.set_player_armor - local update_inventory_original = armor.update_inventory - armor.set_player_armor = function(self, player) - set_player_armor_original(self, player) - end - armor.update_inventory = function(self, player) - update_inventory_original(self, player) - set_inventory(player, true) - end - armor:set_player_armor(player) - armor:update_inventory(player) + local old_update_player = mcl_armor.update_player + function mcl_armor.update_player(player, info) + old_update_player(player, info) + set_inventory(player, true) end -- In Creative Mode, the initial inventory setup is handled in creative.lua @@ -205,6 +178,6 @@ minetest.register_on_joinplayer(function(player) end) if minetest.is_creative_enabled("") then - dofile(minetest.get_modpath("mcl_inventory").."/creative.lua") + dofile(minetest.get_modpath(minetest.get_current_modname()).."/creative.lua") end diff --git a/mods/HUD/mcl_inventory/mod.conf b/mods/HUD/mcl_inventory/mod.conf index edd6343c..7585d9f7 100644 --- a/mods/HUD/mcl_inventory/mod.conf +++ b/mods/HUD/mcl_inventory/mod.conf @@ -1,6 +1,6 @@ name = mcl_inventory author = BlockMen description = Adds the player inventory and creative inventory. -depends = mcl_init, mcl_formspec, mcl_colors -optional_depends = mcl_player, _mcl_autogroup, mcl_armor, mcl_brewing, mcl_potions, mcl_enchanting +depends = mcl_init, mcl_formspec, mcl_player +optional_depends = _mcl_autogroup, mcl_armor, mcl_brewing, mcl_potions, mcl_enchanting, mcl_craftguide diff --git a/mods/HUD/show_wielded_item/init.lua b/mods/HUD/show_wielded_item/init.lua index bc06bee4..dfa87a85 100644 --- a/mods/HUD/show_wielded_item/init.lua +++ b/mods/HUD/show_wielded_item/init.lua @@ -6,12 +6,16 @@ local huds = {} local dtimes = {} local dlimit = 3 -- HUD element will be hidden after this many seconds +local math = math +local string = string +local tonumber = tonumber + local hudbars_mod = minetest.get_modpath("hudbars") local xp_mod = minetest.get_modpath("mcl_experience") local function set_hud(player) if not player:is_player() then return end - local player_name = player:get_player_name() + local player_name = player:get_player_name() -- Fixed offset in config file local fixed = tonumber(minetest.settings:get("show_wielded_item_y_offset")) local off @@ -74,7 +78,7 @@ minetest.register_globalstep(function(dtime) if dtimes[player_name] and dtimes[player_name] < dlimit then dtimes[player_name] = dtimes[player_name] + dtime if dtimes[player_name] > dlimit and huds[player_name] then - player:hud_change(huds[player_name], 'text', "") + player:hud_change(huds[player_name], "text", "") end end @@ -84,7 +88,7 @@ minetest.register_globalstep(function(dtime) wield[player_name] = wname dtimes[player_name] = 0 - if huds[player_name] then + if huds[player_name] then local def = minetest.registered_items[wname] local meta = wstack:get_meta() @@ -105,7 +109,7 @@ minetest.register_globalstep(function(dtime) if firstnewline then desc = string.sub(desc, 1, firstnewline-1) end - player:hud_change(huds[player_name], 'text', desc) + player:hud_change(huds[player_name], "text", desc) end end end diff --git a/mods/HUD/show_wielded_item/screenshot.png b/mods/HUD/show_wielded_item/screenshot.png deleted file mode 100644 index 50c2c626..00000000 Binary files a/mods/HUD/show_wielded_item/screenshot.png and /dev/null differ diff --git a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua index cd194b0d..3517e09c 100644 --- a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua @@ -1,8 +1,8 @@ -local S = minetest.get_translator("mcl_comparators") +local S = minetest.get_translator(minetest.get_current_modname()) -- Functions that get the input/output rules of the comparator -local comparator_get_output_rules = function(node) +local function comparator_get_output_rules(node) local rules = {{x = -1, y = 0, z = 0, spread=true}} for i = 0, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -11,7 +11,7 @@ local comparator_get_output_rules = function(node) end -local comparator_get_input_rules = function(node) +local function comparator_get_input_rules(node) local rules = { -- we rely on this order in update_self below {x = 1, y = 0, z = 0}, -- back @@ -27,13 +27,13 @@ end -- Functions that are called after the delay time -local comparator_turnon = function(params) +local function comparator_turnon(params) local rules = comparator_get_output_rules(params.node) mesecon.receptor_on(params.pos, rules) end -local comparator_turnoff = function(params) +local function comparator_turnoff(params) local rules = comparator_get_output_rules(params.node) mesecon.receptor_off(params.pos, rules) end @@ -41,14 +41,14 @@ end -- Functions that set the correct node type an schedule a turnon/off -local comparator_activate = function(pos, node) +local function comparator_activate(pos, node) local def = minetest.registered_nodes[node.name] minetest.swap_node(pos, { name = def.comparator_onstate, param2 = node.param2 }) minetest.after(0.1, comparator_turnon , {pos = pos, node = node}) end -local comparator_deactivate = function(pos, node) +local function comparator_deactivate(pos, node) local def = minetest.registered_nodes[node.name] minetest.swap_node(pos, { name = def.comparator_offstate, param2 = node.param2 }) minetest.after(0.1, comparator_turnoff, {pos = pos, node = node}) @@ -56,7 +56,7 @@ end -- weather pos has an inventory that contains at least one item -local container_inventory_nonempty = function(pos) +local function container_inventory_nonempty(pos) local invnode = minetest.get_node(pos) local invnodedef = minetest.registered_nodes[invnode.name] -- Ignore stale nodes @@ -78,14 +78,14 @@ local container_inventory_nonempty = function(pos) end -- weather pos has an constant signal output for the comparator -local static_signal_output = function(pos) +local function static_signal_output(pos) local node = minetest.get_node(pos) local g = minetest.get_item_group(node.name, "comparator_signal") return g > 0 end -- whether the comparator should be on according to its inputs -local comparator_desired_on = function(pos, node) +local function comparator_desired_on(pos, node) local my_input_rules = comparator_get_input_rules(node); local back_rule = my_input_rules[1] local state @@ -116,7 +116,7 @@ end -- update comparator state, if needed -local update_self = function(pos, node) +local function update_self(pos, node) node = node or minetest.get_node(pos) local old_state = mesecon.is_receptor_on(node.name) local new_state = comparator_desired_on(pos, node) @@ -131,7 +131,7 @@ end -- compute tile depending on state and mode -local get_tiles = function(state, mode) +local function get_tiles(state, mode) local top = "mcl_comparators_"..state..".png^".. "mcl_comparators_"..mode..".png" local sides = "mcl_comparators_sides_"..state..".png^".. @@ -146,13 +146,13 @@ local get_tiles = function(state, mode) end -- Given one mode, get the other mode -local flipmode = function(mode) +local function flipmode(mode) if mode == "comp" then return "sub" elseif mode == "sub" then return "comp" end end -local make_rightclick_handler = function(state, mode) +local function make_rightclick_handler(state, mode) local newnodename = "mcl_comparators:comparator_"..state.."_"..flipmode(mode) return function (pos, node, clicker) @@ -217,94 +217,94 @@ if minetest.get_modpath("screwdriver") then end for _, mode in pairs{"comp", "sub"} do -for _, state in pairs{mesecon.state.on, mesecon.state.off} do - local state_str = state_strs[state] - local nodename = - "mcl_comparators:comparator_"..state_strs[state].."_"..mode + for _, state in pairs{mesecon.state.on, mesecon.state.off} do + local state_str = state_strs[state] + local nodename = + "mcl_comparators:comparator_"..state_str.."_"..mode - -- Help - local longdesc, usagehelp, use_help - if state_strs[state] == "off" and mode == "comp" then - longdesc = S("Redstone comparators are multi-purpose redstone components.").."\n".. - S("They can transmit a redstone signal, detect whether a block contains any items and compare multiple signals.") + -- Help + local longdesc, usagehelp, use_help + if state_str == "off" and mode == "comp" then + longdesc = S("Redstone comparators are multi-purpose redstone components.").."\n".. + S("They can transmit a redstone signal, detect whether a block contains any items and compare multiple signals.") - usagehelp = S("A redstone comparator has 1 main input, 2 side inputs and 1 output. The output is in arrow direction, the main input is in the opposite direction. The other 2 sides are the side inputs.").."\n".. - S("The main input can powered in 2 ways: First, it can be powered directly by redstone power like any other component. Second, it is powered if, and only if a container (like a chest) is placed in front of it and the container contains at least one item.").."\n".. - S("The side inputs are only powered by normal redstone power. The redstone comparator can operate in two modes: Transmission mode and subtraction mode. It starts in transmission mode and the mode can be changed by using the block.").."\n\n".. - S("Transmission mode:\nThe front torch is unlit and lowered. The output is powered if, and only if the main input is powered. The two side inputs are ignored.").."\n".. - S("Subtraction mode:\nThe front torch is lit. The output is powered if, and only if the main input is powered and none of the side inputs is powered.") - else - use_help = false - end + usagehelp = S("A redstone comparator has 1 main input, 2 side inputs and 1 output. The output is in arrow direction, the main input is in the opposite direction. The other 2 sides are the side inputs.").."\n".. + S("The main input can powered in 2 ways: First, it can be powered directly by redstone power like any other component. Second, it is powered if, and only if a container (like a chest) is placed in front of it and the container contains at least one item.").."\n".. + S("The side inputs are only powered by normal redstone power. The redstone comparator can operate in two modes: Transmission mode and subtraction mode. It starts in transmission mode and the mode can be changed by using the block.").."\n\n".. + S("Transmission mode:\nThe front torch is unlit and lowered. The output is powered if, and only if the main input is powered. The two side inputs are ignored.").."\n".. + S("Subtraction mode:\nThe front torch is lit. The output is powered if, and only if the main input is powered and none of the side inputs is powered.") + else + use_help = false + end - local nodedef = { - description = S("Redstone Comparator"), - inventory_image = icon, - wield_image = icon, - _doc_items_create_entry = use_help, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, - drawtype = "nodebox", - tiles = get_tiles(state_strs[state], mode), - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - wield_image = "mcl_comparators_off.png", - walkable = true, - selection_box = collision_box, - collision_box = collision_box, - node_box = { - type = "fixed", - fixed = node_boxes[mode], - }, - groups = groups, - paramtype = "light", - paramtype2 = "facedir", - sunlight_propagates = false, - is_ground_content = false, - drop = 'mcl_comparators:comparator_off_comp', - on_construct = update_self, - on_rightclick = - make_rightclick_handler(state_strs[state], mode), - comparator_mode = mode, - comparator_onstate = "mcl_comparators:comparator_on_"..mode, - comparator_offstate = "mcl_comparators:comparator_off_"..mode, - sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = { - receptor = { - state = state, - rules = comparator_get_output_rules, + local nodedef = { + description = S("Redstone Comparator"), + inventory_image = icon, + wield_image = icon, + _doc_items_create_entry = use_help, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = usagehelp, + drawtype = "nodebox", + tiles = get_tiles(state_str, mode), + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + --wield_image = "mcl_comparators_off.png", + walkable = true, + selection_box = collision_box, + collision_box = collision_box, + node_box = { + type = "fixed", + fixed = node_boxes[mode], }, - effector = { - rules = comparator_get_input_rules, - action_change = update_self, - } - }, - on_rotate = on_rotate, - } + groups = groups, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = false, + is_ground_content = false, + drop = "mcl_comparators:comparator_off_comp", + on_construct = update_self, + on_rightclick = + make_rightclick_handler(state_str, mode), + comparator_mode = mode, + comparator_onstate = "mcl_comparators:comparator_on_"..mode, + comparator_offstate = "mcl_comparators:comparator_off_"..mode, + sounds = mcl_sounds.node_sound_stone_defaults(), + mesecons = { + receptor = { + state = state, + rules = comparator_get_output_rules, + }, + effector = { + rules = comparator_get_input_rules, + action_change = update_self, + } + }, + on_rotate = on_rotate, + } - if mode == "comp" and state == mesecon.state.off then - -- This is the prototype - nodedef._doc_items_create_entry = true - else - nodedef.groups = table.copy(nodedef.groups) - nodedef.groups.not_in_creative_inventory = 1 - local extra_desc = {} - if mode == "sub" or state == mesecon.state.on then - nodedef.inventory_image = nil + if mode == "comp" and state == mesecon.state.off then + -- This is the prototype + nodedef._doc_items_create_entry = true + else + nodedef.groups = table.copy(nodedef.groups) + nodedef.groups.not_in_creative_inventory = 1 + --local extra_desc = {} + if mode == "sub" or state == mesecon.state.on then + nodedef.inventory_image = nil + end + local desc = nodedef.description + if mode ~= "sub" and state == mesecon.state.on then + desc = S("Redstone Comparator (Powered)") + elseif mode == "sub" and state ~= mesecon.state.on then + desc = S("Redstone Comparator (Subtract)") + elseif mode == "sub" and state == mesecon.state.on then + desc = S("Redstone Comparator (Subtract, Powered)") + end + nodedef.description = desc end - local desc = nodedef.description - if mode ~= "sub" and state == mesecon.state.on then - desc = S("Redstone Comparator (Powered)") - elseif mode == "sub" and state ~= mesecon.state.on then - desc = S("Redstone Comparator (Subtract)") - elseif mode == "sub" and state == mesecon.state.on then - desc = S("Redstone Comparator (Subtract, Powered)") - end - nodedef.description = desc + + minetest.register_node(nodename, nodedef) + mcl_wip.register_wip_item(nodename) end - - minetest.register_node(nodename, nodedef) - mcl_wip.register_wip_item(nodename) -end end -- Register recipies @@ -351,9 +351,9 @@ minetest.register_abm({ -- Add entry aliases for the Help if minetest.get_modpath("doc") then doc.add_entry_alias("nodes", "mcl_comparators:comparator_off_comp", - "nodes", "mcl_comparators:comparator_off_sub") + "nodes", "mcl_comparators:comparator_off_sub") doc.add_entry_alias("nodes", "mcl_comparators:comparator_off_comp", - "nodes", "mcl_comparators:comparator_on_comp") + "nodes", "mcl_comparators:comparator_on_comp") doc.add_entry_alias("nodes", "mcl_comparators:comparator_off_comp", - "nodes", "mcl_comparators:comparator_on_sub") + "nodes", "mcl_comparators:comparator_on_sub") end diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 1fd63cb4..8cbf74b8 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -7,18 +7,18 @@ All node definitions share a lot of code, so this is the reason why there are so many weird tables below. ]] -local S = minetest.get_translator("mcl_dispensers") +local S = minetest.get_translator(minetest.get_current_modname()) -- For after_place_node -local setup_dispenser = function(pos) +local function setup_dispenser(pos) -- Set formspec and inventory local form = "size[9,8.75]".. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. "list[current_player;main;0,7.74;9,1;]".. mcl_formspec.get_itemslot_bg(0,7.74,9,1).. - "label[3,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Dispenser"))).."]".. + "label[3,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Dispenser"))).."]".. "list[current_name;main;3,0.5;3,3;]".. mcl_formspec.get_itemslot_bg(3,0.5,3,3).. "listring[current_name;main]".. @@ -29,7 +29,7 @@ local setup_dispenser = function(pos) inv:set_size("main", 9) end -local orientate_dispenser = function(pos, placer) +local function orientate_dispenser(pos, placer) -- Not placed by player if not placer then return end @@ -96,187 +96,127 @@ local dispenserdef = { end, _mcl_blast_resistance = 3.5, _mcl_hardness = 3.5, - mesecons = {effector = { - -- Dispense random item when triggered - action_on = function (pos, node) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local droppos, dropdir - if node.name == "mcl_dispensers:dispenser" then - dropdir = vector.multiply(minetest.facedir_to_dir(node.param2), -1) - droppos = vector.add(pos, dropdir) - elseif node.name == "mcl_dispensers:dispenser_up" then - dropdir = {x=0, y=1, z=0} - droppos = {x=pos.x, y=pos.y+1, z=pos.z} - elseif node.name == "mcl_dispensers:dispenser_down" then - dropdir = {x=0, y=-1, z=0} - droppos = {x=pos.x, y=pos.y-1, z=pos.z} - end - local dropnode = minetest.get_node(droppos) - local dropnodedef = minetest.registered_nodes[dropnode.name] - local stacks = {} - for i=1,inv:get_size("main") do - local stack = inv:get_stack("main", i) - if not stack:is_empty() then - table.insert(stacks, {stack = stack, stackpos = i}) + mesecons = { + effector = { + -- Dispense random item when triggered + action_on = function(pos, node) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local droppos, dropdir + if node.name == "mcl_dispensers:dispenser" then + dropdir = vector.multiply(minetest.facedir_to_dir(node.param2), -1) + droppos = vector.add(pos, dropdir) + elseif node.name == "mcl_dispensers:dispenser_up" then + dropdir = {x=0, y=1, z=0} + droppos = {x=pos.x, y=pos.y+1, z=pos.z} + elseif node.name == "mcl_dispensers:dispenser_down" then + dropdir = {x=0, y=-1, z=0} + droppos = {x=pos.x, y=pos.y-1, z=pos.z} end - end - if #stacks >= 1 then - local r = math.random(1, #stacks) - local stack = stacks[r].stack - local dropitem = ItemStack(stack) - dropitem:set_count(1) - local stack_id = stacks[r].stackpos - local stackdef = stack:get_definition() - local iname = stack:get_name() - local igroups = minetest.registered_items[iname].groups - - --[===[ Dispense item ]===] - - -- Hardcoded dispensions -- - - -- Armor, mob heads and pumpkins - if igroups.armor_head or igroups.armor_torso or igroups.armor_legs or igroups.armor_feet then - local armor_type, armor_slot - local armor_dispensed = false - if igroups.armor_head then - armor_type = "armor_head" - armor_slot = 2 - elseif igroups.armor_torso then - armor_type = "armor_torso" - armor_slot = 3 - elseif igroups.armor_legs then - armor_type = "armor_legs" - armor_slot = 4 - elseif igroups.armor_feet then - armor_type = "armor_feet" - armor_slot = 5 + local dropnode = minetest.get_node(droppos) + local dropnodedef = minetest.registered_nodes[dropnode.name] + local stacks = {} + for i=1,inv:get_size("main") do + local stack = inv:get_stack("main", i) + if not stack:is_empty() then + table.insert(stacks, {stack = stack, stackpos = i}) end + end + if #stacks >= 1 then + local r = math.random(1, #stacks) + local stack = stacks[r].stack + local dropitem = ItemStack(stack) + dropitem:set_count(1) + local stack_id = stacks[r].stackpos + local stackdef = stack:get_definition() + local iname = stack:get_name() + local igroups = minetest.registered_items[iname].groups - local droppos_below = {x=droppos.x, y=droppos.y-1, z=droppos.z} - local dropnode_below = minetest.get_node(droppos_below) - -- Put armor on player or armor stand - local standpos - if dropnode.name == "mcl_armor_stand:armor_stand" then - standpos = droppos - elseif dropnode_below.name == "mcl_armor_stand:armor_stand" then - standpos = droppos_below - end - if standpos then - local dropmeta = minetest.get_meta(standpos) - local dropinv = dropmeta:get_inventory() - if dropinv:room_for_item(armor_type, dropitem) then - dropinv:add_item(armor_type, dropitem) - minetest.registered_nodes["mcl_armor_stand:armor_stand"].on_metadata_inventory_put(standpos) - stack:take_item() - inv:set_stack("main", stack_id, stack) - armor:play_equip_sound(dropitem, nil, standpos) - armor_dispensed = true - end - else - -- Put armor on nearby player - -- First search for player in front of dispenser (check 2 nodes) - local objs1 = minetest.get_objects_inside_radius(droppos, 1) - local objs2 = minetest.get_objects_inside_radius(droppos_below, 1) - local objs_table = {objs1, objs2} - local player - for oi=1, #objs_table do - local objs_inner = objs_table[oi] - for o=1, #objs_inner do - --[[ First player in list is the lucky one. The other player get nothing :-( - If multiple players are close to the dispenser, it can be a bit - -- unpredictable on who gets the armor. ]] - if objs_inner[o]:is_player() then - player = objs_inner[o] + --[===[ Dispense item ]===] + + -- Hardcoded dispensions -- + + -- Armor, mob heads and pumpkins + if igroups.armor then + local droppos_below = {x = droppos.x, y = droppos.y - 1, z = droppos.z} + + for _, objs in ipairs({minetest.get_objects_inside_radius(droppos, 1), minetest.get_objects_inside_radius(droppos_below, 1)}) do + for _, obj in ipairs(objs) do + stack = mcl_armor.equip(stack, obj) + if stack:is_empty() then break end end - if player then + if stack:is_empty() then break end end - -- If player found, add armor - if player then - local ainv = minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"}) - local pinv = player:get_inventory() - if ainv:get_stack("armor", armor_slot):is_empty() and pinv:get_stack("armor", armor_slot):is_empty() then - ainv:set_stack("armor", armor_slot, dropitem) - pinv:set_stack("armor", armor_slot, dropitem) - armor:set_player_armor(player) - armor:update_inventory(player) - armor:play_equip_sound(dropitem, player) - stack:take_item() - inv:set_stack("main", stack_id, stack) - armor_dispensed = true - end - end - - -- Place head or pumpkin as node, if equipping it as armor has failed - if not armor_dispensed then + -- Place head or pumpkin as node, if equipping it as armor has failed + if not stack:is_empty() then if igroups.head or iname == "mcl_farming:pumpkin_face" then if dropnodedef.buildable_to then minetest.set_node(droppos, {name = iname, param2 = node.param2}) stack:take_item() - inv:set_stack("main", stack_id, stack) end end end - end - -- Spawn Egg - elseif igroups.spawn_egg then - -- Spawn mob - if not dropnodedef.walkable then - pointed_thing = { above = droppos, under = { x=droppos.x, y=droppos.y-1, z=droppos.z } } - minetest.add_entity(droppos, stack:get_name()) - - stack:take_item() inv:set_stack("main", stack_id, stack) - end + -- Spawn Egg + elseif igroups.spawn_egg then + -- Spawn mob + if not dropnodedef.walkable then + --pointed_thing = { above = droppos, under = { x=droppos.x, y=droppos.y-1, z=droppos.z } } + minetest.add_entity(droppos, stack:get_name()) - -- Generalized dispension - elseif (not dropnodedef.walkable or stackdef._dispense_into_walkable) then - --[[ _on_dispense(stack, pos, droppos, dropnode, dropdir) - * stack: Itemstack which is dispense - * pos: Position of dispenser - * droppos: Position to which to dispense item - * dropnode: Node of droppos - * dropdir: Drop direction - - _dispense_into_walkable: If true, can dispense into walkable nodes - ]] - if stackdef._on_dispense then - -- Item-specific dispension (if defined) - local od_ret = stackdef._on_dispense(dropitem, pos, droppos, dropnode, dropdir) - if od_ret then - local newcount = stack:get_count() - 1 - stack:set_count(newcount) - inv:set_stack("main", stack_id, stack) - if newcount == 0 then - inv:set_stack("main", stack_id, od_ret) - elseif inv:room_for_item("main", od_ret) then - inv:add_item("main", od_ret) - else - minetest.add_item(droppos, dropitem) - end - else stack:take_item() inv:set_stack("main", stack_id, stack) end - else - -- Drop item otherwise - minetest.add_item(droppos, dropitem) - stack:take_item() - inv:set_stack("main", stack_id, stack) + + -- Generalized dispension + elseif (not dropnodedef.walkable or stackdef._dispense_into_walkable) then + --[[ _on_dispense(stack, pos, droppos, dropnode, dropdir) + * stack: Itemstack which is dispense + * pos: Position of dispenser + * droppos: Position to which to dispense item + * dropnode: Node of droppos + * dropdir: Drop direction + + _dispense_into_walkable: If true, can dispense into walkable nodes + ]] + if stackdef._on_dispense then + -- Item-specific dispension (if defined) + local od_ret = stackdef._on_dispense(dropitem, pos, droppos, dropnode, dropdir) + if od_ret then + local newcount = stack:get_count() - 1 + stack:set_count(newcount) + inv:set_stack("main", stack_id, stack) + if newcount == 0 then + inv:set_stack("main", stack_id, od_ret) + elseif inv:room_for_item("main", od_ret) then + inv:add_item("main", od_ret) + else + minetest.add_item(droppos, dropitem) + end + else + stack:take_item() + inv:set_stack("main", stack_id, stack) + end + else + -- Drop item otherwise + minetest.add_item(droppos, dropitem) + stack:take_item() + inv:set_stack("main", stack_id, stack) + end end + + end - - - end - end, - rules = mesecon.rules.alldirs, - }}, + end, + rules = mesecon.rules.alldirs, + }, + }, on_rotate = on_rotate, } @@ -306,10 +246,11 @@ S("• Flint and steel: Is used to ignite a fire in air and to ignite TNT").."\n S("• Spawn eggs: Will summon the mob they contain").."\n".. S("• Other items: Are simply dropped") -horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing) +function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing) setup_dispenser(pos) orientate_dispenser(pos, placer) end + horizontal_def.tiles = { "default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", "default_furnace_side.png", @@ -347,7 +288,7 @@ minetest.register_node("mcl_dispensers:dispenser_up", up_def) minetest.register_craft({ - output = 'mcl_dispensers:dispenser', + output = "mcl_dispensers:dispenser", recipe = { {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, {"mcl_core:cobble", "mcl_bows:bow", "mcl_core:cobble",}, diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/mod.conf b/mods/ITEMS/REDSTONE/mcl_dispensers/mod.conf index ac1b56c7..13cdb5f5 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/mod.conf +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/mod.conf @@ -1,3 +1,3 @@ name = mcl_dispensers -depends = mcl_init, mcl_formspec, mesecons, mcl_sounds, mcl_tnt, mcl_worlds, mcl_core, mcl_nether, mcl_armor_stand, mcl_armor, mcl_colors +depends = mcl_init, mcl_formspec, mesecons, mcl_sounds, mcl_tnt, mcl_worlds, mcl_core, mcl_nether, mcl_armor_stand, mcl_armor optional_depends = doc, screwdriver diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index 0d41c355..4bfdbab4 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -8,18 +8,18 @@ All node definitions share a lot of code, so this is the reason why there are so many weird tables below. ]] -local S = minetest.get_translator("mcl_droppers") +local S = minetest.get_translator(minetest.get_current_modname()) -- For after_place_node -local setup_dropper = function(pos) +local function setup_dropper(pos) -- Set formspec and inventory local form = "size[9,8.75]".. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. "list[current_player;main;0,7.74;9,1;]".. mcl_formspec.get_itemslot_bg(0,7.74,9,1).. - "label[3,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Dropper"))).."]".. + "label[3,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Dropper"))).."]".. "list[current_name;main;3,0.5;3,3;]".. mcl_formspec.get_itemslot_bg(3,0.5,3,3).. "listring[current_name;main]".. @@ -30,7 +30,7 @@ local setup_dropper = function(pos) inv:set_size("main", 9) end -local orientate_dropper = function(pos, placer) +local function orientate_dropper(pos, placer) -- Not placed by player if not placer then return end @@ -98,7 +98,7 @@ local dropperdef = { _mcl_hardness = 3.5, mesecons = {effector = { -- Drop random item when triggered - action_on = function (pos, node) + action_on = function(pos, node) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local droppos @@ -152,7 +152,7 @@ horizontal_def.description = S("Dropper") horizontal_def._tt_help = S("9 inventory slots").."\n"..S("Drops item when powered by redstone power") horizontal_def._doc_items_longdesc = S("A dropper is a redstone component and a container with 9 inventory slots which, when supplied with redstone power, drops an item or puts it into a container in front of it.") horizontal_def._doc_items_usagehelp = S("Droppers can be placed in 6 possible directions, items will be dropped out of the hole. Use the dropper to access its inventory. Supply it with redstone energy once to make the dropper drop or transfer a random item.") -horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing) +function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing) setup_dropper(pos) orientate_dropper(pos, placer) end @@ -195,7 +195,7 @@ minetest.register_node("mcl_droppers:dropper_up", up_def) -- Ladies and gentlemen, I present to you: the crafting recipe! minetest.register_craft({ - output = 'mcl_droppers:dropper', + output = "mcl_droppers:dropper", recipe = { {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, {"mcl_core:cobble", "", "mcl_core:cobble",}, diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua index b41d9c2f..f140a958 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua @@ -8,17 +8,17 @@ All node definitions share a lot of code, so this is the reason why there are so many weird tables below. ]] -local S = minetest.get_translator("mcl_droppers") +local S = minetest.get_translator(minetest.get_current_modname()) -- For after_place_node -local setup_dropper = function(pos) +local function setup_dropper(pos) -- Set formspec and inventory local form = "size[9,8.75]".. "background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]".. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,7.74;9,1;]".. - "label[3,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Dropper"))).."]".. + "label[3,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Dropper"))).."]".. "list[current_name;main;3,0.5;3,3;]".. "listring[current_name;main]".. "listring[current_player;main]" @@ -28,7 +28,7 @@ local setup_dropper = function(pos) inv:set_size("main", 9) end -local orientate_dropper = function(pos, placer) +local function orientate_dropper(pos, placer) -- Not placed by player if not placer then return end @@ -96,7 +96,7 @@ local dropperdef = { _mcl_hardness = 3.5, mesecons = {effector = { -- Drop random item when triggered - action_on = function (pos, node) + action_on = function(pos, node) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local droppos @@ -149,14 +149,16 @@ local horizontal_def = table.copy(dropperdef) horizontal_def.description = S("Dropper") horizontal_def._doc_items_longdesc = S("A dropper is a redstone component and a container with 9 inventory slots which, when supplied with redstone power, drops an item or puts it into a container in front of it.") horizontal_def._doc_items_usagehelp = S("Droppers can be placed in 6 possible directions, items will be dropped out of the hole. Use the dropper to access its inventory. Supply it with redstone energy once to make the dropper drop or transfer a random item.") -horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing) + +function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing) setup_dropper(pos) orientate_dropper(pos, placer) end + horizontal_def.tiles = { "default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", "default_furnace_side.png", - "default_furnace_side.png", "mcl_droppers_dropper_front_horizontal.png" + "default_furnace_side.png", "mcl_droppers_dropper_front_horizontal.png", } horizontal_def.paramtype2 = "facedir" horizontal_def.groups = {pickaxey=1, container=2, material_stone=1} @@ -170,7 +172,7 @@ down_def.after_place_node = setup_dropper down_def.tiles = { "default_furnace_top.png", "mcl_droppers_dropper_front_vertical.png", "default_furnace_side.png", "default_furnace_side.png", - "default_furnace_side.png", "default_furnace_side.png" + "default_furnace_side.png", "default_furnace_side.png", } down_def.groups = {pickaxey=1, container=2,not_in_creative_inventory=1, material_stone=1} down_def._doc_items_create_entry = false @@ -184,7 +186,7 @@ up_def.description = S("Upwards-Facing Dropper") up_def.tiles = { "mcl_droppers_dropper_front_vertical.png", "default_furnace_bottom.png", "default_furnace_side.png", "default_furnace_side.png", - "default_furnace_side.png", "default_furnace_side.png" + "default_furnace_side.png", "default_furnace_side.png", } minetest.register_node("mcl_droppers:dropper_up", up_def) @@ -192,7 +194,7 @@ minetest.register_node("mcl_droppers:dropper_up", up_def) -- Ladies and gentlemen, I present to you: the crafting recipe! minetest.register_craft({ - output = 'mcl_droppers:dropper', + output = "mcl_droppers:dropper", recipe = { {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, {"mcl_core:cobble", "", "mcl_core:cobble",}, diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/mod.conf b/mods/ITEMS/REDSTONE/mcl_droppers/mod.conf index b5cf8f0b..bbb1c19f 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/mod.conf +++ b/mods/ITEMS/REDSTONE/mcl_droppers/mod.conf @@ -1,3 +1,3 @@ name = mcl_droppers -depends = mcl_init, mcl_formspec, mesecons, mcl_util, mcl_colors +depends = mcl_init, mcl_formspec, mesecons, mcl_util optional_depends = doc, screwdriver diff --git a/mods/ITEMS/REDSTONE/mcl_observers/init.lua b/mods/ITEMS/REDSTONE/mcl_observers/init.lua index 932f4f64..6045b567 100644 --- a/mods/ITEMS/REDSTONE/mcl_observers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_observers/init.lua @@ -1,7 +1,11 @@ -local S = minetest.get_translator("mcl_observers") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_observers = {} +local string = string + +local get_node = minetest.get_node + -- Warning! TODO: Remove this message. -- 'realtime' is experimental feature! It can slow down the everything! -- Please set it to false and restart the game if something's wrong: @@ -11,7 +15,7 @@ local realtime = true local rules_flat = { { x = 0, y = 0, z = -1, spread = true }, } -local get_rules_flat = function(node) +local function get_rules_flat(node) local rules = rules_flat for i=1, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -24,7 +28,7 @@ local rules_up = {{ x = 0, y = -1, z = 0, spread = true }} function mcl_observers.observer_activate(pos) minetest.after(mcl_vars.redstone_tick, function(pos) - local node = minetest.get_node(pos) + local node = get_node(pos) if not node then return end @@ -46,8 +50,8 @@ end -- and update the observer state if needed. -- TODO: Also scan metadata changes. -- TODO: Ignore some node changes. -local observer_scan = function(pos, initialize) - local node = minetest.get_node(pos) +local function observer_scan(pos, initialize) + local node = get_node(pos) local front if node.name == "mcl_observers:observer_up_off" or node.name == "mcl_observers:observer_up_on" then front = vector.add(pos, {x=0, y=1, z=0}) @@ -56,7 +60,7 @@ local observer_scan = function(pos, initialize) else front = vector.add(pos, minetest.facedir_to_dir(node.param2)) end - local frontnode = minetest.get_node(front) + local frontnode = get_node(front) local meta = minetest.get_meta(pos) local oldnode = meta:get_string("node_name") local oldparam2 = meta:get_string("node_param2") @@ -87,14 +91,14 @@ local observer_scan = function(pos, initialize) end -- Vertical orientation (CURRENTLY DISABLED) -local observer_orientate = function(pos, placer) +local function observer_orientate(pos, placer) -- Not placed by player if not placer then return end -- Placer pitch in degrees local pitch = placer:get_look_vertical() * (180 / math.pi) - local node = minetest.get_node(pos) + --local node = get_node(pos) if pitch > 55 then -- player looking upwards -- Observer looking downwards minetest.set_node(pos, {name="mcl_observers:observer_down_off"}) @@ -104,162 +108,167 @@ local observer_orientate = function(pos, placer) end end -mesecon.register_node("mcl_observers:observer", -{ - is_ground_content = false, - sounds = mcl_sounds.node_sound_stone_defaults(), - paramtype2 = "facedir", - on_rotate = false, - _mcl_blast_resistance = 3.5, - _mcl_hardness = 3.5, -}, -{ - description = S("Observer"), - _tt_help = S("Emits redstone pulse when block in front changes"), - _doc_items_longdesc = S("An observer is a redstone component which observes the block in front of it and sends a very short redstone pulse whenever this block changes."), - _doc_items_usagehelp = S("Place the observer directly in front of the block you want to observe with the “face” looking at the block. The arrow points to the side of the output, which is at the opposite side of the “face”. You can place your redstone dust or any other component here."), +mesecon.register_node("mcl_observers:observer", { + is_ground_content = false, + sounds = mcl_sounds.node_sound_stone_defaults(), + paramtype2 = "facedir", + on_rotate = false, + _mcl_blast_resistance = 3.5, + _mcl_hardness = 3.5, + }, { + description = S("Observer"), + _tt_help = S("Emits redstone pulse when block in front changes"), + _doc_items_longdesc = S("An observer is a redstone component which observes the block in front of it and sends a very short redstone pulse whenever this block changes."), + _doc_items_usagehelp = S("Place the observer directly in front of the block you want to observe with the “face” looking at the block. The arrow points to the side of the output, which is at the opposite side of the “face”. You can place your redstone dust or any other component here."), - groups = {pickaxey=1, material_stone=1, not_opaque=1, }, - tiles = { - "mcl_observers_observer_top.png^[transformR180", "default_furnace_bottom.png", - "mcl_observers_observer_side.png", "mcl_observers_observer_side.png", - "mcl_observers_observer_front.png", "mcl_observers_observer_back.png", - }, - mesecons = { receptor = { - state = mesecon.state.off, - rules = get_rules_flat, - }}, - on_construct = function(pos) - if not realtime then - observer_scan(pos, true) - end - end, - after_place_node = observer_orientate, -}, -{ - _doc_items_create_entry = false, - groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, - tiles = { - "mcl_observers_observer_top.png^[transformR180", "default_furnace_bottom.png", - "mcl_observers_observer_side.png", "mcl_observers_observer_side.png", - "mcl_observers_observer_front.png", "mcl_observers_observer_back_lit.png", - }, - mesecons = { receptor = { - state = mesecon.state.on, - rules = get_rules_flat, - }}, + groups = {pickaxey=1, material_stone=1, not_opaque=1, }, + tiles = { + "mcl_observers_observer_top.png^[transformR180", "default_furnace_bottom.png", + "mcl_observers_observer_side.png", "mcl_observers_observer_side.png", + "mcl_observers_observer_front.png", "mcl_observers_observer_back.png", + }, + mesecons = { + receptor = { + state = mesecon.state.off, + rules = get_rules_flat, + }, + }, + on_construct = function(pos) + if not realtime then + observer_scan(pos, true) + end + end, + after_place_node = observer_orientate, + }, { + _doc_items_create_entry = false, + groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, + tiles = { + "mcl_observers_observer_top.png^[transformR180", "default_furnace_bottom.png", + "mcl_observers_observer_side.png", "mcl_observers_observer_side.png", + "mcl_observers_observer_front.png", "mcl_observers_observer_back_lit.png", + }, + mesecons = { + receptor = { + state = mesecon.state.on, + rules = get_rules_flat, + } + }, - -- VERY quickly disable observer after construction - on_construct = function(pos) - local timer = minetest.get_node_timer(pos) - timer:start(mcl_vars.redstone_tick) - end, - on_timer = function(pos, elapsed) - local node = minetest.get_node(pos) - minetest.set_node(pos, {name = "mcl_observers:observer_off", param2 = node.param2}) - mesecon.receptor_off(pos, get_rules_flat(node)) - end, -} + -- VERY quickly disable observer after construction + on_construct = function(pos) + local timer = minetest.get_node_timer(pos) + timer:start(mcl_vars.redstone_tick) + end, + on_timer = function(pos, elapsed) + local node = get_node(pos) + minetest.set_node(pos, {name = "mcl_observers:observer_off", param2 = node.param2}) + mesecon.receptor_off(pos, get_rules_flat(node)) + end, + } ) -mesecon.register_node("mcl_observers:observer_down", -{ - is_ground_content = false, - sounds = mcl_sounds.node_sound_stone_defaults(), - groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, - on_rotate = false, - _mcl_blast_resistance = 3.5, - _mcl_hardness = 3.5, - drop = "mcl_observers:observer_off", -}, -{ - tiles = { - "mcl_observers_observer_back.png", "mcl_observers_observer_front.png", - "mcl_observers_observer_side.png^[transformR90", "mcl_observers_observer_side.png^[transformR90", - "mcl_observers_observer_top.png", "mcl_observers_observer_top.png", - }, - mesecons = { receptor = { - state = mesecon.state.off, - rules = rules_down, - }}, - on_construct = function(pos) - if not realtime then - observer_scan(pos, true) - end - end, -}, -{ - _doc_items_create_entry = false, - tiles = { - "mcl_observers_observer_back_lit.png", "mcl_observers_observer_front.png", - "mcl_observers_observer_side.png^[transformR90", "mcl_observers_observer_side.png^[transformR90", - "mcl_observers_observer_top.png", "mcl_observers_observer_top.png", - }, - mesecons = { receptor = { - state = mesecon.state.on, - rules = rules_down, - }}, +mesecon.register_node("mcl_observers:observer_down", { + is_ground_content = false, + sounds = mcl_sounds.node_sound_stone_defaults(), + groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, + on_rotate = false, + _mcl_blast_resistance = 3.5, + _mcl_hardness = 3.5, + drop = "mcl_observers:observer_off", + }, { + tiles = { + "mcl_observers_observer_back.png", "mcl_observers_observer_front.png", + "mcl_observers_observer_side.png^[transformR90", "mcl_observers_observer_side.png^[transformR90", + "mcl_observers_observer_top.png", "mcl_observers_observer_top.png", + }, + mesecons = { + receptor = { + state = mesecon.state.off, + rules = rules_down, + }, + }, + on_construct = function(pos) + if not realtime then + observer_scan(pos, true) + end + end, + }, { + _doc_items_create_entry = false, + tiles = { + "mcl_observers_observer_back_lit.png", "mcl_observers_observer_front.png", + "mcl_observers_observer_side.png^[transformR90", "mcl_observers_observer_side.png^[transformR90", + "mcl_observers_observer_top.png", "mcl_observers_observer_top.png", + }, + mesecons = { + receptor = { + state = mesecon.state.on, + rules = rules_down, + }, + }, - -- VERY quickly disable observer after construction - on_construct = function(pos) - local timer = minetest.get_node_timer(pos) - timer:start(mcl_vars.redstone_tick) - end, - on_timer = function(pos, elapsed) - local node = minetest.get_node(pos) - minetest.set_node(pos, {name = "mcl_observers:observer_down_off", param2 = node.param2}) - mesecon.receptor_off(pos, rules_down) - end, -}) + -- VERY quickly disable observer after construction + on_construct = function(pos) + local timer = minetest.get_node_timer(pos) + timer:start(mcl_vars.redstone_tick) + end, + on_timer = function(pos, elapsed) + local node = get_node(pos) + minetest.set_node(pos, {name = "mcl_observers:observer_down_off", param2 = node.param2}) + mesecon.receptor_off(pos, rules_down) + end, + } +) -mesecon.register_node("mcl_observers:observer_up", -{ - is_ground_content = false, - sounds = mcl_sounds.node_sound_stone_defaults(), - groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, - on_rotate = false, - _mcl_blast_resistance = 3.5, - _mcl_hardness = 3.5, - drop = "mcl_observers:observer_off", -}, -{ - tiles = { - "mcl_observers_observer_front.png", "mcl_observers_observer_back.png", - "mcl_observers_observer_side.png^[transformR270", "mcl_observers_observer_side.png^[transformR270", - "mcl_observers_observer_top.png^[transformR180", "mcl_observers_observer_top.png^[transformR180", - }, - mesecons = { receptor = { - state = mesecon.state.off, - rules = rules_up, - }}, - on_construct = function(pos) - if not realtime then - observer_scan(pos, true) - end - end, -}, -{ - _doc_items_create_entry = false, - tiles = { - "mcl_observers_observer_front.png", "mcl_observers_observer_back_lit.png", - "mcl_observers_observer_side.png^[transformR270", "mcl_observers_observer_side.png^[transformR270", - "mcl_observers_observer_top.png^[transformR180", "mcl_observers_observer_top.png^[transformR180", - }, - mesecons = { receptor = { - state = mesecon.state.on, - rules = rules_up, - }}, +mesecon.register_node("mcl_observers:observer_up", { + is_ground_content = false, + sounds = mcl_sounds.node_sound_stone_defaults(), + groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, + on_rotate = false, + _mcl_blast_resistance = 3.5, + _mcl_hardness = 3.5, + drop = "mcl_observers:observer_off", + }, { + tiles = { + "mcl_observers_observer_front.png", "mcl_observers_observer_back.png", + "mcl_observers_observer_side.png^[transformR270", "mcl_observers_observer_side.png^[transformR270", + "mcl_observers_observer_top.png^[transformR180", "mcl_observers_observer_top.png^[transformR180", + }, + mesecons = { + receptor = { + state = mesecon.state.off, + rules = rules_up, + }, + }, + on_construct = function(pos) + if not realtime then + observer_scan(pos, true) + end + end, + }, { + _doc_items_create_entry = false, + tiles = { + "mcl_observers_observer_front.png", "mcl_observers_observer_back_lit.png", + "mcl_observers_observer_side.png^[transformR270", "mcl_observers_observer_side.png^[transformR270", + "mcl_observers_observer_top.png^[transformR180", "mcl_observers_observer_top.png^[transformR180", + }, + mesecons = { + receptor = { + state = mesecon.state.on, + rules = rules_up, + }, + }, - -- VERY quickly disable observer after construction - on_construct = function(pos) - local timer = minetest.get_node_timer(pos) - timer:start(mcl_vars.redstone_tick) - end, - on_timer = function(pos, elapsed) - minetest.set_node(pos, {name = "mcl_observers:observer_up_off"}) - mesecon.receptor_off(pos, rules_up) - end, -}) + -- VERY quickly disable observer after construction + on_construct = function(pos) + local timer = minetest.get_node_timer(pos) + timer:start(mcl_vars.redstone_tick) + end, + on_timer = function(pos, elapsed) + minetest.set_node(pos, {name = "mcl_observers:observer_up_off"}) + mesecon.receptor_off(pos, rules_up) + end, + } +) minetest.register_craft({ output = "mcl_observers:observer_off", @@ -267,7 +276,7 @@ minetest.register_craft({ { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, { "mcl_nether:quartz", "mesecons:redstone", "mesecons:redstone" }, { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, - } + }, }) minetest.register_craft({ output = "mcl_observers:observer_off", @@ -275,7 +284,7 @@ minetest.register_craft({ { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, { "mesecons:redstone", "mesecons:redstone", "mcl_nether:quartz" }, { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, - } + }, }) if realtime then @@ -286,138 +295,138 @@ if realtime then mcl_observers.remove_node = minetest.remove_node mcl_observers.bulk_set_node = minetest.bulk_set_node - minetest.add_node=function(pos,node) + function minetest.add_node(pos,node) mcl_observers.add_node(pos,node) - local n=minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}) + local n = get_node({x=pos.x+1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==-1 then mcl_observers.observer_activate({x=pos.x+1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}) + n = get_node({x=pos.x-1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==1 then mcl_observers.observer_activate({x=pos.x-1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z+1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==-1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z+1}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z-1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z-1}) end - n=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y-1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_u" then mcl_observers.observer_activate({x=pos.x,y=pos.y-1,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y+1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_d" then mcl_observers.observer_activate({x=pos.x,y=pos.y+1,z=pos.z}) end end - minetest.set_node=function(pos,node) + function minetest.set_node(pos,node) mcl_observers.set_node(pos,node) - local n=minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}) + local n = get_node({x=pos.x+1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==-1 then mcl_observers.observer_activate({x=pos.x+1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}) + n = get_node({x=pos.x-1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==1 then mcl_observers.observer_activate({x=pos.x-1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z+1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==-1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z+1}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z-1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z-1}) end - n=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y-1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_u" then mcl_observers.observer_activate({x=pos.x,y=pos.y-1,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y+1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_d" then mcl_observers.observer_activate({x=pos.x,y=pos.y+1,z=pos.z}) end end - minetest.swap_node=function(pos,node) + function minetest.swap_node(pos,node) mcl_observers.swap_node(pos,node) - local n=minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}) + local n = get_node({x=pos.x+1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==-1 then mcl_observers.observer_activate({x=pos.x+1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}) + n = get_node({x=pos.x-1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==1 then mcl_observers.observer_activate({x=pos.x-1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z+1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==-1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z+1}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z-1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z-1}) end - n=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y-1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_u" then mcl_observers.observer_activate({x=pos.x,y=pos.y-1,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y+1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_d" then mcl_observers.observer_activate({x=pos.x,y=pos.y+1,z=pos.z}) end end - minetest.remove_node=function(pos) + function minetest.remove_node(pos) mcl_observers.remove_node(pos) - local n=minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}) + local n = get_node({x=pos.x+1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==-1 then mcl_observers.observer_activate({x=pos.x+1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}) + n = get_node({x=pos.x-1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==1 then mcl_observers.observer_activate({x=pos.x-1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z+1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==-1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z+1}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z-1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z-1}) end - n=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y-1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_u" then mcl_observers.observer_activate({x=pos.x,y=pos.y-1,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y+1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_d" then mcl_observers.observer_activate({x=pos.x,y=pos.y+1,z=pos.z}) end end - minetest.bulk_set_node=function(lst, node) + function minetest.bulk_set_node(lst, node) mcl_observers.bulk_set_node(lst, node) for _, pos in pairs(lst) do - local n=minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}) + local n = get_node({x=pos.x+1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==-1 then mcl_observers.observer_activate({x=pos.x+1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}) + n = get_node({x=pos.x-1,y=pos.y,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==1 then mcl_observers.observer_activate({x=pos.x-1,y=pos.y,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z+1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==-1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z+1}) end - n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}) + n = get_node({x=pos.x,y=pos.y,z=pos.z-1}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==1 then mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z-1}) end - n=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y-1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_u" then mcl_observers.observer_activate({x=pos.x,y=pos.y-1,z=pos.z}) end - n=minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) + n = get_node({x=pos.x,y=pos.y+1,z=pos.z}) if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_d" then mcl_observers.observer_activate({x=pos.x,y=pos.y+1,z=pos.z}) end @@ -454,7 +463,7 @@ minetest.register_lbm({ "mcl_observers:observer_down_on", "mcl_observers:observer_up_on", }, - run_at_every_load = true, + run_at_every_load = true, action = function(pos) minetest.after(1, mcl_observers.observer_activate, {x=pos.x, y=pos.y, z=pos.z}) end, diff --git a/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua b/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua index eabe73d1..489a81b4 100644 --- a/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua +++ b/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua @@ -1,3 +1,5 @@ +local table = table + mesecon.queue.actions={} -- contains all ActionQueue actions function mesecon.queue:add_function(name, func) @@ -31,7 +33,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior end end - if (toremove ~= nil) then + if toremove then table.remove(mesecon.queue.actions, toremove) end @@ -43,7 +45,7 @@ end -- this makes sure that resuming mesecons circuits when restarting minetest works fine -- However, even that does not work in some cases, that's why we delay the time the globalsteps -- start to be execute by 5 seconds -local get_highest_priority = function (actions) +local function get_highest_priority(actions) local highestp = -1 local highesti for i, ac in ipairs(actions) do diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index f4ed9df4..dbe3ebe1 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -138,7 +138,7 @@ local function receptor_get_rules(node) local receptor = mesecon.get_receptor(node.name) if receptor then local rules = receptor.rules - if type(rules) == 'function' then + if type(rules) == "function" then return rules(node) elseif rules then return rules @@ -179,7 +179,7 @@ function mesecon.effector_get_rules(node) local effector = mesecon.get_effector(node.name) if effector then local rules = effector.rules - if type(rules) == 'function' then + if type(rules) == "function" then return rules(node) elseif rules then return rules @@ -329,7 +329,7 @@ function mesecon.get_conductor_on(node_off, rulename) return conductor.states[tonumber(binstate,2)+1] end end - return offstate + return conductor.offstate end function mesecon.get_conductor_off(node_on, rulename) @@ -345,14 +345,14 @@ function mesecon.get_conductor_off(node_on, rulename) return conductor.states[tonumber(binstate,2)+1] end end - return onstate + return conductor.onstate end function mesecon.conductor_get_rules(node) local conductor = mesecon.get_conductor(node.name) if conductor then local rules = conductor.rules - if type(rules) == 'function' then + if type(rules) == "function" then return rules(node) elseif rules then return rules @@ -391,9 +391,7 @@ function mesecon.turnon(pos, link) local f = table.remove(frontiers, 1) local node = get_node_force(f.pos) - if not node then - -- Area does not exist; do nothing - elseif mesecon.is_conductor_off(node, f.link) then + if node and mesecon.is_conductor_off(node, f.link) then local rules = mesecon.conductor_get_rules(node) -- Call turnon on neighbors @@ -453,9 +451,7 @@ function mesecon.turnoff(pos, link) local f = table.remove(frontiers, 1) local node = get_node_force(f.pos) - if not node then - -- No-op - elseif mesecon.is_conductor_on(node, f.link) then + if node and mesecon.is_conductor_on(node, f.link) then local rules = mesecon.conductor_get_rules(node) for _, r in pairs(mesecon.rule2meta(f.link, rules)) do local np = vector.add(f.pos, r) diff --git a/mods/ITEMS/REDSTONE/mesecons/presets.lua b/mods/ITEMS/REDSTONE/mesecons/presets.lua index f624c52f..d9d8418d 100644 --- a/mods/ITEMS/REDSTONE/mesecons/presets.lua +++ b/mods/ITEMS/REDSTONE/mesecons/presets.lua @@ -96,12 +96,12 @@ local function rules_from_dir(ruleset, dir) if dir.z == -1 then return ruleset.zn end end -mesecon.rules.buttonlike_get = function(node) +function mesecon.rules.buttonlike_get(node) local dir = minetest.facedir_to_dir(node.param2) return rules_from_dir(rules_buttonlike, dir) end -mesecon.rules.wallmounted_get = function(node) +function mesecon.rules.wallmounted_get(node) local dir = minetest.wallmounted_to_dir(node.param2) return rules_from_dir(rules_wallmounted, dir) end diff --git a/mods/ITEMS/REDSTONE/mesecons/services.lua b/mods/ITEMS/REDSTONE/mesecons/services.lua index 9addda8b..7d1fce2d 100644 --- a/mods/ITEMS/REDSTONE/mesecons/services.lua +++ b/mods/ITEMS/REDSTONE/mesecons/services.lua @@ -1,6 +1,6 @@ -- Dig and place services -mesecon.on_placenode = function(pos, node) +function mesecon.on_placenode(pos, node) mesecon.execute_autoconnect_hooks_now(pos, node) -- Receptors: Send on signal when active @@ -70,14 +70,14 @@ mesecon.on_placenode = function(pos, node) end end -mesecon.on_dignode = function(pos, node) +function mesecon.on_dignode(pos, node) if mesecon.is_conductor_on(node) then mesecon.receptor_off(pos, mesecon.conductor_get_rules(node)) elseif mesecon.is_receptor_on(node.name) then mesecon.receptor_off(pos, mesecon.receptor_get_rules(node)) end if minetest.get_item_group(node.name, "opaque") == 1 then - local sources = mesecon.is_powered(pos) + --local sources = mesecon.is_powered(pos) local neighbors = mesecon.mcl_get_neighbors(pos) for n=1, #neighbors do local npos = neighbors[n].pos @@ -95,7 +95,7 @@ mesecon.on_dignode = function(pos, node) mesecon.execute_autoconnect_hooks_queue(pos, node) end -mesecon.on_blastnode = function(pos, node) +function mesecon.on_blastnode(pos, node) local node = minetest.get_node(pos) minetest.remove_node(pos) mesecon.on_dignode(pos, node) diff --git a/mods/ITEMS/REDSTONE/mesecons_button/init.lua b/mods/ITEMS/REDSTONE/mesecons_button/init.lua index 377a24c0..2812b275 100644 --- a/mods/ITEMS/REDSTONE/mesecons_button/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_button/init.lua @@ -1,7 +1,7 @@ -- WALL BUTTON -- A button that when pressed emits power for a short moment and then turns off again -local S = minetest.get_translator("mesecons_button") +local S = minetest.get_translator(minetest.get_current_modname()) local button_sounds = {} -- remember button push sounds @@ -21,7 +21,7 @@ local boxes_on = { } -- Push the button -mesecon.push_button = function(pos, node) +function mesecon.push_button(pos, node) -- No-op if button is already pushed if mesecon.is_receptor_on(node) then return @@ -37,7 +37,7 @@ mesecon.push_button = function(pos, node) timer:start(def._mcl_button_timer) end -local on_button_place = function(itemstack, placer, pointed_thing) +local function on_button_place(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then -- no interaction possible with entities return itemstack @@ -86,7 +86,7 @@ end local buttonuse = S("Use the button to push it.") -mesecon.register_button = function(basename, description, texture, recipeitem, sounds, plusgroups, button_timer, push_by_arrow, longdesc, button_sound) +function mesecon.register_button(basename, description, texture, recipeitem, sounds, plusgroups, button_timer, push_by_arrow, longdesc, button_sound) local groups_off = table.copy(plusgroups) groups_off.attached_node=1 groups_off.dig_by_water=1 @@ -132,7 +132,7 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s _doc_items_usagehelp = buttonuse, on_place = on_button_place, node_placement_prediction = "", - on_rightclick = function (pos, node) + on_rightclick = function(pos, node) mesecon.push_button(pos, node) end, sounds = sounds, @@ -159,7 +159,7 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s sunlight_propagates = true, node_box = boxes_on, groups = groups_on, - drop = 'mesecons_button:button_'..basename..'_off', + drop = "mesecons_button:button_"..basename.."_off", _doc_items_create_entry = false, node_placement_prediction = "", sounds = sounds, diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index 1928f809..3902c3c1 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -1,6 +1,8 @@ -local S = minetest.get_translator("mesecons_commandblock") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape +local tonumber = tonumber + local color_red = mcl_colors.RED local command_blocks_activated = minetest.settings:get_bool("mcl_enable_commandblocks", true) @@ -27,7 +29,7 @@ local function resolve_commands(commands, pos) local commander = meta:get_string("commander") -- A non-printable character used while replacing “@@”. - local SUBSTITUTE_CHARACTER = '\26' -- ASCII SUB + local SUBSTITUTE_CHARACTER = "\26" -- ASCII SUB -- No players online: remove all commands containing -- problematic placeholders. @@ -72,7 +74,7 @@ end local function check_commands(commands, player_name) for _, command in pairs(commands:split("\n")) do local pos = command:find(" ") - local cmd, param = command, "" + local cmd = command if pos then cmd = command:sub(1, pos - 1) end @@ -103,10 +105,10 @@ local function commandblock_action_on(pos, node) if node.name ~= "mesecons_commandblock:commandblock_off" then return end - + local meta = minetest.get_meta(pos) local commander = meta:get_string("commander") - + if not command_blocks_activated then --minetest.chat_send_player(commander, msg_not_activated) return @@ -137,7 +139,7 @@ local function commandblock_action_off(pos, node) end end -local on_rightclick = function(pos, node, player, itemstack, pointed_thing) +local function on_rightclick(pos, node, player, itemstack, pointed_thing) if not command_blocks_activated then minetest.chat_send_player(player:get_player_name(), msg_not_activated) return @@ -192,18 +194,18 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing) minetest.show_formspec(pname, "commandblock_"..pos.x.."_"..pos.y.."_"..pos.z, formspec) end -local on_place = function(itemstack, placer, pointed_thing) +local function on_place(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then return itemstack end -- Use pointed node's on_rightclick function first, if present - local node = minetest.get_node(pointed_thing.under) - if placer and not placer: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, placer, itemstack) or itemstack - end - end + local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) + if new_stack then + return new_stack + end + + --local node = minetest.get_node(pointed_thing.under) local privs = minetest.get_player_privs(placer:get_player_name()) if not privs.maphack then @@ -295,8 +297,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end local index, _, x, y, z = string.find(formname, "commandblock_(-?%d+)_(-?%d+)_(-?%d+)") - if index ~= nil and x ~= nil and y ~= nil and z ~= nil then - local pos = {x=tonumber(x), y=tonumber(y), z=tonumber(z)} + if index and x and y and z then + local pos = {x = tonumber(x), y = tonumber(y), z = tonumber(z)} local meta = minetest.get_meta(pos) if not minetest.is_creative_enabled(player:get_player_name()) then minetest.chat_send_player(player:get_player_name(), S("Editing the command block has failed! You can only change the command block in Creative Mode!")) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf b/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf index a35c425f..26059530 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf @@ -1,3 +1,3 @@ name = mesecons_commandblock -depends = mesecons, mcl_colors +depends = mesecons, mcl_colors, mcl_util optional_depends = doc, doc_items diff --git a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua index caf5e965..fc12c0a3 100644 --- a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua @@ -1,10 +1,10 @@ -local S = minetest.get_translator("mesecons_delayer") +local S = minetest.get_translator(minetest.get_current_modname()) local DELAYS = { 0.1, 0.2, 0.3, 0.4 } local DEFAULT_DELAY = DELAYS[1] -- Function that get the input/output rules of the delayer -local delayer_get_output_rules = function(node) +local function delayer_get_output_rules(node) local rules = {{x = -1, y = 0, z = 0, spread=true}} for i = 0, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -12,7 +12,7 @@ local delayer_get_output_rules = function(node) return rules end -local delayer_get_input_rules = function(node) +local function delayer_get_input_rules(node) local rules = {{x = 1, y = 0, z = 0}} for i = 0, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -22,7 +22,7 @@ end -- Return the sides of a delayer. -- Those are used to toggle the lock state. -local delayer_get_sides = function(node) +local function delayer_get_sides(node) local rules = { {x = 0, y = 0, z = -1}, {x = 0, y = 0, z = 1}, @@ -35,7 +35,7 @@ end -- Make the repeater at pos try to lock any repeater it faces. -- Returns true if a repeater was locked. -local check_lock_repeater = function(pos, node) +local function check_lock_repeater(pos, node) -- Check the repeater at pos and look if it faces -- a repeater placed sideways. -- If yes, lock the second repeater. @@ -67,7 +67,7 @@ end -- Make the repeater at pos try to unlock any repeater it faces. -- Returns true if a repeater was unlocked. -local check_unlock_repeater = function(pos, node) +local function check_unlock_repeater(pos, node) -- Check the repeater at pos and look if it faces -- a repeater placed sideways. -- If yes, also check if the second repeater doesn't receive @@ -119,21 +119,19 @@ local check_unlock_repeater = function(pos, node) end -- Functions that are called after the delay time -local delayer_activate = function(pos, node) +local function delayer_activate(pos, node) local def = minetest.registered_nodes[node.name] local time = def.delayer_time minetest.set_node(pos, {name=def.delayer_onstate, param2=node.param2}) mesecon.queue:add_action(pos, "receptor_on", {delayer_get_output_rules(node)}, time, nil) - check_lock_repeater(pos, node) end -local delayer_deactivate = function(pos, node) +local function delayer_deactivate(pos, node) local def = minetest.registered_nodes[node.name] local time = def.delayer_time minetest.set_node(pos, {name=def.delayer_offstate, param2=node.param2}) mesecon.queue:add_action(pos, "receptor_off", {delayer_get_output_rules(node)}, time, nil) - check_unlock_repeater(pos, node) end @@ -145,236 +143,230 @@ end -- Register the 2 (states) x 4 (delay times) delayers for i = 1, 4 do -local groups = {} -if i == 1 then - groups = {dig_immediate=3,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,attached_node=1,redstone_repeater=i} -else - groups = {dig_immediate=3,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,attached_node=1,redstone_repeater=i,not_in_creative_inventory=1} -end + local groups + if i == 1 then + groups = {dig_immediate=3,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,attached_node=1,redstone_repeater=i} + else + groups = {dig_immediate=3,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,attached_node=1,redstone_repeater=i,not_in_creative_inventory=1} + end -local delaytime = DELAYS[i] + local delaytime = DELAYS[i] -local boxes -if i == 1 then -boxes = { - { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab - { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch - { -1/16, -6/16, 0/16, 1/16, -1/16, 2/16}, -- moved torch -} -elseif i == 2 then -boxes = { - { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab - { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch - { -1/16, -6/16, -2/16, 1/16, -1/16, 0/16}, -- moved torch -} -elseif i == 3 then -boxes = { - { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab - { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch - { -1/16, -6/16, -4/16, 1/16, -1/16, -2/16}, -- moved torch -} -elseif i == 4 then -boxes = { - { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab - { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch - { -1/16, -6/16, -6/16, 1/16, -1/16, -4/16}, -- moved torch -} -end + local boxes + if i == 1 then + boxes = { + { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab + { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch + { -1/16, -6/16, 0/16, 1/16, -1/16, 2/16}, -- moved torch + } + elseif i == 2 then + boxes = { + { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab + { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch + { -1/16, -6/16, -2/16, 1/16, -1/16, 0/16}, -- moved torch + } + elseif i == 3 then + boxes = { + { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab + { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch + { -1/16, -6/16, -4/16, 1/16, -1/16, -2/16}, -- moved torch + } + elseif i == 4 then + boxes = { + { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab + { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch + { -1/16, -6/16, -6/16, 1/16, -1/16, -4/16}, -- moved torch + } + end -local help, tt, longdesc, usagehelp, icon, on_construct -if i == 1 then - help = true - tt = S("Transmits redstone power only in one direction").."\n".. - S("Delays signal").."\n".. - S("Output locks when getting active redstone repeater signal from the side") - longdesc = S("Redstone repeaters are versatile redstone components with multiple purposes: 1. They only allow signals to travel in one direction. 2. They delay the signal. 3. Optionally, they can lock their output in one state.") - usagehelp = S("To power a redstone repeater, send a signal in “arrow” direction (the input). The signal goes out on the opposite side (the output) with a delay. To change the delay, use the redstone repeater. The delay is between 0.1 and 0.4 seconds long and can be changed in steps of 0.1 seconds. It is indicated by the position of the moving redstone torch.").."\n".. - S("To lock a repeater, send a signal from an adjacent repeater into one of its sides. While locked, the moving redstone torch disappears, the output doesn't change and the input signal is ignored.") - icon = "mesecons_delayer_item.png" - - -- Check sides of constructed repeater and lock it, if required - on_construct = function(pos) - local node = minetest.get_node(pos) - local sides = delayer_get_sides(node) - for s=1, #sides do - local spos = vector.add(pos, sides[s]) - local snode = minetest.get_node(spos) - -- Is there a powered repeater at one of our sides? - local g = minetest.get_item_group(snode.name, "redstone_repeater") - if g ~= 0 and mesecon.is_receptor_on(snode.name) then - -- The other repeater must also face towards the constructed node - local sface = delayer_get_output_rules(snode)[1] - local sface_pos = vector.add(spos, sface) - if vector.equals(sface_pos, pos) then - -- Repeater is facing towards us! Now we just need to lock the costructed node - if mesecon.is_powered(pos, delayer_get_input_rules(node)[1]) ~= false then - local newnode = {name="mesecons_delayer:delayer_on_locked", param2 = node.param2} - minetest.set_node(pos, newnode) - mesecon.queue:add_action(pos, "receptor_on", {delayer_get_output_rules(newnode)}, DEFAULT_DELAY, nil) - else - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_locked", param2 = node.param2}) + local help, tt, longdesc, usagehelp, icon, on_construct + if i == 1 then + help = true + tt = S("Transmits redstone power only in one direction").."\n".. + S("Delays signal").."\n".. + S("Output locks when getting active redstone repeater signal from the side") + longdesc = S("Redstone repeaters are versatile redstone components with multiple purposes: 1. They only allow signals to travel in one direction. 2. They delay the signal. 3. Optionally, they can lock their output in one state.") + usagehelp = S("To power a redstone repeater, send a signal in “arrow” direction (the input). The signal goes out on the opposite side (the output) with a delay. To change the delay, use the redstone repeater. The delay is between 0.1 and 0.4 seconds long and can be changed in steps of 0.1 seconds. It is indicated by the position of the moving redstone torch.").."\n".. + S("To lock a repeater, send a signal from an adjacent repeater into one of its sides. While locked, the moving redstone torch disappears, the output doesn't change and the input signal is ignored.") + icon = "mesecons_delayer_item.png" + -- Check sides of constructed repeater and lock it, if required + on_construct = function(pos) + local node = minetest.get_node(pos) + local sides = delayer_get_sides(node) + for s=1, #sides do + local spos = vector.add(pos, sides[s]) + local snode = minetest.get_node(spos) + -- Is there a powered repeater at one of our sides? + local g = minetest.get_item_group(snode.name, "redstone_repeater") + if g ~= 0 and mesecon.is_receptor_on(snode.name) then + -- The other repeater must also face towards the constructed node + local sface = delayer_get_output_rules(snode)[1] + local sface_pos = vector.add(spos, sface) + if vector.equals(sface_pos, pos) then + -- Repeater is facing towards us! Now we just need to lock the costructed node + if mesecon.is_powered(pos, delayer_get_input_rules(node)[1]) ~= false then + local newnode = {name="mesecons_delayer:delayer_on_locked", param2 = node.param2} + minetest.set_node(pos, newnode) + mesecon.queue:add_action(pos, "receptor_on", {delayer_get_output_rules(newnode)}, DEFAULT_DELAY, nil) + else + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_locked", param2 = node.param2}) + end + break end - break end end end + else + help = false end -else - help = false -end -local desc_off -if i == 1 then - desc_off = S("Redstone Repeater") -else - desc_off = S("Redstone Repeater (Delay @1)", i) -end + local desc_off + if i == 1 then + desc_off = S("Redstone Repeater") + else + desc_off = S("Redstone Repeater (Delay @1)", i) + end -minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { - description = desc_off, - inventory_image = icon, - wield_image = icon, - _tt_help = tt, - _doc_items_create_entry = help, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, - drawtype = "nodebox", - tiles = { - "mesecons_delayer_off.png", - "mcl_stairs_stone_slab_top.png", - "mesecons_delayer_sides_off.png", - "mesecons_delayer_sides_off.png", - "mesecons_delayer_ends_off.png", - "mesecons_delayer_ends_off.png", - }, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - wield_image = "mesecons_delayer_off.png", - walkable = true, - selection_box = { - type = "fixed", - fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, - }, - collision_box = { - type = "fixed", - fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, - }, - node_box = { - type = "fixed", - fixed = boxes - }, - groups = groups, - paramtype = "light", - paramtype2 = "facedir", - sunlight_propagates = false, - is_ground_content = false, - drop = 'mesecons_delayer:delayer_off_1', - on_rightclick = function (pos, node, clicker) - local protname = clicker:get_player_name() - if minetest.is_protected(pos, protname) then - minetest.record_protection_violation(pos, protname) - return - end - if node.name=="mesecons_delayer:delayer_off_1" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_off_2" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_off_3" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_off_4" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2}) - end - end, - on_construct = on_construct, - delayer_time = delaytime, - delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i), - delayer_lockstate = "mesecons_delayer:delayer_off_locked", - sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = { - receptor = - { - state = mesecon.state.off, - rules = delayer_get_output_rules + minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { + description = desc_off, + inventory_image = icon, + wield_image = icon, + _tt_help = tt, + _doc_items_create_entry = help, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = usagehelp, + drawtype = "nodebox", + tiles = { + "mesecons_delayer_off.png", + "mcl_stairs_stone_slab_top.png", + "mesecons_delayer_sides_off.png", + "mesecons_delayer_sides_off.png", + "mesecons_delayer_ends_off.png", + "mesecons_delayer_ends_off.png", }, - effector = - { - rules = delayer_get_input_rules, - action_on = delayer_activate - } - }, - on_rotate = on_rotate, -}) - - -minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { - description = S("Redstone Repeater (Delay @1, Powered)", i), - _doc_items_create_entry = false, - drawtype = "nodebox", - tiles = { - "mesecons_delayer_on.png", - "mcl_stairs_stone_slab_top.png", - "mesecons_delayer_sides_on.png", - "mesecons_delayer_sides_on.png", - "mesecons_delayer_ends_on.png", - "mesecons_delayer_ends_on.png", - }, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - walkable = true, - selection_box = { - type = "fixed", - fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, - }, - collision_box = { - type = "fixed", - fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, - }, - node_box = { - type = "fixed", - fixed = boxes - }, - groups = {dig_immediate = 3, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1, attached_node=1, redstone_repeater=i, not_in_creative_inventory = 1}, - paramtype = "light", - paramtype2 = "facedir", - sunlight_propagates = false, - is_ground_content = false, - drop = 'mesecons_delayer:delayer_off_1', - on_rightclick = function (pos, node, clicker) - local protname = clicker:get_player_name() - if minetest.is_protected(pos, protname) then - minetest.record_protection_violation(pos, protname) - return - end - if node.name=="mesecons_delayer:delayer_on_1" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_on_2",param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_on_2" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_on_3",param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_on_3" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_on_4",param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_on_4" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_on_1",param2=node.param2}) - end - end, - after_dig_node = function(pos, oldnode) - check_unlock_repeater(pos, oldnode) - end, - delayer_time = delaytime, - delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i), - delayer_lockstate = "mesecons_delayer:delayer_on_locked", - sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = { - receptor = - { - state = mesecon.state.on, - rules = delayer_get_output_rules + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + --wield_image = "mesecons_delayer_off.png", + walkable = true, + selection_box = { + type = "fixed", + fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, }, - effector = - { - rules = delayer_get_input_rules, - action_off = delayer_deactivate - } - }, - on_rotate = on_rotate, -}) + collision_box = { + type = "fixed", + fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, + }, + node_box = { + type = "fixed", + fixed = boxes + }, + groups = groups, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = false, + is_ground_content = false, + drop = "mesecons_delayer:delayer_off_1", + on_rightclick = function(pos, node, clicker) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.record_protection_violation(pos, protname) + return + end + if node.name=="mesecons_delayer:delayer_off_1" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_off_2" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_off_3" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_off_4" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2}) + end + end, + on_construct = on_construct, + delayer_time = delaytime, + delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i), + delayer_lockstate = "mesecons_delayer:delayer_off_locked", + sounds = mcl_sounds.node_sound_stone_defaults(), + mesecons = { + receptor = { + state = mesecon.state.off, + rules = delayer_get_output_rules, + }, + effector = { + rules = delayer_get_input_rules, + action_on = delayer_activate, + }, + }, + on_rotate = on_rotate, + }) + minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { + description = S("Redstone Repeater (Delay @1, Powered)", i), + _doc_items_create_entry = false, + drawtype = "nodebox", + tiles = { + "mesecons_delayer_on.png", + "mcl_stairs_stone_slab_top.png", + "mesecons_delayer_sides_on.png", + "mesecons_delayer_sides_on.png", + "mesecons_delayer_ends_on.png", + "mesecons_delayer_ends_on.png", + }, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + walkable = true, + selection_box = { + type = "fixed", + fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, + }, + collision_box = { + type = "fixed", + fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, + }, + node_box = { + type = "fixed", + fixed = boxes + }, + groups = {dig_immediate = 3, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1, attached_node=1, redstone_repeater=i, not_in_creative_inventory = 1}, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = false, + is_ground_content = false, + drop = "mesecons_delayer:delayer_off_1", + on_rightclick = function(pos, node, clicker) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.record_protection_violation(pos, protname) + return + end + --HACK! we already know the node name, so we should generate the function to avoid multiple checks + if node.name=="mesecons_delayer:delayer_on_1" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_on_2",param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_on_2" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_on_3",param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_on_3" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_on_4",param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_on_4" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_on_1",param2=node.param2}) + end + end, + after_dig_node = function(pos, oldnode) + check_unlock_repeater(pos, oldnode) + end, + delayer_time = delaytime, + delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i), + delayer_lockstate = "mesecons_delayer:delayer_on_locked", + sounds = mcl_sounds.node_sound_stone_defaults(), + mesecons = { + receptor = { + state = mesecon.state.on, + rules = delayer_get_output_rules, + }, + effector = { + rules = delayer_get_input_rules, + action_off = delayer_deactivate, + }, + }, + on_rotate = on_rotate, + }) end @@ -418,7 +410,7 @@ minetest.register_node("mesecons_delayer:delayer_off_locked", { paramtype2 = "facedir", sunlight_propagates = false, is_ground_content = false, - drop = 'mesecons_delayer:delayer_off_1', + drop = "mesecons_delayer:delayer_off_1", delayer_time = DEFAULT_DELAY, sounds = mcl_sounds.node_sound_stone_defaults(), mesecons = { @@ -473,7 +465,7 @@ minetest.register_node("mesecons_delayer:delayer_on_locked", { paramtype2 = "facedir", sunlight_propagates = false, is_ground_content = false, - drop = 'mesecons_delayer:delayer_off_1', + drop = "mesecons_delayer:delayer_off_1", delayer_time = DEFAULT_DELAY, sounds = mcl_sounds.node_sound_stone_defaults(), mesecons = { diff --git a/mods/ITEMS/REDSTONE/mesecons_lightstone/init.lua b/mods/ITEMS/REDSTONE/mesecons_lightstone/init.lua index c09bcf59..0e517e4d 100644 --- a/mods/ITEMS/REDSTONE/mesecons_lightstone/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_lightstone/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mesecons_lightstone") +local S = minetest.get_translator(minetest.get_current_modname()) local light = minetest.LIGHT_MAX @@ -11,7 +11,7 @@ minetest.register_node("mesecons_lightstone:lightstone_off", { _doc_items_longdesc = S("Redstone lamps are simple redstone components which glow brightly (light level @1) when they receive redstone power.", light), sounds = mcl_sounds.node_sound_glass_defaults(), mesecons = {effector = { - action_on = function (pos, node) + action_on = function(pos, node) minetest.swap_node(pos, {name="mesecons_lightstone:lightstone_on", param2 = node.param2}) end, rules = mesecon.rules.alldirs, @@ -29,7 +29,7 @@ minetest.register_node("mesecons_lightstone:lightstone_on", { light_source = light, sounds = mcl_sounds.node_sound_glass_defaults(), mesecons = {effector = { - action_off = function (pos, node) + action_off = function(pos, node) minetest.swap_node(pos, {name="mesecons_lightstone:lightstone_off", param2 = node.param2}) end, rules = mesecon.rules.alldirs, @@ -41,9 +41,9 @@ minetest.register_node("mesecons_lightstone:lightstone_on", { minetest.register_craft({ output = "mesecons_lightstone:lightstone_off", recipe = { - {'',"mesecons:redstone",''}, - {"mesecons:redstone",'mcl_nether:glowstone',"mesecons:redstone"}, - {'','mesecons:redstone',''}, + {"","mesecons:redstone",""}, + {"mesecons:redstone","mcl_nether:glowstone","mesecons:redstone"}, + {"","mesecons:redstone",""}, } }) diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index 8cd5ae87..fedb8fa5 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -1,3 +1,5 @@ +local table = table + --register stoppers for movestones/pistons mesecon.mvps_stoppers = {} @@ -6,8 +8,6 @@ mesecon.mvps_droppers = {} mesecon.on_mvps_move = {} mesecon.mvps_unmov = {} -local is_protected = minetest.is_protected - --- Objects (entities) that cannot be moved function mesecon.register_mvps_unmov(objectname) mesecon.mvps_unmov[objectname] = true; @@ -151,6 +151,7 @@ function mesecon.mvps_get_stack(pos, dir, maximum, piston_pos) -- add connected nodes to frontiers, connected is a vector list -- the vectors must be absolute positions local connected = {} + local has_loop if minetest.registered_nodes[nn.name] and minetest.registered_nodes[nn.name].mvps_sticky then connected, has_loop = minetest.registered_nodes[nn.name].mvps_sticky(np, nn, piston_pos) @@ -258,7 +259,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, n.meta = minetest.get_meta(n.pos):to_table() local is_dropper = mesecon.is_mvps_dropper(n.node, movedir, nodes, id) if is_dropper then - local drops = minetest.get_node_drops(n.node.name, "") + --local drops = minetest.get_node_drops(n.node.name, "") minetest.dig_node(n.pos) else minetest.remove_node(n.pos) diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua index 279e98ba..ac56d8bc 100644 --- a/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mesecons_noteblock") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math minetest.register_node("mesecons_noteblock:noteblock", { description = S("Note Block"), @@ -28,7 +30,7 @@ S("The note block will only play a note when it is below air, otherwise, it stay groups = {handy=1,axey=1, material_wood=1, flammable=-1}, is_ground_content = false, place_param2 = 0, - on_rightclick = function (pos, node, clicker) -- change sound when rightclicked + on_rightclick = function(pos, node, clicker) -- change sound when rightclicked local protname = clicker:get_player_name() if minetest.is_protected(pos, protname) then minetest.record_protection_violation(pos, protname) @@ -38,12 +40,12 @@ S("The note block will only play a note when it is below air, otherwise, it stay mesecon.noteblock_play(pos, node.param2) minetest.set_node(pos, node) end, - on_punch = function (pos, node) -- play current sound when punched + on_punch = function(pos, node) -- play current sound when punched mesecon.noteblock_play(pos, node.param2) end, sounds = mcl_sounds.node_sound_wood_defaults(), mesecons = {effector = { -- play sound when activated - action_on = function (pos, node) + action_on = function(pos, node) mesecon.noteblock_play(pos, node.param2) end, rules = mesecon.rules.alldirs, @@ -53,7 +55,7 @@ S("The note block will only play a note when it is below air, otherwise, it stay }) minetest.register_craft({ - output = '"mesecons_noteblock:noteblock" 1', + output = "mesecons_noteblock:noteblock", recipe = { {"group:wood", "group:wood", "group:wood"}, {"group:wood", "mesecons:redstone", "group:wood"}, @@ -124,7 +126,11 @@ local function param2_to_note_color(param2) return string.format("#%06X", color) end -mesecon.noteblock_play = function (pos, param2) +local function param2_to_pitch(param2) + return 2^((param2-12)/12) +end + +function mesecon.noteblock_play(pos, param2) local block_above_name = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name if block_above_name ~= "air" then -- Don't play sound if no air is above @@ -132,9 +138,6 @@ mesecon.noteblock_play = function (pos, param2) end local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name - local param2_to_pitch = function(param2) - return 2^((param2-12)/12) - end local pitched = false local soundname, pitch if block_below_name == "mcl_core:goldblock" then diff --git a/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua b/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua index 3230d980..7d5f4904 100644 --- a/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua @@ -1,30 +1,37 @@ -local S = minetest.get_translator("mesecons_pistons") +local S = minetest.get_translator(minetest.get_current_modname()) local PISTON_MAXIMUM_PUSH = 12 --- Get mesecon rules of pistons -local piston_rules = -{{x=0, y=0, z=1}, --everything apart from z- (pusher side) - {x=1, y=0, z=0}, - {x=-1, y=0, z=0}, - {x=0, y=1, z=0}, - {x=0, y=-1, z=0}} +--Get mesecon rules of pistons -local piston_up_rules = -{{x=0, y=0, z=-1}, --everything apart from y+ (pusher side) - {x=0, y=0, z=1}, - {x=-1, y=0, z=0}, - {x=1, y=0, z=0}, - {x=0, y=-1, z=0}} +--everything apart from z- (pusher side) +local piston_rules = { + {x=0, y=0, z=1}, + {x=1, y=0, z=0}, + {x=-1, y=0, z=0}, + {x=0, y=1, z=0}, + {x=0, y=-1, z=0}, +} -local piston_down_rules = -{{x=0, y=0, z=-1}, --everything apart from y- (pusher side) - {x=0, y=0, z=1}, - {x=-1, y=0, z=0}, - {x=1, y=0, z=0}, - {x=0, y=1, z=0}} +--everything apart from y+ (pusher side) +local piston_up_rules = { + {x=0, y=0, z=-1}, + {x=0, y=0, z=1}, + {x=-1, y=0, z=0}, + {x=1, y=0, z=0}, + {x=0, y=-1, z=0}, +} -local piston_get_rules = function (node) +--everything apart from y- (pusher side) +local piston_down_rules = { + {x=0, y=0, z=-1}, + {x=0, y=0, z=1}, + {x=-1, y=0, z=0}, + {x=1, y=0, z=0}, + {x=0, y=1, z=0}, +} + +local function piston_get_rules(node) local rules = piston_rules for i = 1, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -32,7 +39,7 @@ local piston_get_rules = function (node) return rules end -local piston_facedir_direction = function (node) +local function piston_facedir_direction(node) local rules = {{x = 0, y = 0, z = -1}} for i = 1, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -40,7 +47,7 @@ local piston_facedir_direction = function (node) return rules[1] end -local piston_get_direction = function (dir, node) +local function piston_get_direction(dir, node) if type(dir) == "function" then return dir(node) else @@ -50,7 +57,7 @@ end -- Remove pusher of piston. -- To be used when piston was destroyed or dug. -local piston_remove_pusher = function (pos, oldnode) +local function piston_remove_pusher(pos, oldnode) local pistonspec = minetest.registered_nodes[oldnode.name].mesecons_piston local dir = piston_get_direction(pistonspec.dir, oldnode) @@ -70,7 +77,7 @@ end -- Remove base node of piston. -- To be used when pusher was destroyed. -local piston_remove_base = function (pos, oldnode) +local function piston_remove_base(pos, oldnode) local basenodename = minetest.registered_nodes[oldnode.name].corresponding_piston local pistonspec = minetest.registered_nodes[basenodename].mesecons_piston @@ -89,7 +96,7 @@ local piston_remove_base = function (pos, oldnode) end end -local piston_on = function (pos, node) +local function piston_on(pos, node) local pistonspec = minetest.registered_nodes[node.name].mesecons_piston local dir = piston_get_direction(pistonspec.dir, node) @@ -113,7 +120,7 @@ local piston_on = function (pos, node) end end -local piston_off = function (pos, node) +local function piston_off(pos, node) local pistonspec = minetest.registered_nodes[node.name].mesecons_piston minetest.swap_node(pos, {param2 = node.param2, name = pistonspec.offname}) piston_remove_pusher (pos, node) @@ -124,13 +131,13 @@ local piston_off = function (pos, node) local dir = piston_get_direction(pistonspec.dir, node) local pullpos = vector.add(pos, vector.multiply(dir, 2)) local meta = minetest.get_meta(pos) - local success, stack, oldstack = mesecon.mvps_pull_single(pullpos, vector.multiply(dir, -1), PISTON_MAXIMUM_PUSH, meta:get_string("owner"), pos) + local success, stack = mesecon.mvps_pull_single(pullpos, vector.multiply(dir, -1), PISTON_MAXIMUM_PUSH, meta:get_string("owner"), pos) if success then mesecon.mvps_process_stack(pos, dir, stack) end end -local piston_orientate = function (pos, placer) +local function piston_orientate(pos, placer) mesecon.mvps_set_owner(pos, placer) -- not placed by player @@ -158,14 +165,14 @@ local piston_pusher_box = { fixed = { {-2/16, -2/16, -.5 + pt, 2/16, 2/16, .5 + pt}, {-.5 , -.5 , -.5 , .5 , .5 , -.5 + pt}, - } + }, } local piston_on_box = { type = "fixed", fixed = { {-.5, -.5, -.5 + pt, .5, .5, .5} - } + }, } @@ -195,18 +202,20 @@ minetest.register_node("mesecons_pistons:piston_normal_off", { "mesecons_piston_bottom.png^[transformR270", "mesecons_piston_back.png", "mesecons_piston_pusher_front.png" - }, - groups = {handy = 1, piston=1}, + }, + groups = {handy=1, piston=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, after_place_node = piston_orientate, mesecons_piston = pistonspec_normal, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_on = piston_on, - rules = piston_get_rules - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_get_rules + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -227,8 +236,8 @@ minetest.register_node("mesecons_pistons:piston_normal_on", { "mesecons_piston_bottom.png^[transformR270", "mesecons_piston_back.png", "mesecons_piston_on_front.png" - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -238,10 +247,12 @@ minetest.register_node("mesecons_pistons:piston_normal_on", { selection_box = piston_on_box, mesecons_piston = pistonspec_normal, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_get_rules - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_get_rules + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -257,10 +268,10 @@ minetest.register_node("mesecons_pistons:piston_pusher_normal", { "mesecons_piston_pusher_right.png", "mesecons_piston_pusher_back.png", "mesecons_piston_pusher_front.png" - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 1 }, + groups = {piston_pusher=1}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -299,7 +310,7 @@ minetest.register_node("mesecons_pistons:piston_sticky_off", { "mesecons_piston_bottom.png^[transformR270", "mesecons_piston_back.png", "mesecons_piston_pusher_front_sticky.png" - }, + }, groups = {handy=1, piston=2}, paramtype = "light", paramtype2 = "facedir", @@ -307,10 +318,12 @@ minetest.register_node("mesecons_pistons:piston_sticky_off", { after_place_node = piston_orientate, mesecons_piston = pistonspec_sticky, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_on = piston_on, - rules = piston_get_rules - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_get_rules + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -331,8 +344,8 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", { "mesecons_piston_bottom.png^[transformR270", "mesecons_piston_back.png", "mesecons_piston_on_front.png" - }, - groups = {handy=1, piston=2, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=2, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -342,10 +355,12 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", { selection_box = piston_on_box, mesecons_piston = pistonspec_sticky, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_get_rules - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_get_rules + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -361,10 +376,10 @@ minetest.register_node("mesecons_pistons:piston_pusher_sticky", { "mesecons_piston_pusher_right.png", "mesecons_piston_pusher_back.png", "mesecons_piston_pusher_front_sticky.png" - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 2 }, + groups = {piston_pusher=2}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -388,14 +403,14 @@ local piston_up_pusher_box = { fixed = { {-2/16, -.5 - pt, -2/16, 2/16, .5 - pt, 2/16}, {-.5 , .5 - pt, -.5 , .5 , .5 , .5}, - } + }, } local piston_up_on_box = { type = "fixed", fixed = { {-.5, -.5, -.5 , .5, .5-pt, .5} - } + }, } -- Normal @@ -404,7 +419,7 @@ local pistonspec_normal_up = { offname = "mesecons_pistons:piston_up_normal_off", onname = "mesecons_pistons:piston_up_normal_on", dir = {x = 0, y = 1, z = 0}, - pusher = "mesecons_pistons:piston_up_pusher_normal" + pusher = "mesecons_pistons:piston_up_pusher_normal", } -- offstate @@ -416,17 +431,19 @@ minetest.register_node("mesecons_pistons:piston_up_normal_off", { "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, drop = "mesecons_pistons:piston_normal_off", mesecons_piston = pistonspec_normal_up, - mesecons = {effector={ - action_on = piston_on, - rules = piston_up_rules, - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_up_rules, + }, + }, sounds = mcl_sounds.node_sound_stone_defaults({ footstep = mcl_sounds.node_sound_wood_defaults().footstep }), @@ -451,8 +468,8 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", { "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", - }, - groups = {handy=1, piston_=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston_=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -462,10 +479,12 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", { selection_box = piston_up_on_box, mesecons_piston = pistonspec_normal_up, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_up_rules, - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_up_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -481,10 +500,10 @@ minetest.register_node("mesecons_pistons:piston_up_pusher_normal", { "mesecons_piston_pusher_right.png^[transformR90", "mesecons_piston_pusher_bottom.png", "mesecons_piston_pusher_top.png^[transformR180", - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 1 }, + groups = {piston_pusher=1}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -507,7 +526,7 @@ local pistonspec_sticky_up = { onname = "mesecons_pistons:piston_up_sticky_on", dir = {x = 0, y = 1, z = 0}, pusher = "mesecons_pistons:piston_up_pusher_sticky", - sticky = true + sticky = true, } -- offstate @@ -519,8 +538,8 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_off", { "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", - }, - groups = {handy=1, piston=2, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=2, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -529,10 +548,12 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_off", { sounds = mcl_sounds.node_sound_stone_defaults({ footstep = mcl_sounds.node_sound_wood_defaults().footstep }), - mesecons = {effector={ - action_on = piston_on, - rules = piston_up_rules, - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_up_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -554,8 +575,8 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_on", { "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", - }, - groups = {handy=1, piston=2, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=2, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -565,10 +586,12 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_on", { selection_box = piston_up_on_box, mesecons_piston = pistonspec_sticky_up, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_up_rules, - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_up_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -584,10 +607,10 @@ minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", { "mesecons_piston_pusher_right.png^[transformR90", "mesecons_piston_pusher_bottom.png", "mesecons_piston_pusher_top.png^[transformR180", - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 2 }, + groups = {piston_pusher=2}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -611,14 +634,14 @@ local piston_down_pusher_box = { fixed = { {-2/16, -.5 + pt, -2/16, 2/16, .5 + pt, 2/16}, {-.5 , -.5 , -.5 , .5 , -.5 + pt, .5}, - } + }, } local piston_down_on_box = { type = "fixed", fixed = { {-.5, -.5+pt, -.5 , .5, .5, .5} - } + }, } @@ -641,18 +664,20 @@ minetest.register_node("mesecons_pistons:piston_down_normal_off", { "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, drop = "mesecons_pistons:piston_normal_off", mesecons_piston = pistonspec_normal_down, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_on = piston_on, - rules = piston_down_rules, - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_down_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -674,8 +699,8 @@ minetest.register_node("mesecons_pistons:piston_down_normal_on", { "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -685,10 +710,12 @@ minetest.register_node("mesecons_pistons:piston_down_normal_on", { selection_box = piston_down_on_box, mesecons_piston = pistonspec_normal_down, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_down_rules, - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_down_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -704,10 +731,10 @@ minetest.register_node("mesecons_pistons:piston_down_pusher_normal", { "mesecons_piston_pusher_right.png^[transformR270", "mesecons_piston_pusher_bottom.png^[transformR180", "mesecons_piston_pusher_top.png", - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 1 }, + groups = {piston_pusher=1}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -727,7 +754,7 @@ local pistonspec_sticky_down = { offname = "mesecons_pistons:piston_down_sticky_off", dir = {x = 0, y = -1, z = 0}, pusher = "mesecons_pistons:piston_down_pusher_sticky", - sticky = true + sticky = true, } -- offstate @@ -739,7 +766,7 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_off", { "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", - }, + }, groups = {handy=1, piston=2, not_in_creative_inventory = 1}, paramtype = "light", paramtype2 = "facedir", @@ -747,10 +774,12 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_off", { drop = "mesecons_pistons:piston_sticky_off", mesecons_piston = pistonspec_sticky_down, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_on = piston_on, - rules = piston_down_rules, - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_down_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -772,8 +801,8 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_on", { "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -783,10 +812,12 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_on", { selection_box = piston_down_on_box, mesecons_piston = pistonspec_sticky_down, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_down_rules, - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_down_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -802,10 +833,10 @@ minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", { "mesecons_piston_pusher_right.png^[transformR270", "mesecons_piston_pusher_bottom.png^[transformR180", "mesecons_piston_pusher_top.png", - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 2 }, + groups = {piston_pusher=2}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -834,12 +865,12 @@ mesecon.register_mvps_stopper("mesecons_pistons:piston_down_sticky_on") --craft recipes minetest.register_craft({ - output = 'mesecons_pistons:piston_normal_off', + output = "mesecons_pistons:piston_normal_off", recipe = { {"group:wood", "group:wood", "group:wood"}, {"mcl_core:cobble", "mcl_core:iron_ingot", "mcl_core:cobble"}, {"mcl_core:cobble", "mesecons:redstone", "mcl_core:cobble"}, - } + }, }) minetest.register_craft({ @@ -847,7 +878,7 @@ minetest.register_craft({ recipe = { {"mcl_mobitems:slimeball"}, {"mesecons_pistons:piston_normal_off"}, - } + }, }) -- Add entry aliases for the Help diff --git a/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua b/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua index 2e161ae4..c0894224 100644 --- a/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mesecons_pressureplates") +local S = minetest.get_translator(minetest.get_current_modname()) local PRESSURE_PLATE_INTERVAL = 0.04 @@ -116,7 +116,7 @@ function mesecon.register_pressure_plate(basename, description, textures_off, te wield_image = image_w, paramtype = "light", walkable = false, - description = description, + description = description, on_timer = pp_on_timer, on_construct = function(pos) minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) diff --git a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua index b256d87e..ed0e4c60 100644 --- a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mesecons_solarpanel") +local S = minetest.get_translator(minetest.get_current_modname()) local boxes = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 } @@ -81,11 +81,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", { }) minetest.register_craft({ - output = 'mesecons_solarpanel:solar_panel_off', + output = "mesecons_solarpanel:solar_panel_off", recipe = { - {'mcl_core:glass', 'mcl_core:glass', 'mcl_core:glass'}, - {'mcl_nether:quartz', 'mcl_nether:quartz', 'mcl_nether:quartz'}, - {'group:wood_slab', 'group:wood_slab', 'group:wood_slab'}, + {"mcl_core:glass", "mcl_core:glass", "mcl_core:glass"}, + {"mcl_nether:quartz", "mcl_nether:quartz", "mcl_nether:quartz"}, + {"group:wood_slab", "group:wood_slab", "group:wood_slab"}, } }) diff --git a/mods/ITEMS/REDSTONE/mesecons_torch/init.lua b/mods/ITEMS/REDSTONE/mesecons_torch/init.lua index c7c4a4ca..e49b843c 100644 --- a/mods/ITEMS/REDSTONE/mesecons_torch/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_torch/init.lua @@ -1,10 +1,10 @@ -- REDSTONE TORCH AND BLOCK OF REDSTONE -local S = minetest.get_translator("mesecons_torch") +local S = minetest.get_translator(minetest.get_current_modname()) local TORCH_COOLOFF = 120 -- Number of seconds it takes for a burned-out torch to reactivate -local rotate_torch_rules = function (rules, param2) +local function rotate_torch_rules(rules, param2) if param2 == 1 then return rules elseif param2 == 5 then @@ -20,7 +20,7 @@ local rotate_torch_rules = function (rules, param2) end end -local torch_get_output_rules = function(node) +local function torch_get_output_rules(node) if node.param2 == 1 then return { { x = -1, y = 0, z = 0 }, @@ -41,7 +41,7 @@ local torch_get_output_rules = function(node) end end -local torch_get_input_rules = function(node) +local function torch_get_input_rules(node) if node.param2 == 1 then return {{x = 0, y = -1, z = 0 }} else @@ -49,7 +49,7 @@ local torch_get_input_rules = function(node) end end -local torch_overheated = function(pos) +local function torch_overheated(pos) minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.02, max_hear_distance = 6}, true) minetest.add_particle({ pos = {x=pos.x, y=pos.y+0.2, z=pos.z}, @@ -62,7 +62,7 @@ local torch_overheated = function(pos) timer:start(TORCH_COOLOFF) end -local torch_action_on = function(pos, node) +local function torch_action_on(pos, node) local overheat if node.name == "mesecons_torch:mesecon_torch_on" then overheat = mesecon.do_overheat(pos) @@ -86,7 +86,7 @@ local torch_action_on = function(pos, node) end end -local torch_action_off = function(pos, node) +local function torch_action_off(pos, node) local overheat if node.name == "mesecons_torch:mesecon_torch_off" or node.name == "mesecons_torch:mesecon_torch_overheated" then overheat = mesecon.do_overheat(pos) @@ -111,89 +111,96 @@ local torch_action_off = function(pos, node) end minetest.register_craft({ - output = 'mesecons_torch:mesecon_torch_on', + output = "mesecons_torch:mesecon_torch_on", recipe = { {"mesecons:redstone"}, {"mcl_core:stick"},} }) -mcl_torches.register_torch("mesecon_torch_off", S("Redstone Torch (off)"), - nil, - nil, - "jeija_torches_off.png", - "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj", - {"jeija_torches_off.png"}, - 0, - {dig_immediate=3, dig_by_water=1, redstone_torch=2, mesecon_ignore_opaque_dig=1, not_in_creative_inventory=1}, - mcl_sounds.node_sound_wood_defaults(), - { - mesecons = { - receptor = { - state = mesecon.state.off, - rules = torch_get_output_rules, - }, - effector = { - state = mesecon.state.on, - rules = torch_get_input_rules, - action_off = torch_action_off, - }, +local off_def = { + name = "mesecon_torch_off", + description = S("Redstone Torch (off)"), + doc_items_create_entry = false, + icon = "jeija_torches_off.png", + tiles = {"jeija_torches_off.png"}, + light = 0, + groups = {dig_immediate=3, dig_by_water=1, redstone_torch=2, mesecon_ignore_opaque_dig=1, not_in_creative_inventory=1}, + sounds = mcl_sounds.node_sound_wood_defaults(), + drop = "mesecons_torch:mesecon_torch_on", +} + +mcl_torches.register_torch(off_def) + +local off_override = { + mesecons = { + receptor = { + state = mesecon.state.off, + rules = torch_get_output_rules, + }, + effector = { + state = mesecon.state.on, + rules = torch_get_input_rules, + action_off = torch_action_off, }, - drop = "mesecons_torch:mesecon_torch_on", - _doc_items_create_entry = false, } -) +} -mcl_torches.register_torch("mesecon_torch_overheated", S("Redstone Torch (overheated)"), - nil, - nil, - "jeija_torches_off.png", - "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj", - {"jeija_torches_off.png"}, - 0, - {dig_immediate=3, dig_by_water=1, redstone_torch=2, mesecon_ignore_opaque_dig=1, not_in_creative_inventory=1}, - mcl_sounds.node_sound_wood_defaults(), - { - drop = "mesecons_torch:mesecon_torch_on", - _doc_items_create_entry = false, - on_timer = function(pos, elapsed) - if not mesecon.is_powered(pos) then - local node = minetest.get_node(pos) - torch_action_off(pos, node) - end - end, - } -) +minetest.override_item("mesecons_torch:mesecon_torch_off", off_override) +minetest.override_item("mesecons_torch:mesecon_torch_off_wall", off_override) +local overheated_def = table.copy(off_def) +overheated_def.name = "mesecon_torch_overheated" +overheated_def.description = S("Redstone Torch (overheated)") +mcl_torches.register_torch(overheated_def) -mcl_torches.register_torch("mesecon_torch_on", S("Redstone Torch"), - S("A redstone torch is a redstone component which can be used to invert a redstone signal. It supplies its surrounding blocks with redstone power, except for the block it is attached to. A redstone torch is normally lit, but it can also be turned off by powering the block it is attached to. While unlit, a redstone torch does not power anything."), - S("Redstone torches can be placed at the side and on the top of full solid opaque blocks."), - "jeija_torches_on.png", - "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj", - {"jeija_torches_on.png"}, - 7, - {dig_immediate=3, dig_by_water=1, redstone_torch=1, mesecon_ignore_opaque_dig=1}, - mcl_sounds.node_sound_wood_defaults(), - { - on_destruct = function(pos, oldnode) +local overheated_override = { + on_timer = function(pos, elapsed) + if not mesecon.is_powered(pos) then local node = minetest.get_node(pos) - torch_action_on(pos, node) - end, - mesecons = { - receptor = { - state = mesecon.state.on, - rules = torch_get_output_rules - }, - effector = { - state = mesecon.state.off, - rules = torch_get_input_rules, - action_on = torch_action_on, - }, + torch_action_off(pos, node) + end + end +} + +minetest.override_item("mesecons_torch:mesecon_torch_overheated", overheated_override) +minetest.override_item("mesecons_torch:mesecon_torch_overheated_wall", overheated_override) + +local on_def = { + name = "mesecon_torch_on", + description = S("Redstone Torch"), + doc_items_longdesc = S("A redstone torch is a redstone component which can be used to invert a redstone signal. It supplies its surrounding blocks with redstone power, except for the block it is attached to. A redstone torch is normally lit, but it can also be turned off by powering the block it is attached to. While unlit, a redstone torch does not power anything."), + doc_items_usagehelp = S("Redstone torches can be placed at the side and on the top of full solid opaque blocks."), + icon = "jeija_torches_on.png", + tiles = {"jeija_torches_on.png"}, + light = 7, + groups = {dig_immediate=3, dig_by_water=1, redstone_torch=1, mesecon_ignore_opaque_dig=1}, + sounds = mcl_sounds.node_sound_wood_defaults(), +} + +mcl_torches.register_torch(on_def) + +local on_override = { + on_destruct = function(pos, oldnode) + local node = minetest.get_node(pos) + torch_action_on(pos, node) + end, + mesecons = { + receptor = { + state = mesecon.state.on, + rules = torch_get_output_rules }, - _tt_help = S("Provides redstone power when it's not powered itself"), - } -) + effector = { + state = mesecon.state.off, + rules = torch_get_input_rules, + action_on = torch_action_on, + }, + }, + _tt_help = S("Provides redstone power when it's not powered itself"), +} + +minetest.override_item("mesecons_torch:mesecon_torch_on", on_override) +minetest.override_item("mesecons_torch:mesecon_torch_on_wall", on_override) minetest.register_node("mesecons_torch:redstoneblock", { description = S("Block of Redstone"), @@ -215,16 +222,16 @@ minetest.register_node("mesecons_torch:redstoneblock", { minetest.register_craft({ output = "mesecons_torch:redstoneblock", recipe = { - {'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'}, - {'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'}, - {'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'}, + {"mesecons:wire_00000000_off","mesecons:wire_00000000_off","mesecons:wire_00000000_off"}, + {"mesecons:wire_00000000_off","mesecons:wire_00000000_off","mesecons:wire_00000000_off"}, + {"mesecons:wire_00000000_off","mesecons:wire_00000000_off","mesecons:wire_00000000_off"}, } }) minetest.register_craft({ - output = 'mesecons:wire_00000000_off 9', + output = "mesecons:wire_00000000_off 9", recipe = { - {'mesecons_torch:redstoneblock'}, + {"mesecons_torch:redstoneblock"}, } }) diff --git a/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua b/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua index a0ecf354..c251587d 100644 --- a/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua @@ -1,8 +1,8 @@ -local S = minetest.get_translator("mesecons_wallever") +local S = minetest.get_translator(minetest.get_current_modname()) local lever_get_output_rules = mesecon.rules.buttonlike_get -local on_rotate = function(pos, node, user, mode) +local function on_rotate(pos, node, user, mode) if mode == screwdriver.ROTATE_FACE then if node.param2 == 10 then node.param2 = 13 @@ -37,7 +37,6 @@ minetest.register_node("mesecons_walllever:wall_lever_off", { wield_image = "jeija_wall_lever.png", paramtype = "light", paramtype2 = "facedir", - drawtype = "mesh", mesh = "jeija_wall_lever_off.obj", sunlight_propagates = true, walkable = false, @@ -51,7 +50,7 @@ minetest.register_node("mesecons_walllever:wall_lever_off", { _tt_help = S("Provides redstone power while it's turned on"), _doc_items_longdesc = S("A lever is a redstone component which can be flipped on and off. It supplies redstone power to adjacent blocks while it is in the “on” state."), _doc_items_usagehelp = S("Use the lever to flip it on or off."), - on_rightclick = function (pos, node) + on_rightclick = function(pos, node) minetest.swap_node(pos, {name="mesecons_walllever:wall_lever_on", param2=node.param2}) mesecon.receptor_on(pos, lever_get_output_rules(node)) minetest.sound_play("mesecons_button_push", {pos=pos, max_hear_distance=16}, true) @@ -149,9 +148,9 @@ minetest.register_node("mesecons_walllever:wall_lever_on", { }, groups = {handy=1, not_in_creative_inventory = 1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1, attached_node_facedir=1}, is_ground_content = false, - drop = '"mesecons_walllever:wall_lever_off" 1', + drop = "mesecons_walllever:wall_lever_off", _doc_items_create_entry = false, - on_rightclick = function (pos, node) + on_rightclick = function(pos, node) minetest.swap_node(pos, {name="mesecons_walllever:wall_lever_off", param2=node.param2}) mesecon.receptor_off(pos, lever_get_output_rules(node)) minetest.sound_play("mesecons_button_push", {pos=pos, max_hear_distance=16, pitch=0.9}, true) @@ -167,10 +166,10 @@ minetest.register_node("mesecons_walllever:wall_lever_on", { }) minetest.register_craft({ - output = 'mesecons_walllever:wall_lever_off', + output = "mesecons_walllever:wall_lever_off", recipe = { - {'mcl_core:stick'}, - {'mcl_core:cobble'}, + {"mcl_core:stick"}, + {"mcl_core:cobble"}, } }) diff --git a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua index e0c5ac53..0f2febc4 100644 --- a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua @@ -4,7 +4,7 @@ -- Where 0 means the wire has no visual connection to that direction and -- 1 means that the wire visually connects to that other node. -local S = minetest.get_translator("mesecons_wires") +local S = minetest.get_translator(minetest.get_current_modname()) -- ####################### -- ## Update wire looks ## @@ -28,12 +28,12 @@ local wire_rules = {x= 0, y=-1, z=-1}} -- self_pos = pos of any mesecon node, from_pos = pos of conductor to getconnect for -local wire_getconnect = function (from_pos, self_pos) +local function wire_getconnect(from_pos, self_pos) local node = minetest.get_node(self_pos) if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].mesecons then -- rules of node to possibly connect to - local rules = {} + local rules if (minetest.registered_nodes[node.name].mesecon_wire) then rules = wire_rules else @@ -50,7 +50,7 @@ local wire_getconnect = function (from_pos, self_pos) end -- Update this node -local wire_updateconnect = function (pos) +local function wire_updateconnect(pos) local connections = {} for _, r in ipairs(wire_rules) do @@ -83,7 +83,7 @@ local wire_updateconnect = function (pos) minetest.set_node(pos, {name = "mesecons:wire_"..nodeid..state_suffix}) end -local update_on_place_dig = function (pos, node) +local function update_on_place_dig(pos, node) -- Update placed node (get_node again as it may have been dug) local nn = minetest.get_node(pos) if (minetest.registered_nodes[nn.name]) @@ -139,8 +139,8 @@ local selectionbox = } -- go to the next nodeid (ex.: 01000011 --> 01000100) -local nid_inc = function() end -nid_inc = function (nid) +local function nid_inc() end +function nid_inc(nid) local i = 0 while nid[i-1] ~= 1 do nid[i] = (nid[i] ~= 1) and 1 or 0 @@ -214,8 +214,7 @@ local function register_wires() local dot_off = "redstone_redstone_dust_dot.png^[colorize:#FF0000:"..ratio_off local dot_on = "redstone_redstone_dust_dot.png^[colorize:#FF0000:"..ratio_on - local tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off } - local tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on } + local tiles_off, tiles_on local wirehelp, tt, longdesc, usagehelp, img, desc_off, desc_on if nodeid == "00000000" then @@ -238,8 +237,8 @@ S("Read the help entries on the other redstone components to learn how redstone else -- Connected redstone wire table.insert(nodebox, box_center) - tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off, } - tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on, } + tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off } + tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on } wirehelp = false desc_off = S("Redstone Trail (@1)", nodeid) desc_on = S("Powered Redstone Trail (@1)", nodeid) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index 1845ed77..fbf6fb75 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_anvils") +local S = minetest.get_translator(minetest.get_current_modname()) local MAX_NAME_LENGTH = 35 local MAX_WEAR = 65535 @@ -16,7 +16,7 @@ local function get_anvil_formspec(set_name) end return "size[9,8.75]".. "background[-0.19,-0.25;9.41,9.49;mcl_anvils_inventory.png]".. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. "list[current_player;main;0,7.74;9,1;]".. @@ -27,7 +27,7 @@ local function get_anvil_formspec(set_name) mcl_formspec.get_itemslot_bg(4,2.5,1,1).. "list[context;output;8,2.5;1,1;]".. mcl_formspec.get_itemslot_bg(8,2.5,1,1).. - "label[3,0.1;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Repair and Name"))).."]".. + "label[3,0.1;"..minetest.formspec_escape(minetest.colorize("#313131", S("Repair and Name"))).."]".. "field[3.25,1;4,1;name;;"..minetest.formspec_escape(set_name).."]".. "field_close_on_enter[name;false]".. "button[7,0.7;2,1;name_button;"..minetest.formspec_escape(S("Set Name")).."]".. @@ -41,7 +41,7 @@ end -- needs to be used up to repair the tool. local function get_consumed_materials(tool, material) local wear = tool:get_wear() - local health = (MAX_WEAR - wear) + --local health = (MAX_WEAR - wear) local matsize = material:get_count() local materials_used = 0 for m=1, math.min(4, matsize) do @@ -74,10 +74,9 @@ end local function update_anvil_slots(meta) local inv = meta:get_inventory() local new_name = meta:get_string("set_name") - local input1, input2, output - input1 = inv:get_stack("input", 1) - input2 = inv:get_stack("input", 2) - output = inv:get_stack("output", 1) + local input1 = inv:get_stack("input", 1) + local input2 = inv:get_stack("input", 2) + --local output = inv:get_stack("output", 1) local new_output, name_item local just_rename = false @@ -181,7 +180,7 @@ local function update_anvil_slots(meta) end -- Set the new output slot - if new_output ~= nil then + if new_output then inv:set_stack("output", 1, new_output) end end @@ -243,7 +242,6 @@ end -- Returns true if anvil was destroyed. local function damage_anvil(pos) local node = minetest.get_node(pos) - local new if node.name == "mcl_anvils:anvil" then minetest.swap_node(pos, {name="mcl_anvils:anvil_damage_1", param2=node.param2}) damage_particles(pos, node) @@ -278,7 +276,6 @@ local function damage_anvil_by_using(pos) end local function damage_anvil_by_falling(pos, distance) - local chance local r = math.random(1, 100) if distance > 1 then if r <= (5*distance) then diff --git a/mods/ITEMS/mcl_anvils/mod.conf b/mods/ITEMS/mcl_anvils/mod.conf index cbb5dc22..cd4fa02a 100644 --- a/mods/ITEMS/mcl_anvils/mod.conf +++ b/mods/ITEMS/mcl_anvils/mod.conf @@ -1,5 +1,5 @@ name = mcl_anvils author = Wuzzy description = Anvils mods for MCL2 -depends = mcl_init, mcl_formspec, mcl_sounds, tt, mcl_enchanting, mcl_colors +depends = mcl_init, mcl_formspec, mcl_sounds, tt, mcl_enchanting optional_depends = mcl_core, screwdriver diff --git a/mods/ITEMS/mcl_armor/api.lua b/mods/ITEMS/mcl_armor/api.lua new file mode 100644 index 00000000..d58b5e66 --- /dev/null +++ b/mods/ITEMS/mcl_armor/api.lua @@ -0,0 +1,268 @@ +function mcl_armor.play_equip_sound(stack, obj, pos, unequip) + local def = stack:get_definition() + local estr = "equip" + if unequip then + estr = "unequip" + end + local snd = def.sounds and def.sounds["_mcl_armor_" .. estr] + if not snd then + -- Fallback sound + snd = { name = "mcl_armor_" .. estr .. "_generic" } + end + if snd then + local dist = 8 + if pos then + dist = 16 + end + minetest.sound_play(snd, {object = obj, pos = pos, gain = 0.5, max_hear_distance = dist}, true) + end +end + +function mcl_armor.on_equip(itemstack, obj) + local def = itemstack:get_definition() + mcl_armor.play_equip_sound(itemstack, obj) + if def._on_equip then + def._on_equip(obj, itemstack) + end + mcl_armor.update(obj) +end + +function mcl_armor.on_unequip(itemstack, obj) + local def = itemstack:get_definition() + mcl_armor.play_equip_sound(itemstack, obj, nil, true) + if def._on_unequip then + def._on_unequip(obj, itemstack) + end + mcl_armor.update(obj) +end + +function mcl_armor.equip(itemstack, obj, swap) + local def = itemstack:get_definition() + + if not def then + return itemstack + end + + local inv = mcl_util.get_inventory(obj, true) + + if not inv or inv:get_size("armor") == 0 then + return itemstack + end + + local element = mcl_armor.elements[def._mcl_armor_element or ""] + + if element then + local old_stack = inv:get_stack("armor", element.index) + + if swap or old_stack:is_empty() then + local new_stack + + if swap then + new_stack = itemstack + itemstack = old_stack + else + new_stack = itemstack:take_item() + end + + inv:set_stack("armor", element.index, new_stack) + mcl_armor.on_equip(new_stack, obj) + end + end + + return itemstack +end + +function mcl_armor.equip_on_use(itemstack, player, pointed_thing) + if not player or not player:is_player() then + return itemstack + end + + local new_stack = mcl_util.call_on_rightclick(itemstack, player, pointed_thing) + if new_stack then + return new_stack + end + + return mcl_armor.equip(itemstack, player) +end + +function mcl_armor.register_set(def) + local modname = minetest.get_current_modname() + local S = minetest.get_translator(modname) + local descriptions = def.descriptions or {} + local groups = def.groups or {} + local on_equip_callbacks = def.on_equip_callbacks or {} + local on_unequip_callbacks = def.on_unequip_callbacks or {} + local on_break_callbacks = def.on_break_callbacks or {} + local textures = def.textures or {} + local previews = def.previews or {} + local durabilities = def.durabilities or {} + local element_groups = def.element_groups or {} + + for name, element in pairs(mcl_armor.elements) do + local itemname = element.name .. "_" .. def.name + local itemstring = modname .. ":" .. itemname + + local groups = table.copy(groups) + groups["armor_" .. name] = 1 + groups["combat_armor_" .. name] = 1 + groups.armor = 1 + groups.combat_armor = 1 + groups.mcl_armor_points = def.points[name] + groups.mcl_armor_toughness = def.toughness + groups.mcl_armor_uses = (durabilities[name] or math.floor(def.durability * element.durability)) + 1 + groups.enchantability = def.enchantability + + for k, v in pairs(element_groups) do + groups[k] = v + end + + minetest.register_tool(itemstring, { + description = S(def.description .. " " .. (descriptions[name] or element.description)), + _doc_items_longdesc = mcl_armor.longdesc, + _doc_items_usagehelp = mcl_armor.usage, + inventory_image = modname .. "_inv_" .. itemname .. ".png", + _repair_material = def.repair_material or def.craft_material, + groups = groups, + sounds = { + _mcl_armor_equip = def.sound_equip or modname .. "_equip_" .. def.name, + _mcl_armor_unequip = def.sound_unequip or modname .. "_unequip_" .. def.name, + }, + on_place = mcl_armor.equip_on_use, + on_secondary_use = mcl_armor.equip_on_use, + _on_equip = on_equip_callbacks[name] or def.on_equip, + _on_unequip = on_unequip_callbacks[name] or def.on_unequip, + _on_break = on_break_callbacks[name] or def.on_break, + _mcl_armor_element = name, + _mcl_armor_texture = textures[name] or modname .. "_" .. itemname .. ".png", + _mcl_armor_preview = previews[name] or modname .. "_" .. itemname .. "_preview.png", + }) + + if def.craft_material then + minetest.register_craft({ + output = itemstring, + recipe = element.craft(def.craft_material), + }) + end + + if def.cook_material then + minetest.register_craft({ + type = "cooking", + output = def.cook_material, + recipe = itemstring, + cooktime = 10, + }) + end + end +end + +mcl_armor.protection_enchantments = { + flags = {}, + types = {}, + wildcard = {}, +} + +function mcl_armor.register_protection_enchantment(def) + local prot_def = {id = def.id, factor = def.factor} + if def.damage_flag then + local tbl = mcl_armor.protection_enchantments.flags[def.damage_flag] or {} + table.insert(tbl, prot_def) + mcl_armor.protection_enchantments.flags = tbl + elseif def.damage_type then + local tbl = mcl_armor.protection_enchantments.types[def.damage_type] or {} + table.insert(tbl, prot_def) + mcl_armor.protection_enchantments.types = tbl + else + table.insert(mcl_armor.protection_enchantments.wildcard, prot_def) + end + mcl_enchanting.enchantments[def.id] = { + name = def.name, + max_level = def.max_level or 4, + primary = def.primary or {combat_armor = true}, + secondary = {}, + disallow = {}, + incompatible = def.incompatible or {}, + weight = def.weight or 5, + description = def.description, + curse = false, + on_enchant = function() end, + requires_tool = false, + treasure = def.treasure or false, + power_range_table = def.power_range_table, + inv_combat_tab = true, + inv_tool_tab = false, + } +end + +function mcl_armor.update(obj) + local info = {points = 0, view_range_factors = {}} + + local inv = mcl_util.get_inventory(obj) + + if inv then + for i = 2, 5 do + local itemstack = inv:get_stack("armor", i) + + local itemname = itemstack:get_name() + if minetest.registered_aliases[itemname] then + itemname = minetest.registered_aliases[itemname] + end + + if not itemstack:is_empty() then + local def = itemstack:get_definition() + + local texture = def._mcl_armor_texture + + if texture then + if type(texture) == "function" then + texture = texture(obj, itemstack) + end + if texture then + info.texture = "(" .. texture .. ")" .. (info.texture and "^" .. info.texture or "") + end + end + + local preview = def._mcl_armor_preview + + if obj:is_player() and preview then + if type(preview) == "function" then + preview = preview(obj, itemstack) + end + if preview then + info.preview = "(player.png^[opacity:0^" .. def._mcl_armor_preview .. ")" .. (info.preview and "^" .. info.preview or "" ) + end + end + + info.points = info.points + minetest.get_item_group(itemname, "mcl_armor_points") + + local mob_range_mob = def._mcl_armor_mob_range_mob + + if mob_range_mob then + local factor = info.view_range_factors[mob_range_mob] + + if factor then + if factor > 0 then + info.view_range_factors[mob_range_mob] = factor * def._mcl_armor_mob_range_factor + end + else + info.view_range_factors[mob_range_mob] = def._mcl_armor_mob_range_factor + end + end + end + end + end + + info.texture = info.texture or "blank.png" + + if obj:is_player() then + info.preview = info.preview or "blank.png" + + mcl_armor.update_player(obj, info) + else + local luaentity = obj:get_luaentity() + + if luaentity.update_armor then + luaentity:update_armor(info) + end + end +end + diff --git a/mods/ITEMS/mcl_armor/armor.lua b/mods/ITEMS/mcl_armor/armor.lua deleted file mode 100644 index 05a02001..00000000 --- a/mods/ITEMS/mcl_armor/armor.lua +++ /dev/null @@ -1,672 +0,0 @@ -local ARMOR_INIT_DELAY = 1 -local ARMOR_INIT_TIMES = 1 -local ARMOR_BONES_DELAY = 1 - -local skin_mod = nil - -local modpath = minetest.get_modpath(minetest.get_current_modname()) - -armor = { - timer = 0, - elements = {"head", "torso", "legs", "feet"}, - physics = {"jump","speed","gravity"}, - formspec = "size[8,8.5]image[2,0.75;2,4;armor_preview]" - .."list[current_player;main;0,4.5;8,4;]" - .."list[current_player;craft;4,1;3,3;]" - .."list[current_player;craftpreview;7,2;1,1;]" - .."listring[current_player;main]" - .."listring[current_player;craft]", - textures = {}, - default_skin = "character", - last_damage_types = {}, -} - -if minetest.get_modpath("mcl_skins") then - skin_mod = "mcl_skins" -elseif minetest.get_modpath("skins") then - skin_mod = "skins" -elseif minetest.get_modpath("simple_skins") then - skin_mod = "simple_skins" -elseif minetest.get_modpath("u_skins") then - skin_mod = "u_skins" -elseif minetest.get_modpath("wardrobe") then - skin_mod = "wardrobe" -end - -function armor.on_armor_use(itemstack, user, pointed_thing) - if not user or user:is_player() == false then - return itemstack - end - - -- Call on_rightclick if the pointed node defines it - if pointed_thing.type == "node" then - local node = minetest.get_node(pointed_thing.under) - if user and not user: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, user, itemstack) or itemstack - end - end - end - - local name, player_inv, armor_inv = armor:get_valid_player(user, "[on_armor_use]") - if not name then - return itemstack - end - - local def = itemstack:get_definition() - local slot - if def.groups and def.groups.armor_head then - slot = 2 - elseif def.groups and def.groups.armor_torso then - slot = 3 - elseif def.groups and def.groups.armor_legs then - slot = 4 - elseif def.groups and def.groups.armor_feet then - slot = 5 - end - - if slot then - local itemstack_single = ItemStack(itemstack) - itemstack_single:set_count(1) - local itemstack_slot = armor_inv:get_stack("armor", slot) - if itemstack_slot:is_empty() then - armor_inv:set_stack("armor", slot, itemstack_single) - player_inv:set_stack("armor", slot, itemstack_single) - armor:set_player_armor(user) - armor:update_inventory(user) - armor:play_equip_sound(itemstack_single, user) - itemstack:take_item() - elseif itemstack:get_count() <= 1 and not mcl_enchanting.has_enchantment(itemstack_slot, "curse_of_binding") then - armor_inv:set_stack("armor", slot, itemstack_single) - player_inv:set_stack("armor", slot, itemstack_single) - armor:set_player_armor(user) - armor:update_inventory(user) - armor:play_equip_sound(itemstack_single, user) - itemstack = ItemStack(itemstack_slot) - end - end - - return itemstack -end - -armor.def = { - count = 0, -} - -armor.update_player_visuals = function(self, player) - if not player then - return - end - - local wielditem = player:get_wielded_item() - local def = wielditem:get_definition() - if def and def._mcl_toollike_wield then - player:set_bone_position("Wield_Item", vector.new(0,3.9,1.3), vector.new(90,0,0)) - elseif string.find(wielditem:get_name(), "mcl_bows:bow") then - player:set_bone_position("Wield_Item", vector.new(.5,4.5,-1.6), vector.new(90,0,20)) - else - player:set_bone_position("Wield_Item", vector.new(-1.5,4.9,1.8), vector.new(135,0,90)) - end - - local name = player:get_player_name() - if self.textures[name] then - mcl_player.player_set_textures(player, { - self.textures[name].skin, - self.textures[name].armor, - self.textures[name].wielditem, - }) - end -end - -armor.set_player_armor = function(self, player) - local name, player_inv = armor:get_valid_player(player, "[set_player_armor]") - if not name then - return - end - local armor_texture = "blank.png" - local armor_level = 0 - local mcl_armor_points = 0 - local items = 0 - local elements = {} - local textures = {} - local physics_o = {speed=1,gravity=1,jump=1} - local material = {type=nil, count=1} - local preview - for _,v in ipairs(self.elements) do - elements[v] = false - end - for i=1, 6 do - local stack = player_inv:get_stack("armor", i) - local item = stack:get_name() - if minetest.registered_aliases[item] then - item = minetest.registered_aliases[item] - end - if stack:get_count() == 1 then - local def = stack:get_definition() - for k, v in pairs(elements) do - if v == false then - local level = def.groups["armor_"..k] - if level then - local texture = def.texture or item:gsub("%:", "_") - local enchanted_addition = (mcl_enchanting.is_enchanted(item) and mcl_enchanting.overlay or "") - table.insert(textures, "("..texture..".png"..enchanted_addition..")") - preview = "(player.png^[opacity:0^"..texture.."_preview.png"..enchanted_addition..")"..(preview and "^"..preview or "") - armor_level = armor_level + level - items = items + 1 - mcl_armor_points = mcl_armor_points + (def.groups["mcl_armor_points"] or 0) - for kk,vv in ipairs(self.physics) do - local o_value = def.groups["physics_"..vv] - if o_value then - physics_o[vv] = physics_o[vv] + o_value - end - end - local mat = string.match(item, "%:.+_(.+)$") - if material.type then - if material.type == mat then - material.count = material.count + 1 - end - else - material.type = mat - end - elements[k] = true - end - end - end - end - end - preview = (armor:get_preview(name) or "character_preview.png")..(preview and "^"..preview or "") - if minetest.get_modpath("shields") then - armor_level = armor_level * 0.9 - end - if material.type and material.count == #self.elements then - armor_level = armor_level * 1.1 - end - if #textures > 0 then - armor_texture = table.concat(textures, "^") - end - local armor_groups = player:get_armor_groups() - armor_groups.fleshy = 100 - armor_groups.level = nil - if armor_level > 0 then - armor_groups.level = math.floor(armor_level / 20) - armor_groups.fleshy = 100 - armor_level - end - player:set_armor_groups(armor_groups) - -- Physics override intentionally removed because of possible conflicts - self.textures[name].armor = armor_texture - self.textures[name].preview = preview - self.def[name].count = items - self.def[name].level = armor_level - self.def[name].heal = mcl_armor_points - self.def[name].jump = physics_o.jump - self.def[name].speed = physics_o.speed - self.def[name].gravity = physics_o.gravity - self:update_player_visuals(player) -end - -armor.update_armor = function(self, player) - -- Legacy support: Called when armor levels are changed - -- Other mods can hook on to this function, see hud mod for example -end - -armor.get_armor_points = function(self, player) - local name, player_inv, armor_inv = armor:get_valid_player(player, "[get_armor_points]") - if not name then - return nil - end - local pts = 0 - for i=1, 6 do - local stack = player_inv:get_stack("armor", i) - if stack:get_count() > 0 then - local p = minetest.get_item_group(stack:get_name(), "mcl_armor_points") - if p then - pts = pts + p - end - end - end - return pts -end - --- Returns a change factor for a mob's view_range for the given player --- or nil, if there's no change. Certain armors (like mob heads) can --- affect the view range of mobs. -armor.get_mob_view_range_factor = function(self, player, mob) - local name, player_inv, armor_inv = armor:get_valid_player(player, "[get_mob_view_range_factor]") - if not name then - return - end - local factor - for i=1, 6 do - local stack = player_inv:get_stack("armor", i) - if stack:get_count() > 0 then - local def = stack:get_definition() - if def._mcl_armor_mob_range_mob == mob then - if not factor then - factor = def._mcl_armor_mob_range_factor - elseif factor == 0 then - return 0 - else - factor = factor * def._mcl_armor_mob_range_factor - end - end - end - end - return factor -end - -armor.get_player_skin = function(self, name) - local skin = nil - if skin_mod == "mcl_skins" then - skin = mcl_skins.skins[name] - elseif skin_mod == "skins" or skin_mod == "simple_skins" then - skin = skins.skins[name] - elseif skin_mod == "u_skins" then - skin = u_skins.u_skins[name] - elseif skin_mod == "wardrobe" then - skin = string.gsub(wardrobe.playerSkins[name], "%.png$","") - end - return skin or armor.default_skin -end - -armor.get_preview = function(self, name) - if skin_mod == "skins" then - return armor:get_player_skin(name).."_preview.png" - end -end - -armor.get_armor_formspec = function(self, name) - if not armor.textures[name] then - minetest.log("error", "mcl_armor: Player texture["..name.."] is nil [get_armor_formspec]") - return "" - end - if not armor.def[name] then - minetest.log("error", "mcl_armor: Armor def["..name.."] is nil [get_armor_formspec]") - return "" - end - local formspec = armor.formspec.."list[detached:"..name.."_armor;armor;0,1;2,3;]" - formspec = formspec:gsub("armor_preview", armor.textures[name].preview) - formspec = formspec:gsub("armor_level", armor.def[name].level) - formspec = formspec:gsub("mcl_armor_points", armor.def[name].heal) - return formspec -end - -armor.update_inventory = function(self, player) -end - -armor.get_valid_player = function(self, player, msg) - msg = msg or "" - if not player then - minetest.log("error", "mcl_armor: Player reference is nil "..msg) - return - end - local name = player:get_player_name() - if not name then - minetest.log("error", "mcl_armor: Player name is nil "..msg) - return - end - local pos = player:get_pos() - local player_inv = player:get_inventory() - local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"}) - if not pos then - minetest.log("error", "mcl_armor: Player position is nil "..msg) - return - elseif not player_inv then - minetest.log("error", "mcl_armor: Player inventory is nil "..msg) - return - elseif not armor_inv then - minetest.log("error", "mcl_armor: Detached armor inventory is nil "..msg) - return - end - return name, player_inv, armor_inv, pos -end - -armor.play_equip_sound = function(self, stack, player, pos, unequip) - local def = stack:get_definition() - local estr = "equip" - if unequip then - estr = "unequip" - end - local snd = def.sounds and def.sounds["_mcl_armor_"..estr] - if not snd then - -- Fallback sound - snd = { name = "mcl_armor_"..estr.."_generic" } - end - if snd then - local dist = 8 - if pos then - dist = 16 - end - minetest.sound_play(snd, {object=player, pos=pos, gain=0.5, max_hear_distance=dist}, true) - end -end - --- Register Player Model - -mcl_player.player_register_model("mcl_armor_character.b3d", { - animation_speed = 30, - textures = { - armor.default_skin..".png", - "blank.png", - "blank.png", - }, - animations = { - stand = {x=0, y=79}, - lay = {x=162, y=166}, - walk = {x=168, y=187}, - mine = {x=189, y=198}, - walk_mine = {x=200, y=219}, - sit = {x=81, y=160}, - sneak_stand = {x=222, y=302}, - sneak_mine = {x=346, y=365}, - sneak_walk = {x=304, y=323}, - sneak_walk_mine = {x=325, y=344}, - swim_walk = {x=368, y=387}, - swim_walk_mine = {x=389, y=408}, - swim_stand = {x=434, y=434}, - swim_mine = {x=411, y=430}, - run_walk = {x=440, y=459}, - run_walk_mine = {x=461, y=480}, - sit_mount = {x=484, y=484}, - die = {x=498, y=498}, - }, -}) - -mcl_player.player_register_model("mcl_armor_character_female.b3d", { - animation_speed = 30, - textures = { - armor.default_skin..".png", - "blank.png", - "blank.png", - }, - animations = { - stand = {x=0, y=79}, - lay = {x=162, y=166}, - walk = {x=168, y=187}, - mine = {x=189, y=198}, - walk_mine = {x=200, y=219}, - sit = {x=81, y=160}, - sneak_stand = {x=222, y=302}, - sneak_mine = {x=346, y=365}, - sneak_walk = {x=304, y=323}, - sneak_walk_mine = {x=325, y=344}, - swim_walk = {x=368, y=387}, - swim_walk_mine = {x=389, y=408}, - swim_stand = {x=434, y=434}, - swim_mine = {x=411, y=430}, - run_walk = {x=440, y=459}, - run_walk_mine = {x=461, y=480}, - sit_mount = {x=484, y=484}, - }, -}) - --- Register Callbacks - -minetest.register_on_player_receive_fields(function(player, formname, fields) - local name = armor:get_valid_player(player, "[on_player_receive_fields]") - if not name then - return - end - if fields.armor then - return - end - for field, _ in pairs(fields) do - if string.find(field, "skins_set") then - minetest.after(0, function(name) - local player = minetest.get_player_by_name(name) - if not player then - return - end - local skin = armor:get_player_skin(name) - armor.textures[name].skin = skin..".png" - armor:set_player_armor(player) - end, player:get_player_name()) - end - end -end) - -minetest.register_on_joinplayer(function(player) - mcl_player.player_set_model(player, "mcl_armor_character.b3d") - local name = player:get_player_name() - local player_inv = player:get_inventory() - local armor_inv = minetest.create_detached_inventory(name.."_armor", { - on_put = function(inv, listname, index, stack, player) - player:get_inventory():set_stack(listname, index, stack) - armor:set_player_armor(player) - armor:update_inventory(player) - armor:play_equip_sound(stack, player) - end, - on_take = function(inv, listname, index, stack, player) - player:get_inventory():set_stack(listname, index, nil) - armor:set_player_armor(player) - armor:update_inventory(player) - armor:play_equip_sound(stack, player, nil, true) - end, - on_move = function(inv, from_list, from_index, to_list, to_index, count, player) - local plaver_inv = player:get_inventory() - local stack = inv:get_stack(to_list, to_index) - player_inv:set_stack(to_list, to_index, stack) - player_inv:set_stack(from_list, from_index, nil) - armor:set_player_armor(player) - armor:update_inventory(player) - armor:play_equip_sound(stack, player) - end, - allow_put = function(inv, listname, index, stack, player) - local iname = stack:get_name() - local g - local groupcheck - if index == 2 then - g = minetest.get_item_group(iname, "armor_head") - elseif index == 3 then - g = minetest.get_item_group(iname, "armor_torso") - elseif index == 4 then - g = minetest.get_item_group(iname, "armor_legs") - elseif index == 5 then - g = minetest.get_item_group(iname, "armor_feet") - end - -- Minor FIXME: If player attempts to place stack into occupied slot, this is rejected. - -- It would be better if 1 item is placed in exchanged for the item in the slot. - if g ~= 0 and g ~= nil and (inv:get_stack(listname, index):is_empty() or (inv:get_stack(listname, index):get_name() ~= stack:get_name()) and stack:get_count() <= 1) then - return 1 - else - return 0 - end - end, - allow_take = function(inv, listname, index, stack, player) - if mcl_enchanting.has_enchantment(stack, "curse_of_binding") and not minetest.settings:get_bool("creative") then - return 0 - end - return stack:get_count() - end, - allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) - return 0 - end, - }, name) - armor_inv:set_size("armor", 6) - player_inv:set_size("armor", 6) - for i=1, 6 do - local stack = player_inv:get_stack("armor", i) - armor_inv:set_stack("armor", i, stack) - end - armor.def[name] = { - count = 0, - level = 0, - heal = 0, - jump = 1, - speed = 1, - gravity = 1, - } - armor.textures[name] = { - skin = armor.default_skin..".png", - armor = "blank.png", - wielditem = "blank.png", - preview = armor.default_skin.."_preview.png", - } - if skin_mod == "mcl_skins" then - local skin = mcl_skins.skins[name] - if skin then - armor.textures[name].skin = skin..".png" - end - elseif skin_mod == "skins" then - local skin = skins.skins[name] - if skin and skins.get_type(skin) == skins.type.MODEL then - armor.textures[name].skin = skin..".png" - end - elseif skin_mod == "simple_skins" then - local skin = skins.skins[name] - if skin then - armor.textures[name].skin = skin..".png" - end - elseif skin_mod == "u_skins" then - local skin = u_skins.u_skins[name] - if skin and u_skins.get_type(skin) == u_skins.type.MODEL then - armor.textures[name].skin = skin..".png" - end - elseif skin_mod == "wardrobe" then - local skin = wardrobe.playerSkins[name] - if skin then - armor.textures[name].skin = skin - end - end - if minetest.get_modpath("player_textures") then - local filename = minetest.get_modpath("player_textures").."/textures/player_"..name - local f = io.open(filename..".png") - if f then - f:close() - armor.textures[name].skin = "player_"..name..".png" - end - end - for i=1, ARMOR_INIT_TIMES do - minetest.after(ARMOR_INIT_DELAY * i, function(name) - local player = minetest.get_player_by_name(name) - if not player then - return - end - armor:set_player_armor(player) - end, player:get_player_name()) - end -end) - -minetest.register_on_player_hpchange(function(player, hp_change, reason) - local name, player_inv, armor_inv = armor:get_valid_player(player, "[on_hpchange]") - if name and hp_change < 0 then - local damage_type = armor.last_damage_types[name] - armor.last_damage_types[name] = nil - - -- Armor doesn't protect from set_hp (commands like /kill), - if reason.type == "set_hp" then - return hp_change - end - - local regular_reduction = reason.type ~= "drown" and reason.type ~= "fall" and reason.other ~= "harming" and reason.other ~= "poison" - - local heal_max = 0 - local items = 0 - local armor_damage = math.max(1, math.floor(math.abs(hp_change)/4)) - - local total_points = 0 - local total_toughness = 0 - local epf = 0 - local thorns_damage = 0 - local thorns_damage_regular = 0 - for i=1, 6 do - local stack = player_inv:get_stack("armor", i) - if stack:get_count() > 0 then - local enchantments = mcl_enchanting.get_enchantments(stack) - local pts = stack:get_definition().groups["mcl_armor_points"] or 0 - local tough = stack:get_definition().groups["mcl_armor_toughness"] or 0 - total_points = total_points + pts - total_toughness = total_toughness + tough - - local protection_level = enchantments.protection or 0 - if protection_level > 0 then - epf = epf + protection_level * 1 - end - local blast_protection_level = enchantments.blast_protection or 0 - if blast_protection_level > 0 and damage_type == "explosion" then - epf = epf + blast_protection_level * 2 - end - local fire_protection_level = enchantments.fire_protection or 0 - if fire_protection_level > 0 and (damage_type == "burning" or damage_type == "fireball" or reason.type == "node_damage" and - (reason.node == "mcl_fire:fire" or reason.node == "mcl_core:lava_source" or reason.node == "mcl_core:lava_flowing")) then - epf = epf + fire_protection_level * 2 - end - local projectile_protection_level = enchantments.projectile_protection or 0 - if projectile_protection_level and (damage_type == "projectile" or damage_type == "fireball") then - epf = epf + projectile_protection_level * 2 - end - local feather_falling_level = enchantments.feather_falling or 0 - if feather_falling_level and reason.type == "fall" then - epf = epf + feather_falling_level * 3 - end - - local did_thorns_damage = false - local thorns_level = enchantments.thorns or 0 - if thorns_level then - if thorns_level > 10 then - thorns_damage = thorns_damage + thorns_level - 10 - did_thorns_damage = true - elseif thorns_damage_regular < 4 and thorns_level * 0.15 > math.random() then - local thorns_damage_regular_new = math.min(4, thorns_damage_regular + math.random(4)) - thorns_damage = thorns_damage + thorns_damage_regular_new - thorns_damage_regular - thorns_damage_regular = thorns_damage_regular_new - did_thorns_damage = true - end - end - - -- Damage armor - local use = stack:get_definition().groups["mcl_armor_uses"] or 0 - if use > 0 and regular_reduction then - local unbreaking_level = enchantments.unbreaking or 0 - if unbreaking_level > 0 then - use = use / (0.6 + 0.4 / (unbreaking_level + 1)) - end - local wear = armor_damage * math.floor(65536/use) - if did_thorns_damage then - wear = wear * 3 - end - stack:add_wear(wear) - end - - local item = stack:get_name() - armor_inv:set_stack("armor", i, stack) - player_inv:set_stack("armor", i, stack) - items = items + 1 - if stack:get_count() == 0 then - armor:set_player_armor(player) - armor:update_inventory(player) - end - end - end - local damage = math.abs(hp_change) - - if regular_reduction then - -- Damage calculation formula (from ) - damage = damage * (1 - math.min(20, math.max((total_points/5), total_points - damage / (2+(total_toughness/4)))) / 25) - end - damage = damage * (1 - (math.min(20, epf) / 25)) - damage = math.floor(damage+0.5) - - if reason.type == "punch" and thorns_damage > 0 then - local obj = reason.object - if obj then - local luaentity = obj:get_luaentity() - if luaentity then - local shooter = obj._shooter - if shooter then - obj = shooter - end - end - obj:punch(player, 1.0, { - full_punch_interval=1.0, - damage_groups = {fleshy = thorns_damage}, - }) - end - end - - hp_change = -math.abs(damage) - - armor.def[name].count = items - armor:update_armor(player) - end - return hp_change -end, true) diff --git a/mods/ITEMS/mcl_armor/damage.lua b/mods/ITEMS/mcl_armor/damage.lua new file mode 100644 index 00000000..ed616397 --- /dev/null +++ b/mods/ITEMS/mcl_armor/damage.lua @@ -0,0 +1,102 @@ +local function use_durability(obj, inv, index, stack, uses) + local def = stack:get_definition() + mcl_util.use_item_durability(stack, uses) + if stack:is_empty() and def and def._on_break then + stack = def._on_break(obj) or stack + end + inv:set_stack("armor", index, stack) +end + +mcl_damage.register_modifier(function(obj, damage, reason) + local flags = reason.flags + + if flags.bypasses_armor and flags.bypasses_magic then + return damage + end + + local uses = math.max(1, math.floor(damage / 4)) + + local points = 0 + local toughness = 0 + local enchantment_protection_factor = 0 + + local thorns_damage_regular = 0 + local thorns_damage_irregular = 0 + local thorns_pieces = {} + + local inv = mcl_util.get_inventory(obj) + + if inv then + for name, element in pairs(mcl_armor.elements) do + local itemstack = inv:get_stack("armor", element.index) + if not itemstack:is_empty() then + local itemname = itemstack:get_name() + local enchantments = mcl_enchanting.get_enchantments(itemstack) + + if not flags.bypasses_armor then + points = points + minetest.get_item_group(itemname, "mcl_armor_points") + toughness = toughness + minetest.get_item_group(itemname, "mcl_armor_toughness") + + use_durability(obj, inv, element.index, itemstack, uses) + end + + if not flags.bypasses_magic then + local function add_enchantments(tbl) + if tbl then + for _, enchantment in pairs(tbl) do + local level = enchantments[enchantment.id] + + if level and level > 0 then + enchantment_protection_factor = enchantment_protection_factor + level * enchantment.factor + end + end + end + end + + add_enchantments(mcl_armor.protection_enchantments.wildcard) + add_enchantments(mcl_armor.protection_enchantments.types[reason.type]) + + for flag, value in pairs(flags) do + if value then + add_enchantments(mcl_armor.protection_enchantments.flags[flag]) + end + end + end + + if reason.source and enchantments.thorns and enchantments.thorns > 0 then + local do_irregular_damage = enchantments.thorns > 10 + + if do_irregular_damage or thorns_damage_regular < 4 and math.random() < enchantments.thorns * 0.15 then + if do_irregular_damage then + thorns_damage_irregular = thorns_damage_irregular + enchantments.thorns - 10 + else + thorns_damage_regular = math.min(4, thorns_damage_regular + math.random(4)) + end + end + + table.insert(thorns_pieces, {index = element.index, itemstack = itemstack}) + end + end + end + end + + -- https://minecraft.gamepedia.com/Armor#Damage_protection + damage = damage * (1 - math.min(20, math.max((points / 5), points - damage / (2 + (toughness / 4)))) / 25) + + -- https://minecraft.gamepedia.com/Armor#Enchantments + damage = damage * (1 - math.min(20, enchantment_protection_factor) / 25) + + local thorns_damage = thorns_damage_regular + thorns_damage_irregular + + if thorns_damage > 0 and reason.type ~= "thorns" and reason.source ~= obj then + mcl_util.deal_damage(reason.source, thorns_damage, {type = "thorns", direct = obj}) + + local thorns_item = thorns_pieces[math.random(#thorns_pieces)] + + use_durability(obj, inv, thorns_item.index, thorns_item.itemstack, 2) + end + + mcl_armor.update(obj) + + return math.floor(damage + 0.5) +end, 0) diff --git a/mods/ITEMS/mcl_armor/init.lua b/mods/ITEMS/mcl_armor/init.lua index c5502cf4..799bf2e9 100644 --- a/mods/ITEMS/mcl_armor/init.lua +++ b/mods/ITEMS/mcl_armor/init.lua @@ -1,392 +1,68 @@ -local S = minetest.get_translator("mcl_armor") +local S = minetest.get_translator(minetest.get_current_modname()) -dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua") -dofile(minetest.get_modpath(minetest.get_current_modname()).."/alias.lua") - --- Regisiter Head Armor - -local longdesc = S("This is a piece of equippable armor which reduces the amount of damage you receive.") -local usage = S("To equip it, put it on the corresponding armor slot in your inventory menu.") - -minetest.register_tool("mcl_armor:helmet_leather", { - description = S("Leather Cap"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_helmet_leather.png", - groups = {armor_head=1, mcl_armor_points=1, mcl_armor_uses=56, enchantability=15}, - _repair_material = "mcl_mobitems:leather", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_leather", - _mcl_armor_unequip = "mcl_armor_unequip_leather", +mcl_armor = { + longdesc = S("This is a piece of equippable armor which reduces the amount of damage you receive."), + usage = S("To equip it, put it on the corresponding armor slot in your inventory menu."), + elements = { + head = { + name = "helmet", + description = "Helmet", + durability = 0.6857, + index = 2, + craft = function(m) + return { + { m, m, m}, + { m, "", m}, + {"", "", ""}, + } + end, + }, + torso = { + name = "chestplate", + description = "Chestplate", + durability = 1.0, + index = 3, + craft = function(m) + return { + { m, "", m}, + { m, m, m}, + { m, m, m}, + } + end, + }, + legs = { + name = "leggings", + description = "Leggings", + durability = 0.9375, + index = 4, + craft = function(m) + return { + { m, m, m}, + { m, "", m}, + { m, "", m}, + } + end, + }, + feet = { + name = "boots", + description = "Boots", + durability = 0.8125, + index = 5, + craft = function(m) + return { + { m, "", m}, + { m, "", m}, + } + end, + } }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) + player_view_range_factors = {}, +} -minetest.register_tool("mcl_armor:helmet_iron", { - description = S("Iron Helmet"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_helmet_iron.png", - groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166, enchantability=9 }, - _repair_material = "mcl_core:iron_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_iron", - _mcl_armor_unequip = "mcl_armor_unequip_iron", - }, - - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:helmet_gold", { - description = S("Golden Helmet"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_helmet_gold.png", - groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=78, enchantability=25 }, - _repair_material = "mcl_core:gold_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_iron", - _mcl_armor_unequip = "mcl_armor_unequip_iron", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:helmet_diamond",{ - description = S("Diamond Helmet"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_helmet_diamond.png", - groups = {armor_head=1, mcl_armor_points=3, mcl_armor_uses=364, mcl_armor_toughness=2, enchantability=10 }, - _repair_material = "mcl_core:diamond", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_diamond", - _mcl_armor_unequip = "mcl_armor_unequip_diamond", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:helmet_chain", { - description = S("Chain Helmet"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_helmet_chain.png", - groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166, enchantability=12 }, - _repair_material = "mcl_core:iron_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_chainmail", - _mcl_armor_unequip = "mcl_armor_unequip_chainmail", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - --- Regisiter Torso Armor - -minetest.register_tool("mcl_armor:chestplate_leather", { - description = S("Leather Tunic"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_chestplate_leather.png", - groups = {armor_torso=1, mcl_armor_points=3, mcl_armor_uses=81, enchantability=15 }, - _repair_material = "mcl_mobitems:leather", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_leather", - _mcl_armor_unequip = "mcl_armor_unequip_leather", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:chestplate_iron", { - description = S("Iron Chestplate"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_chestplate_iron.png", - groups = {armor_torso=1, mcl_armor_points=6, mcl_armor_uses=241, enchantability=9 }, - _repair_material = "mcl_core:iron_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_iron", - _mcl_armor_unequip = "mcl_armor_unequip_iron", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:chestplate_gold", { - description = S("Golden Chestplate"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_chestplate_gold.png", - groups = {armor_torso=1, mcl_armor_points=5, mcl_armor_uses=113, enchantability=25 }, - _repair_material = "mcl_core:gold_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_iron", - _mcl_armor_unequip = "mcl_armor_unequip_iron", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:chestplate_diamond",{ - description = S("Diamond Chestplate"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_chestplate_diamond.png", - groups = {armor_torso=1, mcl_armor_points=8, mcl_armor_uses=529, mcl_armor_toughness=2, enchantability=10 }, - _repair_material = "mcl_core:diamond", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_diamond", - _mcl_armor_unequip = "mcl_armor_unequip_diamond", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:chestplate_chain", { - description = S("Chain Chestplate"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_chestplate_chain.png", - groups = {armor_torso=1, mcl_armor_points=5, mcl_armor_uses=241, enchantability=12 }, - _repair_material = "mcl_core:iron_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_chainmail", - _mcl_armor_unequip = "mcl_armor_unequip_chainmail", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - --- Regisiter Leg Armor - -minetest.register_tool("mcl_armor:leggings_leather", { - description = S("Leather Pants"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_leggings_leather.png", - groups = {armor_legs=1, mcl_armor_points=2, mcl_armor_uses=76, enchantability=15 }, - _repair_material = "mcl_mobitems:leather", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_leather", - _mcl_armor_unequip = "mcl_armor_unequip_leather", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:leggings_iron", { - description = S("Iron Leggings"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_leggings_iron.png", - groups = {armor_legs=1, mcl_armor_points=5, mcl_armor_uses=226, enchantability=9 }, - _repair_material = "mcl_core:iron_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_iron", - _mcl_armor_unequip = "mcl_armor_unequip_iron", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:leggings_gold", { - description = S("Golden Leggings"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_leggings_gold.png", - groups = {armor_legs=1, mcl_armor_points=3, mcl_armor_uses=106, enchantability=25 }, - _repair_material = "mcl_core:gold_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_iron", - _mcl_armor_unequip = "mcl_armor_unequip_iron", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:leggings_diamond",{ - description = S("Diamond Leggings"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_leggings_diamond.png", - groups = {armor_legs=1, mcl_armor_points=6, mcl_armor_uses=496, mcl_armor_toughness=2, enchantability=10 }, - _repair_material = "mcl_core:diamond", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_diamond", - _mcl_armor_unequip = "mcl_armor_unequip_diamond", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:leggings_chain", { - description = S("Chain Leggings"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_leggings_chain.png", - groups = {armor_legs=1, mcl_armor_points=4, mcl_armor_uses=226, enchantability=12 }, - _repair_material = "mcl_core:iron_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_chainmail", - _mcl_armor_unequip = "mcl_armor_unequip_chainmail", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) --- Regisiter Boots - -minetest.register_tool("mcl_armor:boots_leather", { - description = S("Leather Boots"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_boots_leather.png", - groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=66, enchantability=15 }, - _repair_material = "mcl_mobitems:leather", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_leather", - _mcl_armor_unequip = "mcl_armor_unequip_leather", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:boots_iron", { - description = S("Iron Boots"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_boots_iron.png", - groups = {armor_feet=1, mcl_armor_points=2, mcl_armor_uses=196, enchantability=9 }, - _repair_material = "mcl_core:iron_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_iron", - _mcl_armor_unequip = "mcl_armor_unequip_iron", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:boots_gold", { - description = S("Golden Boots"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_boots_gold.png", - groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=92, enchantability=25 }, - _repair_material = "mcl_core:gold_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_iron", - _mcl_armor_unequip = "mcl_armor_unequip_iron", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:boots_diamond",{ - description = S("Diamond Boots"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_boots_diamond.png", - groups = {armor_feet=1, mcl_armor_points=3, mcl_armor_uses=430, mcl_armor_toughness=2, enchantability=10 }, - _repair_material = "mcl_core:diamond", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_diamond", - _mcl_armor_unequip = "mcl_armor_unequip_diamond", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("mcl_armor:boots_chain", { - description = S("Chain Boots"), - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usage, - inventory_image = "mcl_armor_inv_boots_chain.png", - groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=196, enchantability=12 }, - _repair_material = "mcl_core:iron_ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_chainmail", - _mcl_armor_unequip = "mcl_armor_unequip_chainmail", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - --- Register Craft Recipies - -local craft_ingreds = { - leather = { "mcl_mobitems:leather" }, - iron = { "mcl_core:iron_ingot", "mcl_core:iron_nugget" }, - gold = { "mcl_core:gold_ingot", "mcl_core:gold_nugget" }, - diamond = { "mcl_core:diamond" }, - chain = { nil, "mcl_core:iron_nugget"} , -} - -for k, v in pairs(craft_ingreds) do - -- material - local m = v[1] - -- cooking result - local c = v[2] - if m ~= nil then - minetest.register_craft({ - output = "mcl_armor:helmet_"..k, - recipe = { - {m, m, m}, - {m, "", m}, - {"", "", ""}, - }, - }) - minetest.register_craft({ - output = "mcl_armor:chestplate_"..k, - recipe = { - {m, "", m}, - {m, m, m}, - {m, m, m}, - }, - }) - minetest.register_craft({ - output = "mcl_armor:leggings_"..k, - recipe = { - {m, m, m}, - {m, "", m}, - {m, "", m}, - }, - }) - minetest.register_craft({ - output = "mcl_armor:boots_"..k, - recipe = { - {m, "", m}, - {m, "", m}, - }, - }) - end - if c ~= nil then - minetest.register_craft({ - type = "cooking", - output = c, - recipe = "mcl_armor:helmet_"..k, - cooktime = 10, - }) - minetest.register_craft({ - type = "cooking", - output = c, - recipe = "mcl_armor:chestplate_"..k, - cooktime = 10, - }) - minetest.register_craft({ - type = "cooking", - output = c, - recipe = "mcl_armor:leggings_"..k, - cooktime = 10, - }) - minetest.register_craft({ - type = "cooking", - output = c, - recipe = "mcl_armor:boots_"..k, - cooktime = 10, - }) - end -end +local modpath = minetest.get_modpath("mcl_armor") +dofile(modpath .. "/api.lua") +dofile(modpath .. "/player.lua") +dofile(modpath .. "/damage.lua") +dofile(modpath .. "/register.lua") +dofile(modpath .. "/alias.lua") diff --git a/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d b/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d index a658f753..95f763ea 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 12869b59..a5626aac 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 44494d1e..1b420534 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 c854a49e..828cd942 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/models/mcl_armor_character_female.blend1 b/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.blend1 new file mode 100644 index 00000000..1a13f1c9 Binary files /dev/null and b/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.blend1 differ diff --git a/mods/ITEMS/mcl_armor/player.lua b/mods/ITEMS/mcl_armor/player.lua new file mode 100644 index 00000000..9dba0773 --- /dev/null +++ b/mods/ITEMS/mcl_armor/player.lua @@ -0,0 +1,169 @@ +mcl_player.player_register_model("mcl_armor_character.b3d", { + animation_speed = 30, + textures = { + "character.png", + "blank.png", + "blank.png", + }, + animations = { + stand = {x=0, y=79}, + lay = {x=162, y=166}, + walk = {x=168, y=187}, + mine = {x=189, y=198}, + walk_mine = {x=200, y=219}, + sit = {x=81, y=160}, + sneak_stand = {x=222, y=302}, + sneak_mine = {x=346, y=365}, + sneak_walk = {x=304, y=323}, + sneak_walk_mine = {x=325, y=344}, + swim_walk = {x=368, y=387}, + swim_walk_mine = {x=389, y=408}, + swim_stand = {x=434, y=434}, + swim_mine = {x=411, y=430}, + run_walk = {x=440, y=459}, + run_walk_mine = {x=461, y=480}, + sit_mount = {x=484, y=484}, + die = {x=498, y=498}, + fly = {x=502, y=581}, + }, +}) + +mcl_player.player_register_model("mcl_armor_character_female.b3d", { + animation_speed = 30, + textures = { + "character.png", + "blank.png", + "blank.png", + }, + animations = { + stand = {x=0, y=79}, + lay = {x=162, y=166}, + walk = {x=168, y=187}, + mine = {x=189, y=198}, + walk_mine = {x=200, y=219}, + sit = {x=81, y=160}, + sneak_stand = {x=222, y=302}, + sneak_mine = {x=346, y=365}, + sneak_walk = {x=304, y=323}, + sneak_walk_mine = {x=325, y=344}, + swim_walk = {x=368, y=387}, + swim_walk_mine = {x=389, y=408}, + swim_stand = {x=434, y=434}, + swim_mine = {x=411, y=430}, + run_walk = {x=440, y=459}, + run_walk_mine = {x=461, y=480}, + sit_mount = {x=484, y=484}, + die = {x=498, y=498}, + fly = {x=502, y=581}, + }, +}) + +function mcl_armor.update_player(player, info) + mcl_player.player_set_armor(player, info.texture, info.preview) + + local meta = player:get_meta() + meta:set_int("mcl_armor:armor_points", info.points) + + mcl_armor.player_view_range_factors[player] = info.view_range_factors +end + +local function is_armor_action(inventory_info) + return inventory_info.from_list == "armor" or inventory_info.to_list == "armor" or inventory_info.listname == "armor" +end + +local function limit_put(player, inventory, index, stack, count) + local def = stack:get_definition() + + if not def then + return 0 + end + + local element = def._mcl_armor_element + + if not element then + return 0 + end + + local element_index = mcl_armor.elements[element].index + + if index ~= 1 and index ~= element_index then + return 0 + end + + local old_stack = inventory:get_stack("armor", element_index) + + if old_stack:is_empty() or index ~= 1 and old_stack:get_name() ~= stack:get_name() and count <= 1 then + return count + else + return 0 + end +end + +local function limit_take(player, inventory, index, stack, count) + if mcl_enchanting.has_enchantment(stack, "curse_of_binding") and not minetest.is_creative_enabled(player:get_player_name()) then + return 0 + end + + return count +end + +minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info) + if not is_armor_action(inventory_info) then + return + end + + if action == "put" then + return limit_put(player, inventory, inventory_info.index, inventory_info.stack, inventory_info.stack:get_count()) + elseif action == "take" then + return limit_take(player, inventory, inventory_info.index, inventory_info.stack, inventory_info.stack:get_count()) + else + if inventory_info.from_list ~= "armor" then + return limit_put(player, inventory, inventory_info.to_index, inventory:get_stack(inventory_info.from_list, inventory_info.from_index), inventory_info.count) + elseif inventory_info.to_list ~= "armor" then + return limit_take(player, inventory, inventory_info.from_index, inventory:get_stack(inventory_info.from_list, inventory_info.from_index), inventory_info.count) + else + return 0 + end + end +end) + +local function on_put(player, inventory, index, stack) + if index == 1 then + mcl_armor.equip(stack, player) + inventory:set_stack("armor", 1, nil) + else + mcl_armor.on_equip(stack, player) + end +end + +minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info) + if is_armor_action(inventory_info) then + if action == "put" then + on_put(player, inventory, inventory_info.index, inventory_info.stack) + elseif action == "take" then + mcl_armor.on_unequip(inventory_info.stack, player) + else + local stack = inventory:get_stack(inventory_info.to_list, inventory_info.to_index) + if inventory_info.to_list == "armor" then + on_put(player, inventory, inventory_info.to_index, stack) + elseif inventory_info.from_list == "armor" then + mcl_armor.on_unequip(stack, player) + end + end + end +end) + +minetest.register_on_joinplayer(function(player) + mcl_player.player_set_model(player, "mcl_armor_character.b3d") + player:get_inventory():set_size("armor", 5) + + minetest.after(1, function() + if player:is_player() then + mcl_armor.update(player) + end + end) +end) + +minetest.register_on_leaveplayer(function(player) + mcl_armor.player_view_range_factors[player] = nil +end) diff --git a/mods/ITEMS/mcl_armor/register.lua b/mods/ITEMS/mcl_armor/register.lua new file mode 100644 index 00000000..1f9ce7b0 --- /dev/null +++ b/mods/ITEMS/mcl_armor/register.lua @@ -0,0 +1,205 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +mcl_armor.register_set({ + name = "leather", + description = "Leather", + descriptions = { + head = "Cap", + torso = "Tunic", + legs = "Pants", + }, + durability = 80, + enchantability = 15, + points = { + head = 1, + torso = 3, + legs = 2, + feet = 1, + }, + craft_material = "mcl_mobitems:leather", +}) + +mcl_armor.register_set({ + name = "gold", + description = "Golden", + durability = 112, + enchantability = 25, + points = { + head = 2, + torso = 5, + legs = 3, + feet = 1, + }, + craft_material = "mcl_core:gold_ingot", + cook_material = "mcl_core:gold_nugget", + sound_equip = "mcl_armor_equip_iron", + sound_unequip = "mcl_armor_unequip_iron", +}) + +mcl_armor.register_set({ + name = "chain", + description = "Chain", + durability = 240, + enchantability = 12, + points = { + head = 2, + torso = 5, + legs = 4, + feet = 1, + }, + repair_material = "mcl_core:iron_ingot", + cook_material = "mcl_core:iron_nugget", +}) + +mcl_armor.register_set({ + name = "iron", + description = "Iron", + durability = 240, + enchantability = 9, + points = { + head = 2, + torso = 6, + legs = 5, + feet = 2, + }, + craft_material = "mcl_core:iron_ingot", + cook_material = "mcl_core:iron_nugget", +}) + +mcl_armor.register_set({ + name = "diamond", + description = "Diamond", + durability = 528, + enchantability = 10, + points = { + head = 3, + torso = 8, + legs = 6, + feet = 3, + }, + toughness = 2, + craft_material = "mcl_core:diamond", +}) + +mcl_armor.register_protection_enchantment({ + id = "projectile_protection", + name = S("Projectile Protection"), + description = S("Reduces projectile damage."), + power_range_table = {{1, 16}, {11, 26}, {21, 36}, {31, 46}, {41, 56}}, + incompatible = {blast_protection = true, fire_protection = true, protection = true}, + factor = 2, + damage_flag = "is_projectile", +}) + +mcl_armor.register_protection_enchantment({ + id = "blast_protection", + name = S("Blast Protection"), + description = S("Reduces explosion damage and knockback."), + power_range_table = {{5, 13}, {13, 21}, {21, 29}, {29, 37}}, + weight = 2, + incompatible = {fire_protection = true, protection = true, projectile_protection = true}, + factor = 2, + damage_flag = "is_explosion", +}) + +mcl_armor.register_protection_enchantment({ + id = "fire_protection", + name = S("Fire Protection"), + description = S("Reduces fire damage."), + power_range_table = {{5, 13}, {13, 21}, {21, 29}, {29, 37}}, + incompatible = {blast_protection = true, protection = true, projectile_protection = true}, + factor = 2, + damage_flag = "is_fire", +}) + +mcl_armor.register_protection_enchantment({ + id = "protection", + name = S("Protection"), + description = S("Reduces most types of damage by 4% for each level."), + power_range_table = {{1, 12}, {12, 23}, {23, 34}, {34, 45}}, + incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true}, + factor = 1, +}) + +mcl_armor.register_protection_enchantment({ + id = "feather_falling", + name = S("Feather Falling"), + description = S("Reduces fall damage."), + power_range_table = {{5, 11}, {11, 17}, {17, 23}, {23, 29}}, + factor = 3, + primary = {combat_armor_feet = true}, + damage_type = "fall", +}) + +-- requires engine change +--[[mcl_enchanting.enchantments.aqua_affinity = { + name = S("Aqua Affinity"), + max_level = 1, + primary = {armor_head = true}, + secondary = {}, + disallow = {non_combat_armor = true}, + incompatible = {}, + weight = 2, + description = S("Increases underwater mining speed."), + curse = false, + on_enchant = function() end, + requires_tool = false, + treasure = false, + power_range_table = {{1, 41}}, + inv_combat_tab = true, + inv_tool_tab = false, +}]]-- + +mcl_enchanting.enchantments.curse_of_binding = { + name = S("Curse of Binding"), + max_level = 1, + primary = {}, + secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, + disallow = {}, + incompatible = {}, + weight = 1, + description = S("Item cannot be removed from armor slots except due to death, breaking or in Creative Mode."), + curse = true, + on_enchant = function() end, + requires_tool = false, + treasure = true, + power_range_table = {{25, 50}}, + inv_combat_tab = true, + inv_tool_tab = false, +} + +mcl_enchanting.enchantments.thorns = { + name = S("Thorns"), + max_level = 3, + primary = {combat_armor_chestplate = true}, + secondary = {combat_armor = true}, + disallow = {}, + incompatible = {}, + weight = 1, + description = S("Reflects some of the damage taken when hit, at the cost of reducing durability with each proc."), + curse = false, + on_enchant = function() end, + requires_tool = false, + treasure = false, + power_range_table = {{10, 61}, {30, 71}, {50, 81}}, + inv_combat_tab = true, + inv_tool_tab = false, +} + +-- Elytra + +minetest.register_tool("mcl_armor:elytra", { + description = S("Elytra"), + _doc_items_longdesc = mcl_armor.longdesc, + _doc_items_usagehelp = mcl_armor.usage, + inventory_image = "mcl_armor_inv_elytra.png", + groups = {armor = 1, non_combat_armor = 1, armor_torso = 1, non_combat_torso = 1, mcl_armor_uses = 10}, + sounds = { + _mcl_armor_equip = "mcl_armor_equip_leather", + _mcl_armor_unequip = "mcl_armor_unequip_leather", + }, + on_place = mcl_armor.equip_on_use, + on_secondary_use = mcl_armor.equip_on_use, + _mcl_armor_element = "torso", + _mcl_armor_texture = "mcl_armor_elytra.png" +}) diff --git a/mods/ITEMS/mcl_armor/textures/mcl_armor_elytra.png b/mods/ITEMS/mcl_armor/textures/mcl_armor_elytra.png new file mode 100644 index 00000000..b51f2a56 Binary files /dev/null and b/mods/ITEMS/mcl_armor/textures/mcl_armor_elytra.png differ diff --git a/mods/ITEMS/mcl_armor/textures/mcl_armor_inv_elytra.png b/mods/ITEMS/mcl_armor/textures/mcl_armor_inv_elytra.png new file mode 100644 index 00000000..f5d5cfda Binary files /dev/null and b/mods/ITEMS/mcl_armor/textures/mcl_armor_inv_elytra.png differ diff --git a/mods/ITEMS/mcl_armor_stand/init.lua b/mods/ITEMS/mcl_armor_stand/init.lua index c451b6de..d6080b8f 100644 --- a/mods/ITEMS/mcl_armor_stand/init.lua +++ b/mods/ITEMS/mcl_armor_stand/init.lua @@ -1,84 +1,41 @@ -local S = minetest.get_translator("mcl_armor_stand") +local S = minetest.get_translator(minetest.get_current_modname()) -local elements = {"head", "torso", "legs", "feet"} - -local function get_stand_object(pos) - local object = nil - local objects = minetest.get_objects_inside_radius(pos, 0.5) or {} - for _, obj in pairs(objects) do - local ent = obj:get_luaentity() - if ent then - if ent.name == "mcl_armor_stand:armor_entity" then - -- Remove duplicates - if object then - obj:remove() - else - object = obj - end - end - end - end - return object +-- Spawn a stand entity +local function spawn_stand_entity(pos, node) + local luaentity = minetest.add_entity(pos, "mcl_armor_stand:armor_entity"):get_luaentity() + luaentity:update_rotation(node or minetest.get_node(pos)) + return luaentity end -local function update_entity(pos) - local node = minetest.get_node(pos) - local object = get_stand_object(pos) - if object then - if not string.find(node.name, "mcl_armor_stand:") then - object:remove() - return +-- Find a stand entity or spawn one +local function get_stand_entity(pos, node) + for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 0)) do + local luaentity = obj:get_luaentity() + if luaentity and luaentity.name == "mcl_armor_stand:armor_entity" then + return luaentity end - else - object = minetest.add_entity(pos, "mcl_armor_stand:armor_entity") end - if object then - local texture = "blank.png" - local textures = {} - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local yaw = 0 - if inv then - for _, element in pairs(elements) do - local stack = inv:get_stack("armor_"..element, 1) - if stack:get_count() == 1 then - local item = stack:get_name() or "" - if minetest.registered_aliases[item] then - item = minetest.registered_aliases[item] - end - local def = stack:get_definition() or {} - local groups = def.groups or {} - if groups["armor_"..element] then - local texture = def.texture or item:gsub("%:", "_") - table.insert(textures, texture..".png") - end - end - end + return spawn_stand_entity(pos, node) +end + +-- Migrate the old inventory format +local function migrate_inventory(inv) + inv:set_size("armor", 5) + local lists = inv:get_lists() + for name, element in pairs(mcl_armor.elements) do + local listname = "armor_" .. name + local list = lists[listname] + if list then + inv:set_stack("armor", element.index, list[1]) + inv:set_size(listname, 0) end - if #textures > 0 then - texture = table.concat(textures, "^") - end - if node.param2 then - local rot = node.param2 % 4 - if rot == 1 then - yaw = 3 * math.pi / 2 - elseif rot == 2 then - yaw = math.pi - elseif rot == 3 then - yaw = math.pi / 2 - end - end - object:set_yaw(yaw) - object:set_properties({textures={texture}}) end end --- Drop all armor of the armor stand on the ground -local drop_armor = function(pos) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - for _, element in pairs(elements) do - local stack = inv:get_stack("armor_"..element, 1) +-- Drop all armor on the ground when it got destroyed +local function drop_inventory(pos) + local inv = minetest.get_meta(pos):get_inventory() + for _, stack in pairs(inv:get_list("armor")) do if not stack:is_empty() then local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} minetest.add_item(p, stack) @@ -111,136 +68,26 @@ minetest.register_node("mcl_armor_stand:armor_stand", { _mcl_hardness = 2, sounds = mcl_sounds.node_sound_wood_defaults(), on_construct = function(pos) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - for _, element in pairs(elements) do - inv:set_size("armor_"..element, 1) - end + spawn_stand_entity(pos) + end, + on_destruct = function(pos) + drop_inventory(pos) end, - -- Drop all armor on the ground when it got destroyed - on_destruct = drop_armor, - -- Put piece of armor on armor stand, or take one away on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then minetest.record_protection_violation(pos, protname) return itemstack end - local inv = minetest.get_inventory({type = "node", pos = pos}) - if not inv then - return itemstack - end - - -- Check if player wields armor - local name = itemstack:get_name() - local list - for e=1, #elements do - local g = minetest.get_item_group(name, "armor_" .. elements[e]) - if g ~= nil and g ~= 0 then - list = "armor_" .. elements[e] - break - end - end - -- If player wields armor, put it on armor stand - local wielditem = clicker:get_wielded_item() - if list then - -- ... but only if the slot is free - local single_item = ItemStack(itemstack) - single_item:set_count(1) - if inv:is_empty(list) then - inv:add_item(list, single_item) - armor:play_equip_sound(single_item, nil, pos) - update_entity(pos) - itemstack:take_item() - return itemstack - end - end - - -- Take armor from stand if player has a free hand or wields the same armor type (if stackable) - for e=1, #elements do - local stand_armor = inv:get_stack("armor_" .. elements[e], 1) - if not stand_armor:is_empty() then - local pinv = clicker:get_inventory() - local taken = false - -- Empty hand - if wielditem:get_name() == "" then - pinv:set_stack("main", clicker:get_wield_index(), stand_armor) - taken = true - -- Stackable armor type (if not already full). This is the case for e.g. mob heads. - -- This is done purely for convenience. - elseif (wielditem:get_name() == stand_armor:get_name() and wielditem:get_count() < wielditem:get_stack_max()) then - wielditem:set_count(wielditem:get_count()+1) - pinv:set_stack("main", clicker:get_wield_index(), wielditem) - taken = true - end - if taken then - armor:play_equip_sound(stand_armor, nil, pos, true) - stand_armor:take_item() - inv:set_stack("armor_" .. elements[e], 1, stand_armor) - end - update_entity(pos) - return clicker:get_wielded_item() - end - end - update_entity(pos) - return itemstack - end, - after_place_node = function(pos) - minetest.add_entity(pos, "mcl_armor_stand:armor_entity") - end, - allow_metadata_inventory_take = function(pos, listname, index, stack, player) - local name = player:get_player_name() - if minetest.is_protected(pos, name) then - minetest.record_protection_violation(pos, name) - return 0 - else - return stack:get_count() - end - end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) - local name = player:get_player_name() - if minetest.is_protected(pos, name) then - minetest.record_protection_violation(pos, name) - return 0 - end - local def = stack:get_definition() or {} - local groups = def.groups or {} - if groups[listname] then - return 1 - end - return 0 - end, - allow_metadata_inventory_move = function() - return 0 - end, - on_metadata_inventory_put = function(pos) - update_entity(pos) - end, - on_metadata_inventory_take = function(pos) - update_entity(pos) - end, - after_destruct = function(pos) - update_entity(pos) - end, - on_blast = function(pos, _, do_drop) - local object = get_stand_object(pos) - if object then - object:remove() - end - minetest.after(1, function(pos) - update_entity(pos) - end, pos) - minetest.remove_node(pos) - if do_drop then - minetest.add_item(pos, "mcl_armor_stand:armor_stand") - end + return mcl_armor.equip(itemstack, get_stand_entity(pos, node).object, true) end, on_rotate = function(pos, node, user, mode) if mode == screwdriver.ROTATE_FACE then node.param2 = (node.param2 + 1) % 4 minetest.swap_node(pos, node) - update_entity(pos) + get_stand_entity(pos, node):update_rotation(node) return true end return false @@ -248,50 +95,44 @@ minetest.register_node("mcl_armor_stand:armor_stand", { }) minetest.register_entity("mcl_armor_stand:armor_entity", { - physical = true, - visual = "mesh", - mesh = "3d_armor_entity.obj", - visual_size = {x=1, y=1}, - collisionbox = {-0.1,-0.4,-0.1, 0.1,1.3,0.1}, - pointable = false, - textures = {"blank.png"}, - pos = nil, - timer = 0, + initial_properties = { + physical = true, + visual = "mesh", + mesh = "3d_armor_entity.obj", + visual_size = {x=1, y=1}, + collisionbox = {-0.1,-0.4,-0.1, 0.1,1.3,0.1}, + pointable = false, + textures = {"blank.png"}, + timer = 0, + static_save = false, + }, on_activate = function(self) - local pos = self.object:get_pos() - self.object:set_armor_groups({immortal=1}) - if pos then - self.pos = vector.round(pos) - update_entity(pos) - end + self.object:set_armor_groups({immortal = 1}) + self.node_pos = vector.round(self.object:get_pos()) + self.inventory = minetest.get_meta(self.node_pos):get_inventory() + migrate_inventory(self.inventory) + mcl_armor.update(self.object) end, on_step = function(self, dtime) - if not self.pos then - return - end - self.timer = self.timer + dtime - if self.timer > 1 then - self.timer = 0 - local pos = self.object:get_pos() - if pos then - if vector.equals(vector.round(pos), self.pos) then - return - end - end - update_entity(self.pos) + if minetest.get_node(self.node_pos).name ~= "mcl_armor_stand:armor_stand" then self.object:remove() end end, + update_armor = function(self, info) + self.object:set_properties({textures = {info.texture}}) + end, + update_rotation = function(self, node) + self.object:set_yaw(minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2))) + end, }) --- FIXME: Armor helper entity can get destroyed by /clearobjects minetest.register_lbm({ label = "Respawn armor stand entities", name = "mcl_armor_stand:respawn_entities", nodenames = {"mcl_armor_stand:armor_stand"}, run_at_every_load = true, action = function(pos, node) - update_entity(pos, node) + spawn_stand_entity(pos, node) end, }) @@ -304,7 +145,6 @@ minetest.register_craft({ } }) - -- Legacy handling minetest.register_alias("3d_armor_stand:armor_stand", "mcl_armor_stand:armor_stand") minetest.register_entity(":3d_armor_stand:armor_entity", { diff --git a/mods/ITEMS/mcl_armor_stand/models/3d_armor_entity.obj b/mods/ITEMS/mcl_armor_stand/models/3d_armor_entity.obj index 052f6925..37bc521e 100644 --- a/mods/ITEMS/mcl_armor_stand/models/3d_armor_entity.obj +++ b/mods/ITEMS/mcl_armor_stand/models/3d_armor_entity.obj @@ -1,79 +1,132 @@ -# Blender v2.73 (sub 0) OBJ File: '3d_armor_entity_3.blend' +# Blender v2.92.0 OBJ File: '' # www.blender.org mtllib 3d_armor_entity.mtl +o Cube +v 1.000000 1.000000 -1.000000 +v 1.000000 -1.000000 -1.000000 +v 1.000000 1.000000 1.000000 +v 1.000000 -1.000000 1.000000 +v -1.000000 1.000000 -1.000000 +v -1.000000 -1.000000 -1.000000 +v -1.000000 1.000000 1.000000 +v -1.000000 -1.000000 1.000000 +vt 0.625000 0.500000 +vt 0.875000 0.500000 +vt 0.875000 0.750000 +vt 0.625000 0.750000 +vt 0.375000 0.750000 +vt 0.625000 1.000000 +vt 0.375000 1.000000 +vt 0.375000 0.000000 +vt 0.625000 0.000000 +vt 0.625000 0.250000 +vt 0.375000 0.250000 +vt 0.125000 0.500000 +vt 0.375000 0.500000 +vt 0.125000 0.750000 +vn 0.0000 1.0000 0.0000 +vn 0.0000 0.0000 1.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 -1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +usemtl Material +s off +f 1/1/1 5/2/1 7/3/1 3/4/1 +f 4/5/2 3/4/2 7/6/2 8/7/2 +f 8/8/3 7/9/3 5/10/3 6/11/3 +f 6/12/4 2/13/4 4/5/4 8/14/4 +f 2/13/5 1/1/5 3/4/5 4/5/5 +f 6/11/6 5/10/6 1/1/6 2/13/6 o Player_Cube -v 2.200000 9.763893 1.200000 -v 2.200000 9.763893 -1.200000 +v 2.200000 9.763893 1.200001 v 2.200000 2.663871 1.200000 v 2.200000 2.663871 -1.200000 +v 2.200000 9.763893 -1.200000 v -2.200000 9.763893 -1.200000 -v -2.200000 9.763893 1.200000 -v -2.200000 2.663871 -1.200000 +v -2.200000 9.763893 1.200001 v -2.200000 2.663871 1.200000 -v 2.300000 13.863962 2.300000 -v 2.300000 13.863962 -2.300000 +v -2.200000 2.663871 -1.200000 +v 2.300000 13.863962 2.300001 v 2.300000 9.263885 2.300000 -v 2.300000 9.263885 -2.300000 -v -2.300000 13.863962 -2.300000 -v -2.300000 13.863962 2.300000 -v -2.300000 9.263885 -2.300000 +v 2.300000 9.263885 -2.299999 +v 2.300000 13.863962 -2.299999 +v -2.300000 13.863962 -2.299999 +v -2.300000 13.863962 2.300001 v -2.300000 9.263885 2.300000 +v -2.300000 9.263885 -2.299999 v -2.322686 2.473175 -1.300000 v -2.322686 2.473175 1.300000 v -4.713554 2.682348 1.300000 v -4.713554 2.682348 -1.300000 -v -1.686446 9.745432 -1.300000 -v -1.686446 9.745432 1.300000 +v -4.077313 9.954605 -1.299999 v -4.077313 9.954605 1.300000 -v -4.077313 9.954605 -1.300000 -v 4.077313 9.954605 -1.300000 -v 4.077313 9.954605 1.300000 +v -1.686446 9.745432 1.300000 +v -1.686446 9.745432 -1.299999 v 1.686446 9.745432 1.300000 -v 1.686446 9.745432 -1.300000 -v 4.713554 2.682348 -1.300000 -v 4.713554 2.682348 1.300000 v 2.322686 2.473175 1.300000 +v 4.713554 2.682348 1.300000 +v 4.077313 9.954605 1.300000 +v 1.686446 9.745432 -1.299999 v 2.322686 2.473175 -1.300000 +v 4.077313 9.954605 -1.299999 +v 4.713554 2.682348 -1.300000 +v 2.538733 2.980834 -1.210000 v 0.139099 2.938947 -1.200000 v 0.139099 2.938947 1.200000 -v 0.261266 -4.059988 1.200000 -v 0.261266 -4.059988 -1.200000 -v 2.660901 -4.018101 1.190000 -v 2.660901 -4.018101 -1.210000 v 2.538733 2.980834 1.190000 -v 2.538733 2.980834 -1.210000 -v -0.139099 2.938947 -1.200000 -v -0.139099 2.938947 1.200000 -v -0.261266 -4.059988 1.200000 -v -0.261266 -4.059988 -1.200000 +v 0.261266 -4.059988 -1.200000 +v 2.660901 -4.018101 -1.210000 +v 2.660901 -4.018101 1.190000 +v 0.261266 -4.059988 1.200000 v -2.538734 2.980834 -1.210000 v -2.538734 2.980834 1.190000 +v -0.139099 2.938947 1.200000 +v -0.139099 2.938947 -1.200000 +v -0.261266 -4.059988 1.200000 +v -0.261266 -4.059988 -1.200000 v -2.660901 -4.018101 -1.210000 v -2.660901 -4.018101 1.190000 +v 0.000000 -4.387500 -1.400000 +v 0.000000 -4.387500 1.400000 v -2.799999 -4.387500 1.390000 v -2.799999 -4.387500 -1.410000 v -2.800000 -0.812499 1.390000 v -2.800000 -0.812499 -1.410000 -v -0.000000 -4.387500 -1.400000 -v -0.000000 -4.387500 1.400000 -v -0.000000 -0.812499 1.400000 -v -0.000000 -0.812499 -1.400000 -v 2.800000 -0.812499 -1.410000 -v 2.800000 -0.812499 1.390000 -v 2.799999 -4.387500 -1.410000 -v 2.799999 -4.387500 1.390000 +v 0.000000 -0.812499 1.400000 +v 0.000000 -0.812499 -1.400000 +v 0.000000 -0.812499 -1.400000 v 0.000000 -4.387500 -1.400000 v 0.000000 -4.387500 1.400000 v 0.000000 -0.812499 1.400000 -v 0.000000 -0.812499 -1.400000 -v 2.267006 13.830965 2.267006 -v 2.267006 13.830965 -2.267006 +v 2.800000 -0.812499 -1.410000 +v 2.799999 -4.387500 -1.410000 +v 2.799999 -4.387500 1.390000 +v 2.800000 -0.812499 1.390000 +v 2.267006 13.830965 2.267007 +v 2.267006 13.830965 -2.267005 +v 2.267006 9.296881 -2.267005 v 2.267006 9.296881 2.267006 -v 2.267006 9.296881 -2.267006 -v -2.267006 13.830965 -2.267006 -v -2.267006 13.830965 2.267006 -v -2.267006 9.296881 -2.267006 +v -2.267006 13.830965 -2.267005 +v -2.267006 13.830965 2.267007 +v -2.267006 9.296881 -2.267005 v -2.267006 9.296881 2.267006 +v -4.168111 10.060661 1.681621 +v 1.741822 -5.305762 4.169018 +v 1.718504 -5.438008 3.407457 +v -6.641035 -3.963995 3.407457 +v 4.191429 8.586647 1.681621 +v -6.617718 -3.831752 4.169018 +v 4.168111 8.454401 0.920061 +v -4.191429 9.928415 0.920061 +v -4.191429 8.586648 1.681620 +v 6.617716 -3.831752 4.169018 +v 6.641035 -3.963997 3.407457 +v -1.718504 -5.438006 3.407457 +v 4.168111 10.060658 1.681621 +v -1.741822 -5.305762 4.169018 +v 4.191429 9.928414 0.920061 +v -4.168111 8.454404 0.920061 vt 0.250000 0.375000 vt 0.250000 0.000000 vt 0.312500 0.000000 @@ -81,6 +134,8 @@ vt 0.312500 0.375000 vt 0.437500 0.375000 vt 0.437500 0.500000 vt 0.312500 0.500000 +vt 0.437500 0.500000 +vt 0.437500 0.375000 vt 0.562500 0.375000 vt 0.562500 0.500000 vt 0.437500 0.000000 @@ -97,97 +152,308 @@ vt 0.750000 1.000000 vt 0.625000 1.000000 vt 0.875000 0.750000 vt 0.875000 1.000000 +vt 0.750000 1.000000 +vt 0.750000 0.750000 vt 0.750000 0.500000 +vt 0.875000 0.750000 vt 0.875000 0.500000 vt 1.000000 0.750000 vt 1.000000 0.500000 vt 0.750000 0.375000 +vt 0.750000 0.500000 vt 0.812500 0.500000 vt 0.812500 0.375000 vt 0.687500 0.375000 vt 0.687500 0.500000 +vt 0.750000 0.500000 +vt 0.750000 0.375000 +vt 0.687500 0.375000 +vt 0.625000 0.375000 +vt 0.625000 0.000000 vt 0.687500 0.000000 vt 0.750000 0.000000 +vt 0.687500 0.000000 +vt 0.812500 0.375000 vt 0.812500 0.000000 vt 0.875000 0.375000 vt 0.875000 0.000000 +vt 0.812500 0.375000 +vt 0.812500 0.000000 +vt 0.875000 0.000000 +vt 0.875000 0.375000 +vt 0.750000 0.375000 +vt 0.750000 0.000000 +vt 0.687500 0.375000 +vt 0.687500 0.000000 +vt 0.687500 0.375000 +vt 0.687500 0.000000 +vt 0.625000 0.000000 +vt 0.625000 0.375000 +vt 0.750000 0.500000 +vt 0.687500 0.500000 +vt 0.750000 0.375000 +vt 0.812500 0.375000 +vt 0.812500 0.500000 +vt 0.750000 0.500000 vt 0.125000 0.375000 vt 0.062500 0.375000 vt 0.062500 0.500000 vt 0.125000 0.500000 vt 0.187500 0.375000 +vt 0.125000 0.375000 +vt 0.125000 0.500000 vt 0.187500 0.500000 vt 0.000000 0.375000 vt 0.000000 0.000000 vt 0.062500 0.000000 +vt 0.062500 0.375000 +vt 0.250000 0.375000 +vt 0.250000 0.000000 +vt 0.187500 0.000000 +vt 0.187500 0.375000 +vt 0.125000 0.000000 +vt 0.062500 0.000000 +vt 0.187500 0.375000 vt 0.187500 0.000000 vt 0.125000 0.000000 -vt 0.437500 0.875000 -vt 0.437500 1.000000 -vt 0.375000 1.000000 -vt 0.375000 0.875000 -vt 0.250000 0.875000 -vt 0.312500 0.875000 -vt 0.312500 0.656250 -vt 0.250000 0.656250 -vt 0.500000 0.875000 -vt 0.437500 0.656250 -vt 0.500000 0.656250 -vt 0.375000 0.656250 -vt 0.312500 1.000000 -usemtl Armor +vt 0.125000 0.375000 +vt 0.125000 0.375000 +vt 0.125000 0.500000 +vt 0.062500 0.500000 +vt 0.062500 0.375000 +vt 0.187500 0.375000 +vt 0.125000 0.375000 +vt 0.125000 0.000000 +vt 0.187500 0.000000 +vt 0.062500 0.000000 +vt 0.125000 0.000000 +vt 0.250000 0.375000 +vt 0.187500 0.375000 +vt 0.187500 0.000000 +vt 0.250000 0.000000 +vt 0.000000 0.375000 +vt 0.062500 0.375000 +vt 0.062500 0.000000 +vt 0.000000 0.000000 +vt 0.187500 0.375000 +vt 0.187500 0.500000 +vt 0.125000 0.500000 +vt 0.125000 0.375000 +vt 0.381250 0.832812 +vt 0.381250 0.845312 +vt 0.375000 0.845312 +vt 0.375000 0.832812 +vt 0.362500 0.832812 +vt 0.368750 0.832812 +vt 0.368750 0.810938 +vt 0.362500 0.810938 +vt 0.387500 0.832812 +vt 0.381250 0.832812 +vt 0.381250 0.810938 +vt 0.387500 0.810938 +vt 0.375000 0.832812 +vt 0.368750 0.832812 +vt 0.368750 0.810938 +vt 0.375000 0.810938 +vt 0.381250 0.832812 +vt 0.375000 0.832812 +vt 0.375000 0.810938 +vt 0.381250 0.810938 +vt 0.375000 0.845312 +vt 0.368750 0.845312 +vt 0.381250 0.832812 +vt 0.381250 0.810938 +vt 0.375000 0.810938 +vt 0.375000 0.832812 +vt 0.375000 0.832812 +vt 0.375000 0.810938 +vt 0.368750 0.810938 +vt 0.368750 0.832812 +vt 0.387500 0.832812 +vt 0.387500 0.810938 +vt 0.381250 0.810938 +vt 0.381250 0.832812 +vt 0.362500 0.832812 +vt 0.362500 0.810938 +vt 0.368750 0.810938 +vt 0.368750 0.832812 +vt 0.381250 0.832812 +vt 0.375000 0.832812 +vt 0.375000 0.845312 +vt 0.381250 0.845312 +vt 0.368750 0.845312 +vt 0.375000 0.845312 +vt 0.500000 0.750000 +vt 0.625000 0.750000 +vt 0.625000 0.500000 +vt 0.500000 0.500000 +vt 0.750000 0.750000 +vt 0.625000 1.000000 +vt 0.750000 1.000000 +vt 0.875000 0.750000 +vt 0.750000 0.750000 +vt 0.750000 1.000000 +vt 0.875000 1.000000 +vt 0.750000 0.500000 +vt 0.875000 0.750000 +vt 0.875000 0.500000 +vt 1.000000 0.750000 +vt 1.000000 0.500000 +vt 0.032859 0.558649 +vt 0.032859 0.998468 +vt 0.362724 0.998468 +vt 0.362724 0.558649 +vt 0.032859 0.558649 +vt 0.362724 0.558649 +vt 0.362724 0.998468 +vt 0.032859 0.998468 +vt 0.039157 0.992309 +vt 0.039157 0.656118 +vt 0.060169 0.656118 +vt 0.060169 0.992309 +vt -0.003415 0.501261 +vt 0.368238 0.501261 +vt 0.368238 0.563203 +vt -0.003415 0.563203 +vt 0.368238 0.996797 +vt -0.003415 0.996797 +vt -0.003415 0.934855 +vt 0.368238 0.934855 +vt 0.394691 0.498800 +vt 0.394691 0.994336 +vt 0.363720 0.994336 +vt 0.363720 0.498800 +vt 0.032859 0.998468 +vt 0.032859 0.558649 +vt 0.362724 0.558649 +vt 0.362724 0.998468 +vt 0.032859 0.998468 +vt 0.362724 0.998468 +vt 0.362724 0.558649 +vt 0.032859 0.558649 +vt 0.039157 0.656118 +vt 0.039157 0.992309 +vt 0.060169 0.992309 +vt 0.060169 0.656118 +vt -0.003415 0.996797 +vt 0.368238 0.996797 +vt 0.368238 0.934855 +vt -0.003415 0.934855 +vt 0.368238 0.501261 +vt -0.003415 0.501261 +vt -0.003415 0.563203 +vt 0.368238 0.563203 +vt 0.394691 0.994336 +vt 0.394691 0.498800 +vt 0.363720 0.498800 +vt 0.363720 0.994336 +vn 1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 0.0000 -1.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 -0.0000 1.0000 +vn -0.0872 -0.9962 0.0000 +vn 0.0872 0.9962 0.0000 +vn -0.9962 0.0872 0.0000 +vn 0.9962 -0.0872 0.0000 +vn -0.9962 -0.0872 0.0000 +vn 0.9962 0.0872 0.0000 +vn -0.0872 0.9962 0.0000 +vn 0.0872 -0.9962 0.0000 +vn -0.0175 0.9998 0.0000 +vn 0.0175 -0.9998 0.0000 +vn 0.9998 0.0175 0.0000 +vn 0.0042 0.0001 1.0000 +vn -0.0042 -0.0001 -1.0000 +vn -0.9998 -0.0175 0.0000 +vn 0.0175 0.9998 0.0000 +vn 0.9998 -0.0175 0.0000 +vn 0.0042 -0.0001 -1.0000 +vn -0.0042 0.0001 1.0000 +vn -0.9998 0.0175 0.0000 +vn -0.0175 -0.9998 0.0000 +vn -0.0036 -0.0000 1.0000 +vn 0.0036 0.0000 -1.0000 +vn -0.0036 0.0000 -1.0000 +vn 0.0036 -0.0000 1.0000 +vn 0.0302 0.1710 0.9848 +vn -0.0302 -0.1710 -0.9848 +vn 0.1710 0.9698 -0.1737 +vn 0.9848 -0.1736 0.0000 +vn -0.9848 0.1736 -0.0000 +vn -0.1710 -0.9698 0.1736 +vn -0.0302 0.1710 0.9848 +vn 0.0302 -0.1710 -0.9848 +vn -0.1710 0.9698 -0.1736 +vn 0.9848 0.1736 0.0000 +vn -0.9848 -0.1736 -0.0000 +vn 0.1710 -0.9698 0.1736 +usemtl None s off -f 1/1 3/2 4/3 2/4 -f 5/5 6/6 1/7 2/4 -f 8/6 7/5 4/8 3/9 -f 5/5 2/4 4/3 7/10 -f 7/10 8/11 6/12 5/5 -f 8/11 3/13 1/14 6/12 -f 9/15 11/16 12/17 10/18 -f 13/19 14/20 9/21 10/18 -f 12/22 11/23 16/20 15/19 -f 13/19 10/18 12/17 15/24 -f 14/22 13/19 15/24 16/25 -f 9/26 14/22 16/25 11/27 -f 17/28 18/24 19/29 20/30 -f 24/31 23/32 22/24 21/28 -f 23/31 24/14 20/13 19/33 -f 24/31 21/28 17/34 20/33 -f 21/28 22/30 18/35 17/34 -f 22/30 23/36 19/37 18/35 -f 27/30 31/35 30/37 26/36 -f 28/28 32/34 31/35 27/30 -f 25/31 29/33 32/34 28/28 -f 26/31 30/33 29/13 25/14 -f 25/31 28/28 27/24 26/32 -f 32/28 29/30 30/29 31/24 -f 40/38 33/39 34/40 39/41 -f 36/42 38/38 37/41 35/43 -f 39/44 37/45 38/46 40/39 -f 34/1 35/2 37/47 39/42 -f 40/38 38/48 36/46 33/39 -f 33/42 36/47 35/48 34/38 -f 45/38 46/41 42/40 41/39 -f 41/42 42/38 43/48 44/47 -f 45/38 41/39 44/46 47/48 -f 42/1 46/42 48/47 43/2 -f 46/44 45/39 47/46 48/45 -f 44/42 43/43 48/41 47/38 -f 53/49 54/50 49/51 50/52 -f 51/53 52/54 50/55 49/56 -f 55/57 51/49 49/58 54/59 -f 52/52 56/54 53/55 50/60 -f 56/49 55/52 54/60 53/58 -f 52/52 51/51 55/61 56/54 -f 64/49 61/58 62/60 63/52 -f 57/52 59/60 61/55 64/54 -f 63/57 62/59 60/58 58/49 -f 58/53 60/56 59/55 57/54 -f 61/49 59/52 60/51 62/50 -f 57/52 64/54 63/61 58/51 -f 65/15 66/18 68/17 67/16 -f 69/19 66/18 65/21 70/20 -f 68/22 71/19 72/20 67/23 -f 69/19 71/24 68/17 66/18 -f 70/22 72/25 71/24 69/19 -f 65/26 67/27 72/25 70/22 +f 9/15/7 10/16/7 11/17/7 12/18/7 +f 13/19/8 14/20/8 9/21/8 12/18/8 +f 15/22/9 16/23/9 11/24/9 10/25/9 +f 13/19/10 12/18/10 11/17/10 16/26/10 +f 16/26/11 15/27/11 14/28/11 13/19/11 +f 15/27/12 10/29/12 9/30/12 14/28/12 +f 17/31/7 18/32/7 19/33/7 20/34/7 +f 21/35/8 22/36/8 17/37/8 20/34/8 +f 19/38/9 18/39/9 23/40/9 24/41/9 +f 21/35/10 20/34/10 19/33/10 24/42/10 +f 22/43/11 21/35/11 24/42/11 23/44/11 +f 17/45/12 22/43/12 23/44/12 18/46/12 +f 25/47/13 26/48/13 27/49/13 28/50/13 +f 29/51/14 30/52/14 31/53/14 32/54/14 +f 30/55/15 29/56/15 28/57/15 27/58/15 +f 29/51/10 32/54/10 25/59/10 28/60/10 +f 32/54/16 31/61/16 26/62/16 25/59/16 +f 31/61/12 30/63/12 27/64/12 26/62/12 +f 33/65/12 34/66/12 35/67/12 36/68/12 +f 37/69/17 38/70/17 34/66/17 33/65/17 +f 39/71/10 40/72/10 38/70/10 37/69/10 +f 36/73/18 35/74/18 40/75/18 39/76/18 +f 39/71/19 37/69/19 33/77/19 36/78/19 +f 38/79/20 40/80/20 35/81/20 34/82/20 +f 41/83/21 42/84/21 43/85/21 44/86/21 +f 45/87/22 46/88/22 47/89/22 48/90/22 +f 44/91/23 47/92/23 46/93/23 41/94/23 +f 43/95/24 48/96/24 47/97/24 44/98/24 +f 41/83/25 46/99/25 45/100/25 42/84/25 +f 42/101/26 45/102/26 48/103/26 43/104/26 +f 49/105/27 50/106/27 51/107/27 52/108/27 +f 52/109/28 51/110/28 53/111/28 54/112/28 +f 49/105/29 52/108/29 54/113/29 55/114/29 +f 51/115/30 50/116/30 56/117/30 53/118/30 +f 50/119/31 49/120/31 55/121/31 56/122/31 +f 54/123/32 53/124/32 56/125/32 55/126/32 +f 57/127/9 58/128/9 59/129/9 60/130/9 +f 61/131/11 62/132/11 60/133/11 59/134/11 +f 63/135/33 61/136/33 59/137/33 58/138/33 +f 62/139/34 64/140/34 57/141/34 60/142/34 +f 64/143/7 63/144/7 58/145/7 57/146/7 +f 62/139/8 61/147/8 63/148/8 64/140/8 +f 65/149/11 66/150/11 67/151/11 68/152/11 +f 69/153/35 70/154/35 66/155/35 65/156/35 +f 68/157/36 67/158/36 71/159/36 72/160/36 +f 72/161/7 71/162/7 70/163/7 69/164/7 +f 66/165/9 70/166/9 71/167/9 67/168/9 +f 69/153/8 65/156/8 68/169/8 72/170/8 +f 73/171/11 74/172/11 75/173/11 76/174/11 +f 77/175/9 74/172/9 73/176/9 78/177/9 +f 75/178/8 79/179/8 80/180/8 76/181/8 +f 77/175/12 79/182/12 75/173/12 74/172/12 +f 78/183/7 80/184/7 79/182/7 77/175/7 +f 73/185/10 76/186/10 80/184/10 78/183/10 +f 85/187/37 81/188/37 86/189/37 82/190/37 +f 87/191/38 83/192/38 84/193/38 88/194/38 +f 81/195/39 85/196/39 87/197/39 88/198/39 +f 85/199/40 82/200/40 83/201/40 87/202/40 +f 86/203/41 81/204/41 88/205/41 84/206/41 +f 82/207/42 86/208/42 84/209/42 83/210/42 +f 93/211/43 89/212/43 94/213/43 90/214/43 +f 95/215/44 91/216/44 92/217/44 96/218/44 +f 89/219/45 93/220/45 95/221/45 96/222/45 +f 93/223/46 90/224/46 91/225/46 95/226/46 +f 94/227/47 89/228/47 96/229/47 92/230/47 +f 90/231/48 94/232/48 92/233/48 91/234/48 diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index ce76f47f..490e2264 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -1,6 +1,11 @@ -local S = minetest.get_translator("mcl_banners") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) local N = function(s) return s end +local mod_mcl_core = minetest.get_modpath("mcl_core") +local mod_doc = minetest.get_modpath("doc") + local node_sounds if minetest.get_modpath("mcl_sounds") then node_sounds = mcl_sounds.node_sound_wood_defaults() @@ -35,13 +40,56 @@ mcl_banners.colors = { ["unicolor_light_blue"] = {"light_blue", S("Light Blue Banner"), "mcl_wool:light_blue", "#4040CF", "mcl_dye:lightblue", N("Light Blue") }, } + +local pattern_names = { + "", + "border", + "bricks", + "circle", + "creeper", + "cross", + "curly_border", + "diagonal_up_left", + "diagonal_up_right", + "diagonal_right", + "diagonal_left", + "flower", + "gradient", + "gradient_up", + "half_horizontal_bottom", + "half_horizontal", + "half_vertical", + "half_vertical_right", + "thing", + "rhombus", + "skull", + "small_stripes", + "square_bottom_left", + "square_bottom_right", + "square_top_left", + "square_top_right", + "straight_cross", + "stripe_bottom", + "stripe_center", + "stripe_downleft", + "stripe_downright", + "stripe_left", + "stripe_middle", + "stripe_right", + "stripe_top", + "triangle_bottom", + "triangle_top", + "triangles_bottom", + "triangles_top", +} + local colors_reverse = {} for k,v in pairs(mcl_banners.colors) do colors_reverse["mcl_banners:banner_item_"..v[1]] = k end -- Add pattern/emblazoning crafting recipes -dofile(minetest.get_modpath("mcl_banners").."/patterncraft.lua") +dofile(modpath.."/patterncraft.lua") -- Overlay ratios (0-255) local base_color_ratio = 224 @@ -50,11 +98,11 @@ local layer_ratio = 255 local standing_banner_entity_offset = { x=0, y=-0.499, z=0 } local hanging_banner_entity_offset = { x=0, y=-1.7, z=0 } -local rotation_level_to_yaw = function(rotation_level) +local function rotation_level_to_yaw(rotation_level) return (rotation_level * (math.pi/8)) + math.pi end -local on_dig_banner = function(pos, node, digger) +local function on_dig_banner(pos, node, digger) -- Check protection local name = digger:get_player_name() if minetest.is_protected(pos, name) then @@ -73,7 +121,7 @@ local on_dig_banner = function(pos, node, digger) minetest.remove_node(pos) end -local on_destruct_banner = function(pos, hanging) +local function on_destruct_banner(pos, hanging) local offset, nodename if hanging then offset = hanging_banner_entity_offset @@ -93,15 +141,15 @@ local on_destruct_banner = function(pos, hanging) end end -local on_destruct_standing_banner = function(pos) +local function on_destruct_standing_banner(pos) return on_destruct_banner(pos, false) end -local on_destruct_hanging_banner = function(pos) +local function on_destruct_hanging_banner(pos) return on_destruct_banner(pos, true) end -local make_banner_texture = function(base_color, layers) +local function make_banner_texture(base_color, layers) local colorize if mcl_banners.colors[base_color] then colorize = mcl_banners.colors[base_color][4] @@ -131,7 +179,7 @@ local make_banner_texture = function(base_color, layers) end end -local spawn_banner_entity = function(pos, hanging, itemstack) +local function spawn_banner_entity(pos, hanging, itemstack) local banner if hanging then banner = minetest.add_entity(pos, "mcl_banners:hanging_banner") @@ -147,7 +195,7 @@ local spawn_banner_entity = function(pos, hanging, itemstack) local colorid = colors_reverse[itemstack:get_name()] banner:get_luaentity():_set_textures(colorid, layers) local mname = imeta:get_string("name") - if mname ~= nil and mname ~= "" then + if mname and mname ~= "" then banner:get_luaentity()._item_name = mname banner:get_luaentity()._item_description = imeta:get_string("description") end @@ -155,7 +203,7 @@ local spawn_banner_entity = function(pos, hanging, itemstack) return banner end -local respawn_banner_entity = function(pos, node, force) +local function respawn_banner_entity(pos, node, force) local hanging = node.name == "mcl_banners:hanging_banner" local offset if hanging then @@ -300,24 +348,72 @@ minetest.register_node("mcl_banners:hanging_banner", { end, }) +-- for pattern_name, pattern in pairs(patterns) do for colorid, colortab in pairs(mcl_banners.colors) do + for i, pattern_name in ipairs(pattern_names) do local itemid = colortab[1] local desc = colortab[2] local wool = colortab[3] local colorize = colortab[4] - local itemstring = "mcl_banners:banner_item_"..itemid - local inv - if colorize then - inv = "mcl_banners_item_base.png^(mcl_banners_item_overlay.png^[colorize:"..colorize..")" + local itemstring + if pattern_name == "" then + itemstring = "mcl_banners:banner_item_" .. itemid else - inv = "mcl_banners_item_base.png^mcl_banners_item_overlay.png" + itemstring = "mcl_banners:banner_preview" .. "_" .. pattern_name .. "_" .. itemid end + local inv + local base + local finished_banner + if pattern_name == "" then + if colorize then + -- Base texture with base color + base = "mcl_banners_item_base.png^(mcl_banners_item_overlay.png^[colorize:"..colorize..")^[resize:32x32" + else + base = "mcl_banners_item_base.png^mcl_banners_item_overlay.png^[resize:32x32" + end + finished_banner = base + else + -- Banner item preview background + base = "mcl_banners_item_base.png^(mcl_banners_item_overlay.png^[colorize:#CCCCCC)^[resize:32x32" + + desc = S("Preview Banner") + + local pattern = "mcl_banners_" .. pattern_name .. ".png" + local color = colorize + + -- Generate layer texture + + -- TODO: The layer texture in the icon is squished + -- weirdly because the width/height aspect ratio of + -- the banner icon is 1:1.5, whereas the aspect ratio + -- of the banner entity is 1:2. A solution would be to + -- redraw the pattern textures as low-resolution pixel + -- art and use that instead. + + local layer = "(([combine:20x40:-2,-2="..pattern.."^[resize:16x24^[colorize:"..color..":"..layer_ratio.."))" + + function escape(text) + return text:gsub("%^", "\\%^"):gsub(":", "\\:") -- :gsub("%(", "\\%("):gsub("%)", "\\%)") + end + + finished_banner = "[combine:32x32:0,0=" .. escape(base) .. ":8,4=" .. escape(layer) + end + + inv = finished_banner + -- Banner items. - -- This is the player-visible banner item. It comes in 16 base colors. + -- This is the player-visible banner item. It comes in 16 base colors with a lot of patterns. -- The multiple items are really only needed for the different item images. -- TODO: Combine the items into only 1 item. + local groups + if pattern_name == "" then + groups = { banner = 1, deco_block = 1, flammable = -1 } + else + groups = { not_in_creative_inventory = 1 } + end + minetest.register_craftitem(itemstring, { description = desc, _tt_help = S("Paintable decoration"), @@ -326,7 +422,7 @@ for colorid, colortab in pairs(mcl_banners.colors) do wield_image = inv, -- Banner group groups together the banner items, but not the nodes. -- Used for crafting. - groups = { banner = 1, deco_block = 1, flammable = -1 }, + groups = groups, stack_max = 16, on_place = function(itemstack, placer, pointed_thing) @@ -451,7 +547,7 @@ for colorid, colortab in pairs(mcl_banners.colors) do end meta:set_int("rotation_level", rotation_level) - if banner_entity ~= nil then + if banner_entity then banner_entity:set_yaw(final_yaw) end @@ -477,7 +573,7 @@ for colorid, colortab in pairs(mcl_banners.colors) do end, }) - if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_wool") then + if mod_mcl_core and minetest.get_modpath("mcl_wool") then minetest.register_craft({ output = itemstring, recipe = { @@ -488,13 +584,14 @@ for colorid, colortab in pairs(mcl_banners.colors) do }) end - if minetest.get_modpath("doc") then + if mod_doc then -- Add item to node alias doc.add_entry_alias("nodes", "mcl_banners:standing_banner", "craftitems", itemstring) end + end end -if minetest.get_modpath("doc") then +if mod_doc then -- Add item to node alias doc.add_entry_alias("nodes", "mcl_banners:standing_banner", "nodes", "mcl_banners:hanging_banner") end diff --git a/mods/ITEMS/mcl_banners/locale/mcl_banners.de.tr b/mods/ITEMS/mcl_banners/locale/mcl_banners.de.tr index 3bf65629..d5077dc7 100644 --- a/mods/ITEMS/mcl_banners/locale/mcl_banners.de.tr +++ b/mods/ITEMS/mcl_banners/locale/mcl_banners.de.tr @@ -22,7 +22,7 @@ Magenta=magenta Orange Banner=Orange Banner Orange=orange Purple Banner=Violettes Banner -Purple=violett +Violet=violett Brown Banner=Braunes Banner Brown=braun Pink Banner=Rosa Banner diff --git a/mods/ITEMS/mcl_banners/locale/mcl_banners.fr.tr b/mods/ITEMS/mcl_banners/locale/mcl_banners.fr.tr index ee877272..cadf37c3 100644 --- a/mods/ITEMS/mcl_banners/locale/mcl_banners.fr.tr +++ b/mods/ITEMS/mcl_banners/locale/mcl_banners.fr.tr @@ -46,7 +46,7 @@ You can copy the pattern of a banner by placing two banners of the same color in @1 Per Bend Sinister=Division oblique (@1) @1 Flower Charge=Figure Fleur (@1) @1 Gradient=Dégradé (@1) -@1 Base Gradient=Dégradé de couleurs (@1) +@1 Base Gradient=Dégradé de couleurs (@1) @1 Per Fess Inverted=Division inverse (@1) @1 Per Fess=Division (@1) @1 Per Pale=Division (@1) @@ -73,5 +73,5 @@ You can copy the pattern of a banner by placing two banners of the same color in @1 Base Indented=Pied dentelé (@1)t @1 Chief Indented=Tête dentelée (@1) And one additional layer=Et une couche supplémentaire -And @1 additional layer(s)=Et @1 couche(s) supplémentaire(s) +And @1 additional layers=Et @1 couches supplémentaires Paintable decoration=Décoration à peindre diff --git a/mods/ITEMS/mcl_banners/locale/mcl_banners.ru.tr b/mods/ITEMS/mcl_banners/locale/mcl_banners.ru.tr index 01993ae2..a6cee5a6 100644 --- a/mods/ITEMS/mcl_banners/locale/mcl_banners.ru.tr +++ b/mods/ITEMS/mcl_banners/locale/mcl_banners.ru.tr @@ -73,5 +73,5 @@ You can copy the pattern of a banner by placing two banners of the same color in @1 Base Indented=@1 Инвертированный основной @1 Chief Indented=@1 Инвертированный главный And one additional layer=И один индивидуальный слой -And @1 additional layer(s)=И @1 дополнительный(х) слой(я,ёв) +And @1 additional layers=И @1 дополнительныйх слойёв Paintable decoration=Художественное украшение diff --git a/mods/ITEMS/mcl_banners/locale/template.txt b/mods/ITEMS/mcl_banners/locale/template.txt index 944a1a7a..cb8ec0b0 100644 --- a/mods/ITEMS/mcl_banners/locale/template.txt +++ b/mods/ITEMS/mcl_banners/locale/template.txt @@ -73,5 +73,5 @@ You can copy the pattern of a banner by placing two banners of the same color in @1 Base Indented= @1 Chief Indented= And one additional layer= -And @1 additional layer(s)= +And @1 additional layers= Paintable decoration= diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index 31782a42..bc2771fe 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_banners") +local S = minetest.get_translator(minetest.get_current_modname()) local N = function(s) return s end -- Pattern crafting. This file contains the code for crafting all the @@ -253,8 +253,13 @@ for colorid, colortab in pairs(mcl_banners.colors) do dye_to_colorid_mapping[colortab[5]] = colorid end +local dye_to_itemid_mapping = {} +for colorid, colortab in pairs(mcl_banners.colors) do + dye_to_itemid_mapping[colortab[5]] = colortab[1] +end + -- Create a banner description containing all the layer names -mcl_banners.make_advanced_banner_description = function(description, layers) +function mcl_banners.make_advanced_banner_description(description, layers) if layers == nil or #layers == 0 then -- No layers, revert to default return "" @@ -291,7 +296,7 @@ Parameters same as for minetest.register_craft_predict. craft_predict is set true when called from minetest.craft_preview, in this case, this function MUST NOT change the crafting grid. ]] -local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_inv, craft_predict) +local function banner_pattern_craft(itemstack, player, old_craft_grid, craft_inv, craft_predict) if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then return end @@ -421,7 +426,6 @@ local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_i if (pitem == d and minetest.get_item_group(itemname, "dye") == 0) or (pitem == e and itemname ~= e and inv_i ~= banner_index) then pattern_ok = false break - else end inv_i = inv_i + 1 if inv_i > max_i then @@ -491,7 +495,14 @@ local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_i imeta:set_string("description", ometa:get_string("description")) imeta:set_string("name", mname) end - return itemstack + + if craft_predict then + local itemid_prefix = "mcl_banners:banner_preview" + local coloritemid = dye_to_itemid_mapping[dye] + return ItemStack(itemid_prefix .. "_" .. matching_pattern .. "_" .. coloritemid) + else + return itemstack + end end minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv) diff --git a/mods/ITEMS/mcl_beds/api.lua b/mods/ITEMS/mcl_beds/api.lua index a2df1bdf..85873f3c 100644 --- a/mods/ITEMS/mcl_beds/api.lua +++ b/mods/ITEMS/mcl_beds/api.lua @@ -1,23 +1,97 @@ -local S = minetest.get_translator("mcl_beds") +local S = minetest.get_translator(minetest.get_current_modname()) + +local minetest_get_node = minetest.get_node +local minetest_get_node_or_nil = minetest.get_node_or_nil +local minetest_remove_node = minetest.remove_node +local minetest_facedir_to_dir = minetest.facedir_to_dir +local minetest_add_item = minetest.add_item +local vector_add = vector.add +local vector_subtract = vector.subtract + +local function get_bed_next_node(pos, node) + local node = node or minetest_get_node_or_nil(pos) + if not node then return end + + local dir = minetest_facedir_to_dir(node.param2) + + local pos2, bottom + if string.sub(node.name, -4) == "_top" then + pos2 = vector_subtract(pos, dir) + else + pos2 = vector_add(pos, dir) + bottom = true + end + + local node2 = minetest_get_node(pos2) + return pos2, node2, bottom, dir +end + +local function rotate(pos, node, user, mode, new_param2) + if mode ~= screwdriver.ROTATE_FACE then + return false + end + + local p, node2, bottom = get_bed_next_node(pos, node) + if not node2 then return end + + local name = node2.name + if not minetest.get_item_group(name, "bed") == 2 or not node.param2 == node2.param2 then return false end + + if bottom then + name = string.sub(name, 1, -5) + else + name = string.sub(name, 1, -8) + end + + if minetest.is_protected(p, user:get_player_name()) then + minetest.record_protection_violation(p, user:get_player_name()) + return false + end + + local newp + local new_dir = minetest_facedir_to_dir(new_param2) + + if bottom then + newp = vector_add(pos, new_dir) + else + newp = vector_subtract(pos, new_dir) + end + + local node3 = minetest_get_node_or_nil(newp) + if not node3 then return false end + + local node_def = minetest.registered_nodes[node3.name] + if not node_def or not node_def.buildable_to then return false end + + if minetest.is_protected(newp, user:get_player_name()) then + minetest.record_protection_violation(newp, user:get_player_name()) + return false + end + + node.param2 = new_param2 + -- do not remove_node here - it will trigger destroy_bed() + minetest.swap_node(p, {name = "air"}) + minetest.swap_node(pos, node) + minetest.swap_node(newp, {name = name .. (bottom and "_top" or "_bottom"), param2 = new_param2}) + + return true +end + local function destruct_bed(pos, oldnode) - local node = oldnode or minetest.get_node(pos) + local node = oldnode or minetest_get_node_or_nil(pos) if not node then return end - local dir = minetest.facedir_to_dir(node.param2) - local pos2, node2 - if string.sub(node.name, -4) == "_top" then - pos2 = vector.subtract(pos, dir) - node2 = minetest.get_node(pos2) - if node2 and string.sub(node2.name, -7) == "_bottom" then - minetest.remove_node(pos2) - end - minetest.check_for_falling(pos) - elseif string.sub(node.name, -7) == "_bottom" then - minetest.add_item(pos, node.name) - pos2 = vector.add(pos, dir) - node2 = minetest.get_node(pos2) + + local pos2, node2, bottom = get_bed_next_node(pos, oldnode) + + if bottom then + minetest_add_item(pos, node.name) if node2 and string.sub(node2.name, -4) == "_top" then - minetest.remove_node(pos2) + minetest_remove_node(pos2) + end + else + if node2 and string.sub(node2.name, -7) == "_bottom" then + minetest_remove_node(pos2) end end end @@ -81,7 +155,7 @@ function mcl_beds.register_bed(name, def) paramtype2 = "facedir", is_ground_content = false, stack_max = 1, - groups = {handy=1, flammable = 3, bed = 1, dig_by_piston=1, bouncy=66, fall_damage_add_percent=-50, deco_block = 1, flammable=-1}, + groups = {handy=1, bed = 1, dig_by_piston=1, bouncy=66, fall_damage_add_percent=-50, deco_block = 1, flammable=-1}, _mcl_hardness = 0.2, _mcl_blast_resistance = 1, sounds = def.sounds or default_sounds, @@ -94,7 +168,7 @@ function mcl_beds.register_bed(name, def) local under = pointed_thing.under -- Use pointed node's on_rightclick function first, if present - local node = minetest.get_node(under) + local node = minetest_get_node(under) if placer and not placer: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, placer, itemstack) or itemstack @@ -102,7 +176,7 @@ function mcl_beds.register_bed(name, def) end local pos - local undername = minetest.get_node(under).name + local undername = minetest_get_node(under).name if minetest.registered_items[undername] and minetest.registered_items[undername].buildable_to then pos = under else @@ -115,13 +189,13 @@ function mcl_beds.register_bed(name, def) return itemstack end - local node_def = minetest.registered_nodes[minetest.get_node(pos).name] + local node_def = minetest.registered_nodes[minetest_get_node(pos).name] if not node_def or not node_def.buildable_to then return itemstack end local dir = minetest.dir_to_facedir(placer:get_look_dir()) - local botpos = vector.add(pos, minetest.facedir_to_dir(dir)) + local botpos = vector_add(pos, minetest_facedir_to_dir(dir)) if minetest.is_protected(botpos, placer:get_player_name()) and not minetest.check_player_privs(placer, "protection_bypass") then @@ -129,7 +203,7 @@ function mcl_beds.register_bed(name, def) return itemstack end - local botdef = minetest.registered_nodes[minetest.get_node(botpos).name] + local botdef = minetest.registered_nodes[minetest_get_node(botpos).name] if not botdef or not botdef.buildable_to then return itemstack end @@ -152,38 +226,7 @@ function mcl_beds.register_bed(name, def) return itemstack end, - on_rotate = function(pos, node, user, mode, new_param2) - local dir = minetest.facedir_to_dir(node.param2) - local p = vector.add(pos, dir) - local node2 = minetest.get_node_or_nil(p) - if not node2 or not minetest.get_item_group(node2.name, "bed") == 2 or - not node.param2 == node2.param2 then - return false - end - if minetest.is_protected(p, user:get_player_name()) then - minetest.record_protection_violation(p, user:get_player_name()) - return false - end - if mode ~= screwdriver.ROTATE_FACE then - return false - end - local newp = vector.add(pos, minetest.facedir_to_dir(new_param2)) - local node3 = minetest.get_node_or_nil(newp) - local node_def = node3 and minetest.registered_nodes[node3.name] - if not node_def or not node_def.buildable_to then - return false - end - if minetest.is_protected(newp, user:get_player_name()) then - minetest.record_protection_violation(newp, user:get_player_name()) - return false - end - node.param2 = new_param2 - -- do not remove_node here - it will trigger destroy_bed() - minetest.set_node(p, {name = "air"}) - minetest.set_node(pos, node) - minetest.set_node(newp, {name = name .. "_top", param2 = new_param2}) - return true - end, + on_rotate = rotate, }) local node_box_top, selection_box_top, collision_box_top @@ -217,7 +260,7 @@ function mcl_beds.register_bed(name, def) mcl_beds.on_rightclick(pos, clicker, true) return itemstack end, - on_rotate = false, + on_rotate = rotate, after_destruct = destruct_bed, }) diff --git a/mods/ITEMS/mcl_beds/beds.lua b/mods/ITEMS/mcl_beds/beds.lua index 8f41c7a3..5043c85d 100644 --- a/mods/ITEMS/mcl_beds/beds.lua +++ b/mods/ITEMS/mcl_beds/beds.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_beds") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") local nodebox = { diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 86f6a685..dc9afe2b 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -1,22 +1,25 @@ -local S = minetest.get_translator("mcl_beds") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape -local pi = math.pi +local math = math +local vector = vector local player_in_bed = 0 local is_sp = minetest.is_singleplayer() -local weather_mod = minetest.get_modpath("mcl_weather") ~= nil -local explosions_mod = minetest.get_modpath("mcl_explosions") ~= nil +local weather_mod = minetest.get_modpath("mcl_weather") +local explosions_mod = minetest.get_modpath("mcl_explosions") +local spawn_mod = minetest.get_modpath("mcl_spawn") +local worlds_mod = minetest.get_modpath("mcl_worlds") -- Helper functions local function get_look_yaw(pos) local n = minetest.get_node(pos) if n.param2 == 1 then - return pi / 2, n.param2 + return math.pi / 2, n.param2 elseif n.param2 == 3 then - return -pi / 2, n.param2 + return -math.pi / 2, n.param2 elseif n.param2 == 0 then - return pi, n.param2 + return math.pi, n.param2 else return 0, n.param2 end @@ -76,7 +79,7 @@ local function lay_down(player, pos, bed_pos, state, skip) bed_center = {x = bed_pos.x - dir.x/2, y = bed_pos.y + 0.1, z = bed_pos.z - dir.z/2} -- save respawn position when entering bed - if minetest.get_modpath("mcl_spawn") and mcl_spawn.set_spawn_pos(player, bed_pos, false) then + if spawn_mod and mcl_spawn.set_spawn_pos(player, bed_pos, nil) then minetest.chat_send_player(name, S("New respawn position set!")) end @@ -86,7 +89,7 @@ local function lay_down(player, pos, bed_pos, state, skip) end for _, other_pos in pairs(mcl_beds.bed_pos) do - if vector.distance(bed_pos, other_pos) < 0.1 then + if vector.distance(bed_pos2, other_pos) < 0.1 then return false, S("This bed is already occupied!") end end @@ -103,7 +106,7 @@ local function lay_down(player, pos, bed_pos, state, skip) -- The exceptions above apply. -- Zombie pigmen only prevent sleep while they are hostle. for _, obj in pairs(minetest.get_objects_inside_radius(bed_pos, 8)) do - if obj ~= nil and not obj:is_player() then + if obj and not obj:is_player() then local ent = obj:get_luaentity() local mobname = ent.name local def = minetest.registered_entities[mobname] @@ -120,7 +123,7 @@ local function lay_down(player, pos, bed_pos, state, skip) -- stand up if state ~= nil and not state then local p = mcl_beds.pos[name] or nil - if mcl_beds.player[name] ~= nil then + if mcl_beds.player[name] then mcl_beds.player[name] = nil player_in_bed = player_in_bed - 1 end @@ -155,7 +158,7 @@ local function lay_down(player, pos, bed_pos, state, skip) local def2 = minetest.registered_nodes[n2.name] if def1.walkable or def2.walkable then return false, S("You can't sleep, the bed is obstructed!") - elseif (def1.damage_per_second ~= nil and def1.damage_per_second > 0) or (def2.damage_per_second ~= nil and def2.damage_per_second > 0) then + elseif (def1.damage_per_second and def1.damage_per_second > 0) or (def2.damage_per_second and def2.damage_per_second > 0) then return false, S("It's too dangerous to sleep here!") end @@ -168,7 +171,7 @@ local function lay_down(player, pos, bed_pos, state, skip) mcl_beds.player[name] = 1 mcl_beds.pos[name] = pos - mcl_beds.bed_pos[name] = bed_pos + mcl_beds.bed_pos[name] = bed_pos2 player_in_bed = player_in_bed + 1 -- physics, eye_offset, etc player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0}) @@ -271,7 +274,7 @@ end -- Throw a player out of bed function mcl_beds.kick_player(player) local name = player:get_player_name() - if mcl_beds.player[name] ~= nil then + if mcl_beds.player[name] then lay_down(player, nil, nil, false) update_formspecs(false) minetest.close_formspec(name, "mcl_beds_form") @@ -297,11 +300,15 @@ function mcl_beds.on_rightclick(pos, player, is_top) if player:get_meta():get_string("mcl_beds:sleeping") == "true" then return end - if minetest.get_modpath("mcl_worlds") then + if worlds_mod then local dim = mcl_worlds.pos_to_dimension(pos) if dim == "nether" or dim == "end" then -- Bed goes BOOM in the Nether or End. + local node = minetest.get_node(pos) + local dir = minetest.facedir_to_dir(node.param2) + minetest.remove_node(pos) + minetest.remove_node(string.sub(node.name, -4) == "_top" and vector.subtract(pos, dir) or vector.add(pos, dir)) if explosions_mod then mcl_explosions.explode(pos, 5, {drop_chance = 1.0, fire = true}) end @@ -313,14 +320,14 @@ function mcl_beds.on_rightclick(pos, player, is_top) -- move to bed if not mcl_beds.player[name] then - local success, message + local message if is_top then - success, message = lay_down(player, ppos, pos) + message = select(2, lay_down(player, ppos, pos)) else local node = minetest.get_node(pos) local dir = minetest.facedir_to_dir(node.param2) local other = vector.add(pos, dir) - success, message = lay_down(player, ppos, other) + message = select(2, lay_down(player, ppos, other)) end if message then mcl_tmp_message.message(player, message) diff --git a/mods/ITEMS/mcl_books/init.lua b/mods/ITEMS/mcl_books/init.lua index 5101994e..e549ef6f 100644 --- a/mods/ITEMS/mcl_books/init.lua +++ b/mods/ITEMS/mcl_books/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_books") +local S = minetest.get_translator(minetest.get_current_modname()) local max_text_length = 4500 -- TODO: Increase to 12800 when scroll bar was added to written book local max_title_length = 64 @@ -21,16 +21,16 @@ minetest.register_craftitem("mcl_books:book", { if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then minetest.register_craft({ - type = 'shapeless', - output = 'mcl_books:book', - recipe = { 'mcl_core:paper', 'mcl_core:paper', 'mcl_core:paper', 'mcl_mobitems:leather', } + type = "shapeless", + output = "mcl_books:book", + recipe = { "mcl_core:paper", "mcl_core:paper", "mcl_core:paper", "mcl_mobitems:leather", } }) end -- Get the included text out of the book item -- itemstack: Book item -- meta: Meta of book (optional) -local get_text = function(itemstack) +local function get_text(itemstack) -- Grab the text local meta = itemstack:get_meta() local text = meta:get_string("text") @@ -56,7 +56,7 @@ local get_text = function(itemstack) return text end -local make_description = function(title, author, generation) +local function make_description(title, author, generation) local desc if generation == 0 then desc = S("“@1”", title) @@ -71,11 +71,11 @@ local make_description = function(title, author, generation) return desc end -local cap_text_length = function(text, max_length) +local function cap_text_length(text, max_length) return string.sub(text, 1, max_length) end -local write = function(itemstack, user, pointed_thing) +local function write(itemstack, user, pointed_thing) -- Call on_rightclick if the pointed node defines it if pointed_thing.type == "node" then local node = minetest.get_node(pointed_thing.under) @@ -96,7 +96,7 @@ local write = function(itemstack, user, pointed_thing) minetest.show_formspec(user:get_player_name(), "mcl_books:writable_book", formspec) end -local read = function(itemstack, user, pointed_thing) +local function read(itemstack, user, pointed_thing) -- Call on_rightclick if the pointed node defines it if pointed_thing.type == "node" then local node = minetest.get_node(pointed_thing.under) @@ -147,8 +147,8 @@ minetest.register_on_player_receive_fields(function ( player, formname, fields ) local formspec = "size[8,9]".. header.. "background[-0.5,-0.5;9,10;mcl_books_book_bg.png]".. - "field[0.75,1;7.25,1;title;"..minetest.formspec_escape(minetest.colorize(mcl_colors.BLACK, S("Enter book title:")))..";]".. - "label[0.75,1.5;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("by @1", name))).."]".. + "field[0.75,1;7.25,1;title;"..minetest.formspec_escape(minetest.colorize("#000000", S("Enter book title:")))..";]".. + "label[0.75,1.5;"..minetest.formspec_escape(minetest.colorize("#404040", S("by @1", name))).."]".. "button_exit[0.75,7.95;3,1;sign;"..minetest.formspec_escape(S("Sign and Close")).."]".. "tooltip[sign;"..minetest.formspec_escape(S("Note: The book will no longer be editable after signing")).."]".. "button[4.25,7.95;3,1;cancel;"..minetest.formspec_escape(S("Cancel")).."]" @@ -238,11 +238,9 @@ minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craf end local original - local index for i = 1, player:get_inventory():get_size("craft") do if old_craft_grid[i]:get_name() == "mcl_books:written_book" then original = old_craft_grid[i] - index = i end end if not original then @@ -349,11 +347,11 @@ minetest.register_node("mcl_books:bookshelf", { }) minetest.register_craft({ - output = 'mcl_books:bookshelf', + output = "mcl_books:bookshelf", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'mcl_books:book', 'mcl_books:book', 'mcl_books:book'}, - {'group:wood', 'group:wood', 'group:wood'}, + {"group:wood", "group:wood", "group:wood"}, + {"mcl_books:book", "mcl_books:book", "mcl_books:book"}, + {"group:wood", "group:wood", "group:wood"}, } }) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index cddae086..9a22ee62 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -1,29 +1,32 @@ -local S = minetest.get_translator("mcl_bows") +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 = 60 -- Time after which stuck arrow is rechecked for being stuck local STUCK_RECHECK_TIME = 5 -local GRAVITY = 9.81 +--local GRAVITY = 9.81 local YAW_OFFSET = -math.pi/2 -local dir_to_pitch = function(dir) - local dir2 = vector.normalize(dir) +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 random_arrow_positions = function(positions, placement) - if positions == 'x' then +local function random_arrow_positions(positions, placement) + if positions == "x" then return math.random(-4, 4) - elseif positions == 'y' then + elseif positions == "y" then return math.random(0, 10) end - if placement == 'front' and positions == 'z' then + if placement == "front" and positions == "z" then return 3 - elseif placement == 'back' and positions == 'z' then + elseif placement == "back" and positions == "z" then return -3 end return 0 @@ -69,13 +72,14 @@ local ARROW_ENTITY={ _stuckrechecktimer=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 spawn_item = function(self, pos) +local function spawn_item(self, pos) if not minetest.is_creative_enabled("") then local item = minetest.add_item(pos, "mcl_bows:arrow") item:set_velocity({x=0, y=0, z=0}) @@ -85,7 +89,7 @@ local spawn_item = function(self, pos) self.object:remove() end -local damage_particles = function(pos, is_critical) +local function damage_particles(pos, is_critical) if is_critical then minetest.add_particlespawner({ amount = 15, @@ -107,8 +111,8 @@ local damage_particles = function(pos, is_critical) end end -ARROW_ENTITY.on_step = function(self, dtime) - mcl_burning.tick(self.object, dtime) +function ARROW_ENTITY.on_step(self, dtime) + mcl_burning.tick(self.object, dtime, self) self._time_in_air = self._time_in_air + .001 @@ -117,16 +121,6 @@ ARROW_ENTITY.on_step = function(self, dtime) dpos = vector.round(dpos) local node = minetest.get_node(dpos) - if self.object:get_attach() ~= nil and self.object:get_attach(parent):get_hp() < 1 then - self.object:remove() - end - - minetest.register_on_leaveplayer(function(player) - if self.object:get_attach(parent) == player then - self.object:remove() - end - end) - if self._stuck then self._stucktimer = self._stucktimer + dtime self._stuckrechecktimer = self._stuckrechecktimer + dtime @@ -208,7 +202,7 @@ ARROW_ENTITY.on_step = function(self, dtime) -- Arrows can only damage players and mobs if obj:is_player() then ok = true - elseif obj:get_luaentity() ~= nil then + elseif obj:get_luaentity() then if (obj:get_luaentity()._cmi_is_mob or obj:get_luaentity()._hittable_by_projectile) then ok = true end @@ -228,7 +222,7 @@ ARROW_ENTITY.on_step = function(self, dtime) -- If an attackable object was found, we will damage the closest one only - if closest_object ~= nil then + if closest_object then local obj = closest_object local is_player = obj:is_player() local lua = obj:get_luaentity() @@ -254,9 +248,6 @@ ARROW_ENTITY.on_step = function(self, dtime) -- Punch target object but avoid hurting enderman. if not lua or lua.name ~= "mobs_mc:enderman" then - if obj:is_player() and rawget(_G, "armor") and armor.last_damage_types then - armor.last_damage_types[obj:get_player_name()] = "projectile" - end if self._in_player == false then damage_particles(self.object:get_pos(), self._is_critical) end @@ -269,12 +260,12 @@ ARROW_ENTITY.on_step = function(self, dtime) damage_groups={fleshy=self._damage}, }, self.object:get_velocity()) if obj:is_player() then - local placement = '' + local placement self._placement = math.random(1, 2) if self._placement == 1 then - placement = 'front' + placement = "front" else - placement = 'back' + placement = "back" end self._in_player = true if self._placement == 2 then @@ -282,25 +273,25 @@ ARROW_ENTITY.on_step = function(self, dtime) else self._rotation_station = -90 end - self._y_position = random_arrow_positions('y', placement) - self._x_position = random_arrow_positions('x', placement) + self._y_position = random_arrow_positions("y", placement) + self._x_position = random_arrow_positions("x", placement) if self._y_position > 6 and self._x_position < 2 and self._x_position > -2 then - self._attach_parent = 'Head' + self._attach_parent = "Head" self._y_position = self._y_position - 6 elseif self._x_position > 2 then - self._attach_parent = 'Arm_Right' + self._attach_parent = "Arm_Right" self._y_position = self._y_position - 3 self._x_position = self._x_position - 2 elseif self._x_position < -2 then - self._attach_parent = 'Arm_Left' + self._attach_parent = "Arm_Left" self._y_position = self._y_position - 3 self._x_position = self._x_position + 2 else - self._attach_parent = 'Body' + self._attach_parent = "Body" end self._z_rotation = math.random(-30, 30) self._y_rotation = math.random( -30, 30) - self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions('z', placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation}) + self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions("z", placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation}) minetest.after(150, function() self.object:remove() end) @@ -405,7 +396,7 @@ ARROW_ENTITY.on_step = function(self, dtime) if not v then v = 0 end - local old_v = self._viscosity + --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 @@ -432,13 +423,13 @@ end -- Force recheck of stuck arrows when punched. -- Otherwise, punching has no effect. -ARROW_ENTITY.on_punch = function(self) +function ARROW_ENTITY.on_punch(self) if self._stuck then self._stuckrechecktimer = STUCK_RECHECK_TIME end end -ARROW_ENTITY.get_staticdata = function(self) +function ARROW_ENTITY.get_staticdata(self) local out = { lastpos = self._lastpos, startpos = self._startpos, @@ -460,7 +451,7 @@ ARROW_ENTITY.get_staticdata = function(self) return minetest.serialize(out) end -ARROW_ENTITY.on_activate = function(self, staticdata, dtime_s) +function ARROW_ENTITY.on_activate(self, staticdata, dtime_s) self._time_in_air = 1.0 self._in_player = false local data = minetest.deserialize(staticdata) @@ -503,15 +494,15 @@ minetest.register_entity("mcl_bows:arrow_entity", ARROW_ENTITY) if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then minetest.register_craft({ - output = 'mcl_bows:arrow 4', + output = "mcl_bows:arrow 4", recipe = { - {'mcl_core:flint'}, - {'mcl_core:stick'}, - {'mcl_mobitems:feather'} + {"mcl_core:flint"}, + {"mcl_core:stick"}, + {"mcl_mobitems:feather"} } }) end -if minetest.get_modpath("doc_identifier") ~= nil then +if minetest.get_modpath("doc_identifier") then doc.sub.identifier.register_object("mcl_bows:arrow_entity", "craftitems", "mcl_bows:arrow") end diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index 45912384..23b6b431 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_bows") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_bows = {} @@ -33,7 +33,7 @@ local bow_load = {} -- Another player table, this one stores the wield index of the bow being charged local bow_index = {} -mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_stack, collectable) +function mcl_bows.shoot_arrow(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_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 @@ -59,13 +59,14 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag 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_bow_shoot", {pos=pos, max_hear_distance=16}, true) - if shooter ~= nil and shooter:is_player() then + if shooter and shooter:is_player() then if obj:get_luaentity().player == "" then obj:get_luaentity().player = shooter end @@ -74,7 +75,7 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag return obj end -local get_arrow = function(player) +local function get_arrow(player) local inv = player:get_inventory() local arrow_stack, arrow_stack_id for i=1, inv:get_size("main") do @@ -88,7 +89,7 @@ local get_arrow = function(player) return arrow_stack, arrow_stack_id end -local player_shoot_arrow = function(itemstack, player, power, damage, is_critical) +local function player_shoot_arrow(itemstack, player, power, damage, is_critical) local arrow_stack, arrow_stack_id = get_arrow(player) local arrow_itemstring local has_infinity_enchantment = mcl_enchanting.has_enchantment(player:get_wielded_item(), "infinity") @@ -161,7 +162,7 @@ S("The speed and damage of the arrow increases the longer you charge. The regula }) -- Iterates through player inventory and resets all the bows in "charging" state back to their original stage -local reset_bows = function(player) +local function reset_bows(player) local inv = player:get_inventory() local list = inv:get_list("main") for place, stack in pairs(list) do @@ -181,7 +182,7 @@ local reset_bows = function(player) end -- Resets the bow charging state and player speed. To be used when the player is no longer charging the bow -local reset_bow_state = function(player, also_reset_bows) +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 @@ -227,11 +228,10 @@ 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 inv = minetest.get_inventory({type="player", name=player:get_player_name()}) local wielditem = player:get_wielded_item() if (wielditem:get_name()=="mcl_bows:bow_0" or wielditem:get_name()=="mcl_bows:bow_1" or wielditem:get_name()=="mcl_bows:bow_2" or wielditem:get_name()=="mcl_bows:bow_0_enchanted" or wielditem:get_name()=="mcl_bows:bow_1_enchanted" or wielditem:get_name()=="mcl_bows:bow_2_enchanted") then - local has_shot = false local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name()) local speed, damage @@ -271,7 +271,7 @@ controls.register_on_release(function(player, key, time) damage = math.max(1, math.floor(9 * charge_ratio)) end - has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical) + local has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical) if enchanted then wielditem:set_name("mcl_bows:bow_enchanted") @@ -298,7 +298,7 @@ controls.register_on_hold(function(player, key, time) if key ~= "RMB" or not (creative or get_arrow(player)) then return end - local inv = minetest.get_inventory({type="player", name=name}) + --local inv = minetest.get_inventory({type="player", name=name}) local wielditem = player:get_wielded_item() if bow_load[name] == nil and (wielditem:get_name()=="mcl_bows:bow" or wielditem:get_name()=="mcl_bows:bow_enchanted") and wielditem:get_meta():get("active") and (creative or get_arrow(player)) then local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name()) @@ -345,7 +345,7 @@ minetest.register_globalstep(function(dtime) local name = player:get_player_name() local wielditem = player:get_wielded_item() local wieldindex = player:get_wield_index() - local controls = player:get_player_control() + --local controls = player:get_player_control() if type(bow_load[name]) == "number" and ((wielditem:get_name()~="mcl_bows:bow_0" and wielditem:get_name()~="mcl_bows:bow_1" and wielditem:get_name()~="mcl_bows:bow_2" and wielditem:get_name()~="mcl_bows:bow_0_enchanted" and wielditem:get_name()~="mcl_bows:bow_1_enchanted" and wielditem:get_name()~="mcl_bows:bow_2_enchanted") or wieldindex ~= bow_index[name]) then reset_bow_state(player, true) end @@ -362,19 +362,19 @@ end) if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then minetest.register_craft({ - output = 'mcl_bows:bow', + output = "mcl_bows:bow", recipe = { - {'', 'mcl_core:stick', 'mcl_mobitems:string'}, - {'mcl_core:stick', '', 'mcl_mobitems:string'}, - {'', 'mcl_core:stick', 'mcl_mobitems:string'}, + {"", "mcl_core:stick", "mcl_mobitems:string"}, + {"mcl_core:stick", "", "mcl_mobitems:string"}, + {"", "mcl_core:stick", "mcl_mobitems:string"}, } }) minetest.register_craft({ - output = 'mcl_bows:bow', + output = "mcl_bows:bow", recipe = { - {'mcl_mobitems:string', 'mcl_core:stick', ''}, - {'mcl_mobitems:string', '', 'mcl_core:stick'}, - {'mcl_mobitems:string', 'mcl_core:stick', ''}, + {"mcl_mobitems:string", "mcl_core:stick", ""}, + {"mcl_mobitems:string", "", "mcl_core:stick"}, + {"mcl_mobitems:string", "mcl_core:stick", ""}, } }) end diff --git a/mods/ITEMS/mcl_brewing/init.lua b/mods/ITEMS/mcl_brewing/init.lua index 78ccd8ed..bd44b429 100644 --- a/mods/ITEMS/mcl_brewing/init.lua +++ b/mods/ITEMS/mcl_brewing/init.lua @@ -1,11 +1,11 @@ -local S = minetest.get_translator("mcl_brewing") +local S = minetest.get_translator(minetest.get_current_modname()) local function active_brewing_formspec(fuel_percent, brew_percent) return "size[9,8.75]".. "background[-0.19,-0.25;9.5,9.5;mcl_brewing_inventory.png]".. - "label[4,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Brewing Stand"))).."]".. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[4,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Brewing Stand"))).."]".. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. "list[current_player;main;0,7.75;9,1;]".. @@ -35,8 +35,8 @@ end local brewing_formspec = "size[9,8.75]".. "background[-0.19,-0.25;9.5,9.5;mcl_brewing_inventory.png]".. - "label[4,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Brewing Stand"))).."]".. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[4,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Brewing Stand"))).."]".. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. "list[current_player;main;0,7.75;9,1;]".. @@ -61,14 +61,14 @@ local brewing_formspec = "size[9,8.75]".. "listring[context;stand]" -local function swap_node(pos, name) +--[[local function swap_node(pos, name) local node = minetest.get_node(pos) if node.name == name then return end node.name = name minetest.swap_node(pos, node) -end +end]] local function brewable(inv) @@ -110,12 +110,13 @@ local function brewing_stand_timer(pos, elapsed) local BREW_TIME = 20 -- all brews brew the same local BURN_TIME = BREW_TIME * 10 - local input_item = meta:get_string("input_item") or "" + --local input_item = meta:get_string("input_item") or "" local stand_timer = meta:get_float("stand_timer") or 0 local fuel = meta:get_float("fuel") or 0 local inv = meta:get_inventory() - local input_list, stand_list, fuel_list, brew_output, d + --local input_list, stand_list, fuel_list + local brew_output, d local input_count, fuel_name, fuel_count, formspec, fuel_percent, brew_percent local update = true @@ -124,9 +125,9 @@ local function brewing_stand_timer(pos, elapsed) update = false - input_list = inv:get_list("input") - stand_list = inv:get_list("stand") - fuel_list = inv:get_list("fuel") + --input_list = inv:get_list("input") + --stand_list = inv:get_list("stand") + --fuel_list = inv:get_list("fuel") -- TODO ... fix this. Goal is to reset the process if the stand changes -- for i=1, inv:get_size("stand", i) do -- reset the process due to change @@ -237,7 +238,7 @@ local function brewing_stand_timer(pos, elapsed) end -local function allow_metadata_inventory_put(pos, listname, index, stack, player) +--[[local function allow_metadata_inventory_put(pos, listname, index, stack, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -273,7 +274,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player) elseif listname == "stand" then return 0 end -end +end]] -- Drop input items of brewing_stand at pos with metadata meta @@ -315,14 +316,16 @@ local doc_string = S("When you have found a good combination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.").."\n".. S("Different combinations of brewing materials and liquids will give different results. Try to experiment!") -local tiles = {"mcl_brewing_top.png", --top - "mcl_brewing_base.png", --bottom - "mcl_brewing_side.png", --right - "mcl_brewing_side.png", --left - "mcl_brewing_side.png", --back - "mcl_brewing_side.png^[transformFX"} --front +local tiles = { + "mcl_brewing_top.png", --top + "mcl_brewing_base.png", --bottom + "mcl_brewing_side.png", --right + "mcl_brewing_side.png", --left + "mcl_brewing_side.png", --back + "mcl_brewing_side.png^[transformFX", --front +} -local allow_put = function(pos, listname, index, stack, player) +local function allow_put(pos, listname, index, stack, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -332,7 +335,7 @@ local allow_put = function(pos, listname, index, stack, player) end end -local on_put = function(pos, listname, index, stack, player) +local function on_put(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local str = "" @@ -349,18 +352,18 @@ local on_put = function(pos, listname, index, stack, player) --some code here to enforce only potions getting placed on stands end -local after_dig = function(pos, oldnode, oldmetadata, digger) +--[[local function after_dig(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) meta:from_table(oldmetadata) drop_brewing_stand_items(pos, meta) -end +end]] -local on_destruct = function(pos) +local function on_destruct(pos) local meta = minetest.get_meta(pos) drop_brewing_stand_items(pos, meta) end -local allow_take = function(pos, listname, index, stack, player) +local function allow_take(pos, listname, index, stack, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -490,7 +493,6 @@ minetest.register_node("mcl_brewing:stand_100", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -500,7 +502,6 @@ minetest.register_node("mcl_brewing:stand_100", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -508,10 +509,10 @@ minetest.register_node("mcl_brewing:stand_100", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_010", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -564,7 +565,6 @@ minetest.register_node("mcl_brewing:stand_010", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -574,7 +574,6 @@ minetest.register_node("mcl_brewing:stand_010", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -582,10 +581,10 @@ minetest.register_node("mcl_brewing:stand_010", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_001", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -602,7 +601,6 @@ minetest.register_node("mcl_brewing:stand_001", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -634,7 +632,6 @@ minetest.register_node("mcl_brewing:stand_001", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -644,7 +641,6 @@ minetest.register_node("mcl_brewing:stand_001", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -652,10 +648,10 @@ minetest.register_node("mcl_brewing:stand_001", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_110", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -672,7 +668,6 @@ minetest.register_node("mcl_brewing:stand_110", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -714,7 +709,6 @@ minetest.register_node("mcl_brewing:stand_110", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -724,7 +718,6 @@ minetest.register_node("mcl_brewing:stand_110", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -732,10 +725,10 @@ minetest.register_node("mcl_brewing:stand_110", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_101", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -752,7 +745,6 @@ minetest.register_node("mcl_brewing:stand_101", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -790,7 +782,6 @@ minetest.register_node("mcl_brewing:stand_101", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -800,7 +791,6 @@ minetest.register_node("mcl_brewing:stand_101", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -808,10 +798,10 @@ minetest.register_node("mcl_brewing:stand_101", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_011", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -828,7 +818,6 @@ minetest.register_node("mcl_brewing:stand_011", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -866,7 +855,6 @@ minetest.register_node("mcl_brewing:stand_011", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -876,7 +864,6 @@ minetest.register_node("mcl_brewing:stand_011", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -884,10 +871,10 @@ minetest.register_node("mcl_brewing:stand_011", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_111", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -904,7 +891,6 @@ minetest.register_node("mcl_brewing:stand_111", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -949,7 +935,6 @@ minetest.register_node("mcl_brewing:stand_111", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -959,7 +944,6 @@ minetest.register_node("mcl_brewing:stand_111", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -967,7 +951,6 @@ minetest.register_node("mcl_brewing:stand_111", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) diff --git a/mods/ITEMS/mcl_brewing/mod.conf b/mods/ITEMS/mcl_brewing/mod.conf index 160319c9..2c27c979 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, mcl_colors +depends = mcl_init, mcl_formspec, mcl_sounds, mcl_potions, mcl_mobitems optional_depends = mcl_core, doc, screwdriver diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 0ba68b72..90ccec63 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -1,8 +1,7 @@ -local S = minetest.get_translator("mcl_buckets") -local modpath = minetest.get_modpath(minetest.get_current_modname()) - --- Minetest 0.4 mod: bucket -- See README.txt for licensing and other information. +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) +local modpath = minetest.get_modpath(modname) minetest.register_alias("bucket:bucket_empty", "mcl_buckets:bucket_empty") minetest.register_alias("bucket:bucket_water", "mcl_buckets:bucket_water") @@ -10,14 +9,14 @@ minetest.register_alias("bucket:bucket_lava", "mcl_buckets:bucket_lava") 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") +--local mod_mclx_core = minetest.get_modpath("mclx_core") if mod_mcl_core then minetest.register_craft({ - output = 'mcl_buckets:bucket_empty 1', + output = "mcl_buckets:bucket_empty 1", recipe = { - {'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'}, - {'', 'mcl_core:iron_ingot', ''}, + {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, + {"", "mcl_core:iron_ingot", ""}, } }) end @@ -51,6 +50,7 @@ function mcl_buckets.register_liquid(def) mcl_buckets.liquids[def.source_take[i]] = { source_place = def.source_place, source_take = def.source_take[i], + on_take = def.on_take, itemname = def.itemname, } if type(def.source_place) == "string" then @@ -58,7 +58,7 @@ function mcl_buckets.register_liquid(def) end end - if def.itemname ~= nil then + if def.itemname then minetest.register_craftitem(def.itemname, { description = def.name, _doc_items_longdesc = def.longdesc, @@ -76,10 +76,11 @@ function mcl_buckets.register_liquid(def) 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 minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then - return minetest.registered_nodes[nn].on_rightclick(place_pos, node, user, itemstack) or itemstack + if nodedef and nodedef.on_rightclick then + return nodedef.on_rightclick(place_pos, node, user, itemstack) or itemstack end end @@ -90,11 +91,9 @@ function mcl_buckets.register_liquid(def) node_place = def.source_place end -- Check if pointing to a buildable node - local item = itemstack:get_name() + --local item = itemstack:get_name() - if def.extra_check and def.extra_check(place_pos, user) == false then - -- Fail placement of liquid - elseif minetest.registered_nodes[nn] and minetest.registered_nodes[nn].buildable_to then + if def.extra_check and def.extra_check(place_pos, user) == true and nodedef and nodedef.buildable_to then -- buildable; replace the node local pns = user:get_player_name() if minetest.is_protected(place_pos, pns) then @@ -147,12 +146,12 @@ function mcl_buckets.register_liquid(def) end end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) - local iname = stack:get_name() + --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 + --if def.extra_check and def.extra_check(droppos, nil) == false then -- Fail placement of liquid - elseif buildable then + 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 @@ -202,13 +201,13 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { -- Check if pointing to a liquid source local liquiddef = mcl_buckets.liquids[nn] local new_bucket - if liquiddef ~= nil and liquiddef.itemname ~= nil and (nn == liquiddef.source_take) then + 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.itemname == "mcl_buckets:bucket_lava" and awards and awards.unlock and user and user:is_player() then - awards.unlock(user:get_player_name(), "mcl:hotStuff") + if liquiddef.on_take then + liquiddef.on_take(user) end end @@ -260,7 +259,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { local liquiddef = mcl_buckets.liquids[dropnode.name] local new_bucket - if liquiddef ~= nil and liquiddef.itemname ~= nil and (dropnode.name == liquiddef.source_take) then + if liquiddef and liquiddef.itemname and (dropnode.name == liquiddef.source_take) then -- Fill bucket new_bucket = ItemStack({name = liquiddef.itemname}) sound_take(dropnode.name, droppos) diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index b5d86ac0..863aa074 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -1,6 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) 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 def = minetest.registered_nodes[itemname] @@ -9,12 +10,12 @@ local sound_place = function(itemname, pos) end end -local sound_take = function(itemname, pos) +--[[local sound_take = function(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 +end]] if mod_mcl_core then -- Lava bucket @@ -28,6 +29,11 @@ if mod_mcl_core then end end, source_take = {"mcl_core:lava_source", "mcl_nether:nether_lava_source"}, + on_take = function(user) + if has_awards and user and user:is_player() then + awards.unlock(user:get_player_name(), "mcl:hotStuff") + end + end, itemname = "mcl_buckets:bucket_lava", inventory_image = "bucket_lava.png", name = S("Lava Bucket"), @@ -49,7 +55,7 @@ if mod_mcl_core then extra_check = function(pos, placer) -- Check protection local placer_name = "" - if placer ~= nil then + if placer then placer_name = placer:get_player_name() end if placer and minetest.is_protected(pos, placer_name) then @@ -92,7 +98,7 @@ if mod_mclx_core then extra_check = function(pos, placer) -- Check protection local placer_name = "" - if placer ~= nil then + if placer then placer_name = placer:get_player_name() end if placer and minetest.is_protected(pos, placer_name) then diff --git a/mods/ITEMS/mcl_cake/init.lua b/mods/ITEMS/mcl_cake/init.lua index aeb70628..777b7ec5 100644 --- a/mods/ITEMS/mcl_cake/init.lua +++ b/mods/ITEMS/mcl_cake/init.lua @@ -5,7 +5,7 @@ local CAKE_HUNGER_POINTS = 2 -local S = minetest.get_translator("mcl_cake") +local S = minetest.get_translator(minetest.get_current_modname()) local cake_texture = {"cake_top.png","cake_bottom.png","cake_inner.png","cake_side.png","cake_side.png","cake_side.png"} local slice_1 = { -7/16, -8/16, -7/16, -5/16, 0/16, 7/16} @@ -20,9 +20,9 @@ local full_cake = { -7/16, -8/16, -7/16, 7/16, 0/16, 7/16} minetest.register_craft({ output = "mcl_cake:cake", recipe = { - {'mcl_mobitems:milk_bucket', 'mcl_mobitems:milk_bucket', 'mcl_mobitems:milk_bucket'}, - {'mcl_core:sugar', 'mcl_throwing:egg', 'mcl_core:sugar'}, - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, + {"mcl_mobitems:milk_bucket", "mcl_mobitems:milk_bucket", "mcl_mobitems:milk_bucket"}, + {"mcl_core:sugar", "mcl_throwing:egg", "mcl_core:sugar"}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, }, replacements = { {"mcl_mobitems:milk_bucket", "mcl_buckets:bucket_empty"}, @@ -53,7 +53,7 @@ minetest.register_node("mcl_cake:cake", { }, stack_max = 1, groups = {handy=1, cake=7, food=2,no_eat_delay=1, attached_node=1, dig_by_piston=1, comparator_signal=14}, - drop = '', + drop = "", on_rightclick = function(pos, node, clicker, itemstack) -- Cake is subject to protection local name = clicker:get_player_name() @@ -126,7 +126,7 @@ local register_slice = function(level, nodebox, desc) fixed = nodebox, }, groups = {handy=1, cake=level, food=2,no_eat_delay=1,attached_node=1,not_in_creative_inventory=1,dig_by_piston=1,comparator_signal=level*2}, - drop = '', + drop = "", on_rightclick = on_rightclick, sounds = mcl_sounds.node_sound_leaves_defaults(), diff --git a/mods/ITEMS/mcl_cauldrons/init.lua b/mods/ITEMS/mcl_cauldrons/init.lua index f4356d27..55866f5c 100644 --- a/mods/ITEMS/mcl_cauldrons/init.lua +++ b/mods/ITEMS/mcl_cauldrons/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_cauldron") +local S = minetest.get_translator(minetest.get_current_modname()) -- Cauldron mod, adds cauldrons. @@ -47,7 +47,7 @@ minetest.register_node("mcl_cauldrons:cauldron", { description = S("Cauldron"), _tt_help = S("Stores water"), _doc_items_longdesc = S("Cauldrons are used to store water and slowly fill up under rain."), - _doc_items_usagehelp = S("Place a water pucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water."), + _doc_items_usagehelp = S("Place a water bucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water."), wield_image = "mcl_cauldrons_cauldron.png", inventory_image = "mcl_cauldrons_cauldron.png", use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, diff --git a/mods/ITEMS/mcl_cauldrons/locale/mcl_cauldrons.de.tr b/mods/ITEMS/mcl_cauldrons/locale/mcl_cauldrons.de.tr index 72432b04..fe1d9aa8 100644 --- a/mods/ITEMS/mcl_cauldrons/locale/mcl_cauldrons.de.tr +++ b/mods/ITEMS/mcl_cauldrons/locale/mcl_cauldrons.de.tr @@ -1,7 +1,7 @@ # textdomain: mcl_cauldron Cauldron=Kessel -Cauldrons are used to store water and slowly fill up under rain.=Kessel werden benutzt, um Wasser zu lagern, im Regen werden sie langsam aufgefüllt. -Place a water pucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water.=Platzieren Sie einen Wassereinmer in den Kessel, um ihn mit Wasser zu füllen. Platzieren Sie einen leeren Eimer auf einen vollen Kessel, um das Wasser aufzusammeln. Platzieren Sie eine Wasserflasche in den Kessel, um ihn zu einem Drittel mit Wasser zu füllen. +Cauldrons are used to store water and slowly fill up under rain. They can also be used to wash off banners.=Kessel werden benutzt, um Wasser zu lagern, im Regen werden sie langsam aufgefüllt. Kessel können auch verwendet werden, um Banner abzuwaschen. +Place a water bucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water. Use an emblazoned banner on a cauldron with water to wash off its top layer.=Platzieren Sie einen Wassereinmer in den Kessel, um ihn mit Wasser zu füllen. Platzieren Sie einen leeren Eimer auf einen vollen Kessel, um das Wasser aufzusammeln. Platzieren Sie eine Wasserflasche in den Kessel, um ihn zu einem Drittel mit Wasser zu füllen. Benutzen Sie ein bemaltes Banner auf den Kessel, um die oberste Schicht abzuwaschen. Cauldron (1/3 Water)=Kessel (1/3 Wasser) Cauldron (2/3 Water)=Kessel (2/3 Wasser) Cauldron (3/3 Water)=Kessel (3/3 Wasser) diff --git a/mods/ITEMS/mcl_cauldrons/locale/mcl_cauldrons.es.tr b/mods/ITEMS/mcl_cauldrons/locale/mcl_cauldrons.es.tr index 5f7f9fc3..9748e61b 100644 --- a/mods/ITEMS/mcl_cauldrons/locale/mcl_cauldrons.es.tr +++ b/mods/ITEMS/mcl_cauldrons/locale/mcl_cauldrons.es.tr @@ -1,10 +1,10 @@ # textdomain: mcl_cauldron Cauldron=Caldera Cauldrons are used to store water and slowly fill up under rain.=Los calderos se usan para almacenar agua y llenarse lentamente bajo la lluvia. -Place a water pucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water.=Coloque un cubo de agua en el caldero para llenarlo con agua. Coloque un cubo vacío en un caldero lleno para recuperar el agua. Coloque una botella de agua en el caldero para llenar el caldero hasta un tercio con agua. Coloque una botella de vidrio en un caldero con agua para recuperar un tercio del agua. +Place a water bucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water.=Coloque un cubo de agua en el caldero para llenarlo con agua. Coloque un cubo vacío en un caldero lleno para recuperar el agua. Coloque una botella de agua en el caldero para llenar el caldero hasta un tercio con agua. Coloque una botella de vidrio en un caldero con agua para recuperar un tercio del agua. Cauldron (1/3 Water)=Caldera (1/3 de agua) Cauldron (2/3 Water)=Caldera (2/3 de agua) Cauldron (3/3 Water)=Caldera (3/3 de agua) Cauldron (1/3 River Water)=Caldera (1/3 de agua de río) Cauldron (2/3 River Water)=Caldera (2/3 de agua de río) -Cauldron (3/3 River Water)=Caldera (3/3 de agua de río) \ No newline at end of file +Cauldron (3/3 River Water)=Caldera (3/3 de agua de río) diff --git a/mods/ITEMS/mcl_cauldrons/locale/mcl_chaudrons.fr.tr b/mods/ITEMS/mcl_cauldrons/locale/mcl_chaudrons.fr.tr index 03b0e9be..a241c5cb 100644 --- a/mods/ITEMS/mcl_cauldrons/locale/mcl_chaudrons.fr.tr +++ b/mods/ITEMS/mcl_cauldrons/locale/mcl_chaudrons.fr.tr @@ -1,7 +1,7 @@ # textdomain: mcl_cauldron Cauldron=Chaudrons Cauldrons are used to store water and slowly fill up under rain. They can also be used to wash off banners.=Les chaudrons sont utilisés pour stocker l'eau et se remplissent lentement sous la pluie. Ils peuvent également être utilisés pour laver les bannières. -Place a water pucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water. Use an emblazoned banner on a cauldron with water to wash off its top layer.=Placez une marmite d'eau dans le chaudron pour le remplir d'eau. Placez un seau vide sur un chaudron plein pour récupérer l'eau. Placez une bouteille d'eau dans le chaudron pour remplir le chaudron au tiers avec de l'eau. Placez une bouteille en verre dans un chaudron avec de l'eau pour récupérer un tiers de l'eau. Utilisez une bannière blasonnée sur un chaudron avec de l'eau pour laver sa couche supérieure. +Place a water bucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water. Use an emblazoned banner on a cauldron with water to wash off its top layer.=Placez une marmite d'eau dans le chaudron pour le remplir d'eau. Placez un seau vide sur un chaudron plein pour récupérer l'eau. Placez une bouteille d'eau dans le chaudron pour remplir le chaudron au tiers avec de l'eau. Placez une bouteille en verre dans un chaudron avec de l'eau pour récupérer un tiers de l'eau. Utilisez une bannière blasonnée sur un chaudron avec de l'eau pour laver sa couche supérieure. Cauldron (1/3 Water)=Chaudron (1/3 d'eau) Cauldron (2/3 Water)=Chaudron (2/3 d'eau) Cauldron (3/3 Water)=Chaudron (3/3 d'eau) diff --git a/mods/ITEMS/mcl_cauldrons/locale/mcl_chaudrons.ru.tr b/mods/ITEMS/mcl_cauldrons/locale/mcl_chaudrons.ru.tr index ff43a577..6ecae102 100644 --- a/mods/ITEMS/mcl_cauldrons/locale/mcl_chaudrons.ru.tr +++ b/mods/ITEMS/mcl_cauldrons/locale/mcl_chaudrons.ru.tr @@ -1,7 +1,7 @@ # textdomain: mcl_cauldron Cauldron=Котёл Cauldrons are used to store water and slowly fill up under rain. They can also be used to wash off banners.=Котлы используются для хранения воды и медленного наполнения под дождём. Они также могут использоваться для промывания флагов. -Place a water pucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water. Use an emblazoned banner on a cauldron with water to wash off its top layer.=Попытайтесь поместить ведро воды в котёл, чтобы наполнить его водой. Попытка поместить пустое ведро приведёт к освобождению котла. Поместите в котёл бутылку воды, чтобы наполнить его на треть. +Place a water bucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water. Use an emblazoned banner on a cauldron with water to wash off its top layer.=Попытайтесь поместить ведро воды в котёл, чтобы наполнить его водой. Попытка поместить пустое ведро приведёт к освобождению котла. Поместите в котёл бутылку воды, чтобы наполнить его на треть. Cauldron (1/3 Water)=Котёл (1/3 воды) Cauldron (2/3 Water)=Котёл (2/3 воды) Cauldron (3/3 Water)=Котёл (3/3 воды) diff --git a/mods/ITEMS/mcl_cauldrons/locale/template.txt b/mods/ITEMS/mcl_cauldrons/locale/template.txt index b4385631..5e18f328 100644 --- a/mods/ITEMS/mcl_cauldrons/locale/template.txt +++ b/mods/ITEMS/mcl_cauldrons/locale/template.txt @@ -1,7 +1,7 @@ # textdomain: mcl_cauldron Cauldron= Cauldrons are used to store water and slowly fill up under rain. They can also be used to wash off banners.= -Place a water pucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water. Use an emblazoned banner on a cauldron with water to wash off its top layer.= +Place a water bucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water. Use an emblazoned banner on a cauldron with water to wash off its top layer.= Cauldron (1/3 Water)= Cauldron (2/3 Water)= Cauldron (3/3 Water)= diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index 1f3f518a..de8b9bd0 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_chests") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") -- Chest Entity @@ -47,7 +47,7 @@ minetest.register_entity("mcl_chests:chest", { local playerlist = self.players playerlist[playername] = nil if self.is_open then - for _ in pairs(playerlist) do + if next(playerlist) then return end self:set_animation("close") @@ -158,19 +158,20 @@ end --[[ List of open chests. Key: Player name Value: - If player is using a chest: { pos = } - Otherwise: nil ]] + If player is using a chest: { pos = } + Otherwise: nil ]] local open_chests = {} -local function back_is_blocked(pos, dir) +--[[local function back_is_blocked(pos, dir) pos = vector.add(pos, dir) local def = minetest.registered_nodes[minetest.get_node(pos).name] pos.y = pos.y + 1 local def2 = minetest.registered_nodes[minetest.get_node(pos).name] return not def or def.groups.opaque == 1 or not def2 or def2.groups.opaque == 1 -end +end]] + -- To be called if a player opened a chest -local player_chest_open = function(player, pos, node_name, textures, param2, double, sound, mesh, shulker) +local function player_chest_open(player, pos, node_name, textures, param2, double, sound, mesh, shulker) local name = player:get_player_name() open_chests[name] = {pos = pos, node_name = node_name, textures = textures, param2 = param2, double = double, sound = sound, mesh = mesh, shulker = shulker} if animate_chests then @@ -180,7 +181,7 @@ local player_chest_open = function(player, pos, node_name, textures, param2, dou end -- Simple protection checking functions -local protection_check_move = function(pos, from_list, from_index, to_list, to_index, count, player) +local function protection_check_move(pos, from_list, from_index, to_list, to_index, count, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -189,7 +190,7 @@ local protection_check_move = function(pos, from_list, from_index, to_list, to_i return count end end -local protection_check_put_take = function(pos, listname, index, stack, player) +local function protection_check_put_take(pos, listname, index, stack, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -202,7 +203,7 @@ end local trapped_chest_mesecons_rules = mesecon.rules.pplate -- To be called when a chest is closed (only relevant for trapped chest atm) -local chest_update_after_close = function(pos) +local function chest_update_after_close(pos) local node = minetest.get_node(pos) if node.name == "mcl_chests:trapped_chest_on_small" then @@ -229,7 +230,7 @@ local chest_update_after_close = function(pos) end -- To be called if a player closed a chest -local player_chest_close = function(player) +local function player_chest_close(player) local name = player:get_player_name() local open_chest = open_chests[name] if open_chest == nil then @@ -244,570 +245,569 @@ local player_chest_close = function(player) end -- This is a helper function to register both chests and trapped chests. Trapped chests will make use of the additional parameters -local register_chest = function(basename, desc, longdesc, usagehelp, tt_help, tiles_table, hidden, mesecons, on_rightclick_addendum, on_rightclick_addendum_left, on_rightclick_addendum_right, drop, canonical_basename) --- START OF register_chest FUNCTION BODY -if not drop then - drop = "mcl_chests:"..basename -else - drop = "mcl_chests:"..drop -end --- The basename of the "canonical" version of the node, if set (e.g.: trapped_chest_on → trapped_chest). --- Used to get a shared formspec ID and to swap the node back to the canonical version in on_construct. -if not canonical_basename then - canonical_basename = basename -end - -local double_chest_add_item = function(top_inv, bottom_inv, listname, stack) - if not stack or stack:is_empty() then - return +local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tiles_table, hidden, mesecons, on_rightclick_addendum, on_rightclick_addendum_left, on_rightclick_addendum_right, drop, canonical_basename) + -- START OF register_chest FUNCTION BODY + if not drop then + drop = "mcl_chests:"..basename + else + drop = "mcl_chests:"..drop + end + -- The basename of the "canonical" version of the node, if set (e.g.: trapped_chest_on → trapped_chest). + -- Used to get a shared formspec ID and to swap the node back to the canonical version in on_construct. + if not canonical_basename then + canonical_basename = basename end - local name = stack:get_name() + local function double_chest_add_item(top_inv, bottom_inv, listname, stack) + if not stack or stack:is_empty() then + return + end - local top_off = function(inv, stack) - for c, chest_stack in ipairs(inv:get_list(listname)) do + local name = stack:get_name() + + local function top_off(inv, stack) + for c, chest_stack in ipairs(inv:get_list(listname)) do + if stack:is_empty() then + break + end + + if chest_stack:get_name() == name and chest_stack:get_free_space() > 0 then + stack = chest_stack:add_item(stack) + inv:set_stack(listname, c, chest_stack) + end + end + + return stack + end + + stack = top_off(top_inv, stack) + stack = top_off(bottom_inv, stack) + + if not stack:is_empty() then + stack = top_inv:add_item(listname, stack) + if not stack:is_empty() then + bottom_inv:add_item(listname, stack) + end + end + end + + local function drop_items_chest(pos, oldnode, oldmetadata) + local meta = minetest.get_meta(pos) + local meta2 = meta + if oldmetadata then + meta:from_table(oldmetadata) + end + local inv = meta:get_inventory() + for i=1,inv:get_size("main") do + local stack = inv:get_stack("main", i) + if not stack:is_empty() then + local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} + minetest.add_item(p, stack) + end + end + meta:from_table(meta2:to_table()) + end + + local function on_chest_blast(pos) + local node = minetest.get_node(pos) + drop_items_chest(pos, node) + minetest.remove_node(pos) + end + + local function limit_put_list(stack, list) + for _, other in ipairs(list) do + stack = other:add_item(stack) if stack:is_empty() then break end - - if chest_stack:get_name() == name and chest_stack:get_free_space() > 0 then - stack = chest_stack:add_item(stack) - inv:set_stack(listname, c, chest_stack) - end end - return stack end - stack = top_off(top_inv, stack) - stack = top_off(bottom_inv, stack) + local function limit_put(stack, inv1, inv2) + local leftover = ItemStack(stack) + leftover = limit_put_list(leftover, inv1:get_list("main")) + leftover = limit_put_list(leftover, inv2:get_list("main")) + return stack:get_count() - leftover:get_count() + end - if not stack:is_empty() then - stack = top_inv:add_item(listname, stack) - if not stack:is_empty() then - bottom_inv:add_item(listname, stack) + local small_name = "mcl_chests:"..basename.."_small" + local small_textures = tiles_table.small + local left_name = "mcl_chests:"..basename.."_left" + local left_textures = tiles_table.double + + minetest.register_node("mcl_chests:"..basename, { + description = desc, + _tt_help = tt_help, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = usagehelp, + _doc_items_hidden = hidden, + drawtype = "mesh", + mesh = "mcl_chests_chest.obj", + tiles = small_textures, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + paramtype = "light", + paramtype2 = "facedir", + stack_max = 64, + sounds = mcl_sounds.node_sound_wood_defaults(), + groups = {deco_block=1}, + on_construct = function(pos, node) + local node = minetest.get_node(pos) + node.name = small_name + minetest.set_node(pos, node) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, + }) + + local function close_forms(canonical_basename, pos) + local players = minetest.get_connected_players() + for p=1, #players do + if vector.distance(players[p]:get_pos(), pos) <= 30 then + minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) + end end end -end -local drop_items_chest = function(pos, oldnode, oldmetadata) - local meta = minetest.get_meta(pos) - local meta2 = meta - if oldmetadata then - meta:from_table(oldmetadata) - end - local inv = meta:get_inventory() - for i=1,inv:get_size("main") do - local stack = inv:get_stack("main", i) - if not stack:is_empty() then - local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} - minetest.add_item(p, stack) - end - end - meta:from_table(meta2:to_table()) -end + minetest.register_node(small_name, { + description = desc, + _tt_help = tt_help, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = usagehelp, + _doc_items_hidden = hidden, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.4375, -0.5, -0.4375, 0.4375, 0.375, 0.4375}, + }, + tiles = {"mcl_chests_blank.png"}, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, + _chest_entity_textures = small_textures, + _chest_entity_sound = "default_chest", + _chest_entity_mesh = "mcl_chests_chest", + _chest_entity_animation_type = "chest", + paramtype = "light", + paramtype2 = "facedir", + stack_max = 64, + drop = drop, + groups = {handy=1,axey=1, container=2, deco_block=1, material_wood=1,flammable=-1,chest_entity=1, not_in_creative_inventory=1}, + is_ground_content = false, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_construct = function(pos) + local param2 = minetest.get_node(pos).param2 + local meta = minetest.get_meta(pos) + --[[ This is a workaround for Minetest issue 5894 + . + Apparently if we don't do this, large chests initially don't work when + placed at chunk borders, and some chests randomly don't work after + placing. ]] + -- FIXME: Remove this workaround when the bug has been fixed. + -- BEGIN OF WORKAROUND -- + meta:set_string("workaround", "ignore_me") + meta:set_string("workaround", nil) -- Done to keep metadata clean + -- END OF WORKAROUND -- + local inv = meta:get_inventory() + inv:set_size("main", 9*3) + --[[ The "input" list is *another* workaround (hahahaha!) around the fact that Minetest + does not support listrings to put items into an alternative list if the first one + happens to be full. See . + This list is a hidden input-only list and immediately puts items into the appropriate chest. + It is only used for listrings and hoppers. This workaround is not that bad because it only + requires a simple “inventory allows” check for large chests.]] + -- FIXME: Refactor the listrings as soon Minetest supports alternative listrings + -- BEGIN OF LISTRING WORKAROUND + inv:set_size("input", 1) + -- END OF LISTRING WORKAROUND + if minetest.get_node(mcl_util.get_double_container_neighbor_pos(pos, param2, "right")).name == "mcl_chests:"..canonical_basename.."_small" then + minetest.swap_node(pos, {name="mcl_chests:"..canonical_basename.."_right",param2=param2}) + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") + minetest.swap_node(p, { name = "mcl_chests:"..canonical_basename.."_left", param2 = param2 }) + create_entity(p, "mcl_chests:"..canonical_basename.."_left", left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") + elseif minetest.get_node(mcl_util.get_double_container_neighbor_pos(pos, param2, "left")).name == "mcl_chests:"..canonical_basename.."_small" then + minetest.swap_node(pos, {name="mcl_chests:"..canonical_basename.."_left",param2=param2}) + create_entity(pos, "mcl_chests:"..canonical_basename.."_left", left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") + minetest.swap_node(p, { name = "mcl_chests:"..canonical_basename.."_right", param2 = param2 }) + else + minetest.swap_node(pos, { name = "mcl_chests:"..canonical_basename.."_small", param2 = param2 }) + create_entity(pos, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") + end + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, + after_dig_node = drop_items_chest, + on_blast = on_chest_blast, + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, + allow_metadata_inventory_put = protection_check_put_take, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + -- BEGIN OF LISTRING WORKAROUND + if listname == "input" then + local inv = minetest.get_inventory({type="node", pos=pos}) + inv:add_item("main", stack) + end + -- END OF LISTRING WORKAROUND + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, + _mcl_blast_resistance = 2.5, + _mcl_hardness = 2.5, -local on_chest_blast = function(pos) - local node = minetest.get_node(pos) - drop_items_chest(pos, node) - minetest.remove_node(pos) -end + on_rightclick = function(pos, node, clicker) + if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].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") + if name == "" then + name = S("Chest") + end -local function limit_put_list(stack, list) - for _, other in ipairs(list) do - stack = other:add_item(stack) - if stack:is_empty() then - break - end - end - return stack -end + minetest.show_formspec(clicker:get_player_name(), + "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, + "size[9,8.75]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. + "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,0.5,9,3).. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. + "list[current_player;main;0,4.5;9,3;9]".. + mcl_formspec.get_itemslot_bg(0,4.5,9,3).. + "list[current_player;main;0,7.74;9,1;]".. + mcl_formspec.get_itemslot_bg(0,7.74,9,1).. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]".. + "listring[current_player;main]") -local function limit_put(stack, inv1, inv2) - local leftover = ItemStack(stack) - leftover = limit_put_list(leftover, inv1:get_list("main")) - leftover = limit_put_list(leftover, inv2:get_list("main")) - return stack:get_count() - leftover:get_count() -end + if on_rightclick_addendum then + on_rightclick_addendum(pos, node, clicker) + end -local small_name = "mcl_chests:"..basename.."_small" -local small_textures = tiles_table.small -local left_name = "mcl_chests:"..basename.."_left" -local left_textures = tiles_table.double + player_chest_open(clicker, pos, small_name, small_textures, node.param2, false, "default_chest", "mcl_chests_chest") + end, -minetest.register_node("mcl_chests:"..basename, { - description = desc, - _tt_help = tt_help, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, - _doc_items_hidden = hidden, - drawtype = "mesh", - mesh = "mcl_chests_chest.obj", - tiles = small_textures, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - paramtype = "light", - paramtype2 = "facedir", - stack_max = 64, - sounds = mcl_sounds.node_sound_wood_defaults(), - groups = {deco_block=1}, - on_construct = function(pos, node) - local node = minetest.get_node(pos) - node.name = small_name - minetest.set_node(pos, node) - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) - end, -}) + on_destruct = function(pos) + close_forms(canonical_basename, pos) + end, + mesecons = mesecons, + on_rotate = simple_rotate, + }) -local function close_forms(canonical_basename, pos) - local players = minetest.get_connected_players() - for p=1, #players do - if vector.distance(players[p]:get_pos(), pos) <= 30 then - minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) - end - end -end - -minetest.register_node(small_name, { - description = desc, - _tt_help = tt_help, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, - _doc_items_hidden = hidden, - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = {-0.4375, -0.5, -0.4375, 0.4375, 0.375, 0.4375}, - }, - tiles = {"mcl_chests_blank.png"}, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, - _chest_entity_textures = small_textures, - _chest_entity_sound = "default_chest", - _chest_entity_mesh = "mcl_chests_chest", - _chest_entity_animation_type = "chest", - paramtype = "light", - paramtype2 = "facedir", - stack_max = 64, - drop = drop, - groups = {handy=1,axey=1, container=2, deco_block=1, material_wood=1,flammable=-1,chest_entity=1, not_in_creative_inventory=1}, - is_ground_content = false, - sounds = mcl_sounds.node_sound_wood_defaults(), - on_construct = function(pos) - local param2 = minetest.get_node(pos).param2 - local meta = minetest.get_meta(pos) - --[[ This is a workaround for Minetest issue 5894 - . - Apparently if we don't do this, large chests initially don't work when - placed at chunk borders, and some chests randomly don't work after - placing. ]] - -- FIXME: Remove this workaround when the bug has been fixed. - -- BEGIN OF WORKAROUND -- - meta:set_string("workaround", "ignore_me") - meta:set_string("workaround", nil) -- Done to keep metadata clean - -- END OF WORKAROUND -- - local inv = meta:get_inventory() - inv:set_size("main", 9*3) - --[[ The "input" list is *another* workaround (hahahaha!) around the fact that Minetest - does not support listrings to put items into an alternative list if the first one - happens to be full. See . - This list is a hidden input-only list and immediately puts items into the appropriate chest. - It is only used for listrings and hoppers. This workaround is not that bad because it only - requires a simple “inventory allows” check for large chests.]] - -- FIXME: Refactor the listrings as soon Minetest supports alternative listrings - -- BEGIN OF LISTRING WORKAROUND - inv:set_size("input", 1) - -- END OF LISTRING WORKAROUND - if minetest.get_node(mcl_util.get_double_container_neighbor_pos(pos, param2, "right")).name == "mcl_chests:"..canonical_basename.."_small" then - minetest.swap_node(pos, {name="mcl_chests:"..canonical_basename.."_right",param2=param2}) - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") - minetest.swap_node(p, { name = "mcl_chests:"..canonical_basename.."_left", param2 = param2 }) - create_entity(p, "mcl_chests:"..canonical_basename.."_left", left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") - elseif minetest.get_node(mcl_util.get_double_container_neighbor_pos(pos, param2, "left")).name == "mcl_chests:"..canonical_basename.."_small" then - minetest.swap_node(pos, {name="mcl_chests:"..canonical_basename.."_left",param2=param2}) - create_entity(pos, "mcl_chests:"..canonical_basename.."_left", left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") + minetest.register_node(left_name, { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.4375, -0.5, -0.4375, 0.5, 0.375, 0.4375}, + }, + tiles = {"mcl_chests_blank.png"}, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, + _chest_entity_textures = left_textures, + _chest_entity_sound = "default_chest", + _chest_entity_mesh = "mcl_chests_chest", + _chest_entity_animation_type = "chest", + paramtype = "light", + paramtype2 = "facedir", + groups = {handy=1,axey=1, container=5,not_in_creative_inventory=1, material_wood=1,flammable=-1,chest_entity=1,double_chest=1}, + drop = drop, + is_ground_content = false, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_construct = function(pos) + local n = minetest.get_node(pos) + local param2 = n.param2 local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") - minetest.swap_node(p, { name = "mcl_chests:"..canonical_basename.."_right", param2 = param2 }) - else - minetest.swap_node(pos, { name = "mcl_chests:"..canonical_basename.."_small", param2 = param2 }) - create_entity(pos, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") - end - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) - end, - after_dig_node = drop_items_chest, - on_blast = on_chest_blast, - allow_metadata_inventory_move = protection_check_move, - allow_metadata_inventory_take = protection_check_put_take, - allow_metadata_inventory_put = protection_check_put_take, - on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - minetest.log("action", player:get_player_name().. - " moves stuff in chest at "..minetest.pos_to_string(pos)) - end, - on_metadata_inventory_put = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " moves stuff to chest at "..minetest.pos_to_string(pos)) - -- BEGIN OF LISTRING WORKAROUND - if listname == "input" then - local inv = minetest.get_inventory({type="node", pos=pos}) - inv:add_item("main", stack) - end - -- END OF LISTRING WORKAROUND - end, - on_metadata_inventory_take = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " takes stuff from chest at "..minetest.pos_to_string(pos)) - end, - _mcl_blast_resistance = 2.5, - _mcl_hardness = 2.5, + if not p or minetest.get_node(p).name ~= "mcl_chests:"..canonical_basename.."_right" then + n.name = "mcl_chests:"..canonical_basename.."_small" + minetest.swap_node(pos, n) + end + create_entity(pos, left_name, left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, + on_destruct = function(pos) + local n = minetest.get_node(pos) + if n.name == small_name then + return + end - on_rightclick = function(pos, node, clicker) - if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].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") - if name == "" then - name = S("Chest") - end + close_forms(canonical_basename, pos) - minetest.show_formspec(clicker:get_player_name(), - "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, - "size[9,8.75]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, name)).."]".. - "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,0.5,9,3).. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. - "list[current_player;main;0,4.5;9,3;9]".. - mcl_formspec.get_itemslot_bg(0,4.5,9,3).. - "list[current_player;main;0,7.74;9,1;]".. - mcl_formspec.get_itemslot_bg(0,7.74,9,1).. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]".. - "listring[current_player;main]") + local param2 = n.param2 + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") + if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_right" then + return + end + close_forms(canonical_basename, p) - if on_rightclick_addendum then - on_rightclick_addendum(pos, node, clicker) - end - - player_chest_open(clicker, pos, small_name, small_textures, node.param2, false, "default_chest", "mcl_chests_chest") - end, - - on_destruct = function(pos) - close_forms(canonical_basename, pos) - end, - mesecons = mesecons, - on_rotate = simple_rotate, -}) - -minetest.register_node(left_name, { - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = {-0.4375, -0.5, -0.4375, 0.5, 0.375, 0.4375}, - }, - tiles = {"mcl_chests_blank.png"}, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, - _chest_entity_textures = left_textures, - _chest_entity_sound = "default_chest", - _chest_entity_mesh = "mcl_chests_chest", - _chest_entity_animation_type = "chest", - paramtype = "light", - paramtype2 = "facedir", - groups = {handy=1,axey=1, container=5,not_in_creative_inventory=1, material_wood=1,flammable=-1,chest_entity=1,double_chest=1}, - drop = drop, - is_ground_content = false, - sounds = mcl_sounds.node_sound_wood_defaults(), - on_construct = function(pos) - local n = minetest.get_node(pos) - local param2 = n.param2 - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") - if not p or minetest.get_node(p).name ~= "mcl_chests:"..canonical_basename.."_right" then - n.name = "mcl_chests:"..canonical_basename.."_small" - minetest.swap_node(pos, n) - end - create_entity(pos, left_name, left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) - end, - on_destruct = function(pos) - local n = minetest.get_node(pos) - if n.name == small_name then - return - end - - close_forms(canonical_basename, pos) - - local param2 = n.param2 - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") - if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_right" then - return - end - close_forms(canonical_basename, p) - - minetest.swap_node(p, { name = small_name, param2 = param2 }) - create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") - end, - after_dig_node = drop_items_chest, - on_blast = on_chest_blast, - allow_metadata_inventory_move = protection_check_move, - allow_metadata_inventory_take = protection_check_put_take, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) - local name = player:get_player_name() - if minetest.is_protected(pos, name) then - minetest.record_protection_violation(pos, name) - return 0 - -- BEGIN OF LISTRING WORKAROUND - elseif listname == "input" then - local inv = minetest.get_inventory({type="node", pos=pos}) - local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "left") - local other_inv = minetest.get_inventory({type="node", pos=other_pos}) - return limit_put(stack, inv, other_inv) - --[[if inv:room_for_item("main", stack) then - return -1 - else - - if other_inv:room_for_item("main", stack) then + minetest.swap_node(p, { name = small_name, param2 = param2 }) + create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") + end, + after_dig_node = drop_items_chest, + on_blast = on_chest_blast, + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + -- BEGIN OF LISTRING WORKAROUND + elseif listname == "input" then + local inv = minetest.get_inventory({type="node", pos=pos}) + local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "left") + local other_inv = minetest.get_inventory({type="node", pos=other_pos}) + return limit_put(stack, inv, other_inv) + --[[if inv:room_for_item("main", stack) then return -1 else - return 0 - end - end]]-- - -- END OF LISTRING WORKAROUND - else - return stack:get_count() - end - end, - on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - minetest.log("action", player:get_player_name().. - " moves stuff in chest at "..minetest.pos_to_string(pos)) - end, - on_metadata_inventory_put = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " moves stuff to chest at "..minetest.pos_to_string(pos)) - -- BEGIN OF LISTRING WORKAROUND - if listname == "input" then - local inv = minetest.get_inventory({type="node", pos=pos}) - local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "left") - local other_inv = minetest.get_inventory({type="node", pos=other_pos}) - inv:set_stack("input", 1, nil) - - double_chest_add_item(inv, other_inv, "main", stack) - end - -- END OF LISTRING WORKAROUND - end, - on_metadata_inventory_take = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " takes stuff from chest at "..minetest.pos_to_string(pos)) - end, - _mcl_blast_resistance = 2.5, - _mcl_hardness = 2.5, - - 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 - end - - local name = minetest.get_meta(pos):get_string("name") - if name == "" then - name = minetest.get_meta(pos_other):get_string("name") - end - if name == "" then - name = S("Large Chest") - end - - minetest.show_formspec(clicker:get_player_name(), - "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, - "size[9,11.5]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, name)).."]".. - "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,0.5,9,3).. - "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,3.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,3.5,9,3).. - "label[0,7;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. - "list[current_player;main;0,7.5;9,3;9]".. - mcl_formspec.get_itemslot_bg(0,7.5,9,3).. - "list[current_player;main;0,10.75;9,1;]".. - mcl_formspec.get_itemslot_bg(0,10.75,9,1).. - -- BEGIN OF LISTRING WORKAROUND - "listring[current_player;main]".. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]".. - -- END OF LISTRING WORKAROUND - "listring[current_player;main]".. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]".. - "listring[current_player;main]".. - "listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]") - - if on_rightclick_addendum_left then - on_rightclick_addendum_left(pos, node, clicker) - end - - player_chest_open(clicker, pos, left_name, left_textures, node.param2, true, "default_chest", "mcl_chests_chest") - end, - mesecons = mesecons, - on_rotate = no_rotate, -}) - -minetest.register_node("mcl_chests:"..basename.."_right", { - drawtype = "nodebox", - paramtype = "light", - paramtype2 = "facedir", - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.4375, 0.4375, 0.375, 0.4375}, - }, - tiles = {"mcl_chests_blank.png"}, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, - groups = {handy=1,axey=1, container=6,not_in_creative_inventory=1, material_wood=1,flammable=-1,double_chest=2}, - drop = drop, - is_ground_content = false, - sounds = mcl_sounds.node_sound_wood_defaults(), - on_construct = function(pos) - local n = minetest.get_node(pos) - local param2 = n.param2 - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") - if not p or minetest.get_node(p).name ~= "mcl_chests:"..canonical_basename.."_left" then - n.name = "mcl_chests:"..canonical_basename.."_small" - minetest.swap_node(pos, n) - end - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) - end, - on_destruct = function(pos) - local n = minetest.get_node(pos) - if n.name == small_name then - return - end - - close_forms(canonical_basename, pos) - - local param2 = n.param2 - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") - if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_left" then - return - end - close_forms(canonical_basename, p) - - minetest.swap_node(p, { name = small_name, param2 = param2 }) - create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") - local meta = minetest.get_meta(pos) - end, - after_dig_node = drop_items_chest, - on_blast = on_chest_blast, - allow_metadata_inventory_move = protection_check_move, - allow_metadata_inventory_take = protection_check_put_take, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) - local name = player:get_player_name() - if minetest.is_protected(pos, name) then - minetest.record_protection_violation(pos, name) - return 0 - -- BEGIN OF LISTRING WORKAROUND - elseif listname == "input" then - local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") - local other_inv = minetest.get_inventory({type="node", pos=other_pos}) - local inv = minetest.get_inventory({type="node", pos=pos}) - --[[if other_inv:room_for_item("main", stack) then - return -1 + if other_inv:room_for_item("main", stack) then + return -1 + else + return 0 + end + end]]-- + -- END OF LISTRING WORKAROUND else - if inv:room_for_item("main", stack) then + return stack:get_count() + end + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + -- BEGIN OF LISTRING WORKAROUND + if listname == "input" then + local inv = minetest.get_inventory({type="node", pos=pos}) + local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "left") + local other_inv = minetest.get_inventory({type="node", pos=other_pos}) + + inv:set_stack("input", 1, nil) + + double_chest_add_item(inv, other_inv, "main", stack) + end + -- END OF LISTRING WORKAROUND + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, + _mcl_blast_resistance = 2.5, + _mcl_hardness = 2.5, + + 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 + end + + local name = minetest.get_meta(pos):get_string("name") + if name == "" then + name = minetest.get_meta(pos_other):get_string("name") + end + if name == "" then + name = S("Large Chest") + end + + minetest.show_formspec(clicker:get_player_name(), + "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, + "size[9,11.5]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. + "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,0.5,9,3).. + "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,3.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,3.5,9,3).. + "label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. + "list[current_player;main;0,7.5;9,3;9]".. + mcl_formspec.get_itemslot_bg(0,7.5,9,3).. + "list[current_player;main;0,10.75;9,1;]".. + mcl_formspec.get_itemslot_bg(0,10.75,9,1).. + -- BEGIN OF LISTRING WORKAROUND + "listring[current_player;main]".. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]".. + -- END OF LISTRING WORKAROUND + "listring[current_player;main]".. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]".. + "listring[current_player;main]".. + "listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]") + + if on_rightclick_addendum_left then + on_rightclick_addendum_left(pos, node, clicker) + end + + player_chest_open(clicker, pos, left_name, left_textures, node.param2, true, "default_chest", "mcl_chests_chest") + end, + mesecons = mesecons, + on_rotate = no_rotate, + }) + + minetest.register_node("mcl_chests:"..basename.."_right", { + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.4375, 0.4375, 0.375, 0.4375}, + }, + tiles = {"mcl_chests_blank.png"}, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, + groups = {handy=1,axey=1, container=6,not_in_creative_inventory=1, material_wood=1,flammable=-1,double_chest=2}, + drop = drop, + is_ground_content = false, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_construct = function(pos) + local n = minetest.get_node(pos) + local param2 = n.param2 + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") + if not p or minetest.get_node(p).name ~= "mcl_chests:"..canonical_basename.."_left" then + n.name = "mcl_chests:"..canonical_basename.."_small" + minetest.swap_node(pos, n) + end + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, + on_destruct = function(pos) + local n = minetest.get_node(pos) + if n.name == small_name then + return + end + + close_forms(canonical_basename, pos) + + local param2 = n.param2 + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") + if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_left" then + return + end + close_forms(canonical_basename, p) + + minetest.swap_node(p, { name = small_name, param2 = param2 }) + create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") + end, + after_dig_node = drop_items_chest, + on_blast = on_chest_blast, + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + -- BEGIN OF LISTRING WORKAROUND + elseif listname == "input" then + local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") + local other_inv = minetest.get_inventory({type="node", pos=other_pos}) + local inv = minetest.get_inventory({type="node", pos=pos}) + --[[if other_inv:room_for_item("main", stack) then return -1 else - return 0 - end - end--]] - return limit_put(stack, other_inv, inv) - -- END OF LISTRING WORKAROUND - else - return stack:get_count() - end - end, - on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - minetest.log("action", player:get_player_name().. - " moves stuff in chest at "..minetest.pos_to_string(pos)) - end, - on_metadata_inventory_put = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " moves stuff to chest at "..minetest.pos_to_string(pos)) - -- BEGIN OF LISTRING WORKAROUND - if listname == "input" then - local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") - local other_inv = minetest.get_inventory({type="node", pos=other_pos}) - local inv = minetest.get_inventory({type="node", pos=pos}) + if inv:room_for_item("main", stack) then + return -1 + else + return 0 + end + end--]] + return limit_put(stack, other_inv, inv) + -- END OF LISTRING WORKAROUND + else + return stack:get_count() + end + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + -- BEGIN OF LISTRING WORKAROUND + if listname == "input" then + local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") + local other_inv = minetest.get_inventory({type="node", pos=other_pos}) + local inv = minetest.get_inventory({type="node", pos=pos}) - inv:set_stack("input", 1, nil) + inv:set_stack("input", 1, nil) - double_chest_add_item(other_inv, inv, "main", stack) - end - -- END OF LISTRING WORKAROUND - end, - on_metadata_inventory_take = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " takes stuff from chest at "..minetest.pos_to_string(pos)) - end, - _mcl_blast_resistance = 2.5, - _mcl_hardness = 2.5, + double_chest_add_item(other_inv, inv, "main", stack) + end + -- END OF LISTRING WORKAROUND + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, + _mcl_blast_resistance = 2.5, + _mcl_hardness = 2.5, - on_rightclick = function(pos, node, clicker) - local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") - 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 - end + on_rightclick = function(pos, node, clicker) + local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") + 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 + end - local name = minetest.get_meta(pos_other):get_string("name") - if name == "" then - name = minetest.get_meta(pos):get_string("name") - end - if name == "" then - name = S("Large Chest") - end + local name = minetest.get_meta(pos_other):get_string("name") + if name == "" then + name = minetest.get_meta(pos):get_string("name") + end + if name == "" then + name = S("Large Chest") + end - minetest.show_formspec(clicker:get_player_name(), - "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, + minetest.show_formspec(clicker:get_player_name(), + "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, - "size[9,11.5]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, name)).."]".. - "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,0.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,0.5,9,3).. - "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,3.5,9,3).. - "label[0,7;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. - "list[current_player;main;0,7.5;9,3;9]".. - mcl_formspec.get_itemslot_bg(0,7.5,9,3).. - "list[current_player;main;0,10.75;9,1;]".. - mcl_formspec.get_itemslot_bg(0,10.75,9,1).. - -- BEGIN OF LISTRING WORKAROUND - "listring[current_player;main]".. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]".. - -- END OF LISTRING WORKAROUND - "listring[current_player;main]".. - "listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]".. - "listring[current_player;main]".. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]") + "size[9,11.5]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. + "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,0.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,0.5,9,3).. + "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,3.5,9,3).. + "label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. + "list[current_player;main;0,7.5;9,3;9]".. + mcl_formspec.get_itemslot_bg(0,7.5,9,3).. + "list[current_player;main;0,10.75;9,1;]".. + mcl_formspec.get_itemslot_bg(0,10.75,9,1).. + -- BEGIN OF LISTRING WORKAROUND + "listring[current_player;main]".. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]".. + -- END OF LISTRING WORKAROUND + "listring[current_player;main]".. + "listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]".. + "listring[current_player;main]".. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]") - if on_rightclick_addendum_right then - on_rightclick_addendum_right(pos, node, clicker) - end + if on_rightclick_addendum_right then + on_rightclick_addendum_right(pos, node, clicker) + end - player_chest_open(clicker, pos_other, left_name, left_textures, node.param2, true, "default_chest", "mcl_chests_chest") - end, - mesecons = mesecons, - on_rotate = no_rotate, -}) + player_chest_open(clicker, pos_other, left_name, left_textures, node.param2, true, "default_chest", "mcl_chests_chest") + end, + mesecons = mesecons, + on_rotate = no_rotate, + }) -if mod_doc then - doc.add_entry_alias("nodes", small_name, "nodes", "mcl_chests:"..basename.."_left") - doc.add_entry_alias("nodes", small_name, "nodes", "mcl_chests:"..basename.."_right") -end + if mod_doc then + doc.add_entry_alias("nodes", small_name, "nodes", "mcl_chests:"..basename.."_left") + doc.add_entry_alias("nodes", small_name, "nodes", "mcl_chests:"..basename.."_right") + end --- END OF register_chest FUNCTION BODY + -- END OF register_chest FUNCTION BODY end local chestusage = S("To access its inventory, rightclick it. When broken, the items will drop out.") @@ -898,7 +898,7 @@ register_chest("trapped_chest_on", "trapped_chest" ) -local function close_if_trapped_chest(pos, player) +--[[local function close_if_trapped_chest(pos, player) local node = minetest.get_node(pos) if node.name == "mcl_chests:trapped_chest_on_small" then @@ -928,7 +928,7 @@ local function close_if_trapped_chest(pos, player) player_chest_close(player) end -end +end]] -- Disable chest when it has been closed minetest.register_on_player_receive_fields(function(player, formname, fields) @@ -944,23 +944,23 @@ minetest.register_on_leaveplayer(function(player) end) minetest.register_craft({ - output = 'mcl_chests:chest', + output = "mcl_chests:chest", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'group:wood', '', 'group:wood'}, - {'group:wood', 'group:wood', 'group:wood'}, + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "", "group:wood"}, + {"group:wood", "group:wood", "group:wood"}, } }) minetest.register_craft({ - type = 'fuel', - recipe = 'mcl_chests:chest', + type = "fuel", + recipe = "mcl_chests:chest", burntime = 15 }) minetest.register_craft({ - type = 'fuel', - recipe = 'mcl_chests:trapped_chest', + type = "fuel", + recipe = "mcl_chests:trapped_chest", burntime = 15 }) @@ -986,10 +986,10 @@ minetest.register_node("mcl_chests:ender_chest", { }) local formspec_ender_chest = "size[9,8.75]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Ender Chest"))).."]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Ender Chest"))).."]".. "list[current_player;enderchest;0,0.5;9,3;]".. mcl_formspec.get_itemslot_bg(0,0.5,9,3).. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. "list[current_player;main;0,7.74;9,1;]".. @@ -1006,7 +1006,7 @@ minetest.register_node("mcl_chests:ender_chest_small", { drawtype = "nodebox", node_box = { type = "fixed", - fixed = {-0.4375, -0.5, -0.4375, 0.5, 0.375, 0.4375}, + fixed = {-0.4375, -0.5, -0.4375, 0.5, 0.375, 0.4375}, }, _chest_entity_textures = {"mcl_chests_ender.png"}, _chest_entity_sound = "mcl_chests_enderchest", @@ -1027,11 +1027,14 @@ minetest.register_node("mcl_chests:ender_chest_small", { sounds = mcl_sounds.node_sound_stone_defaults(), drop = "mcl_core:obsidian 8", on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", formspec_ender_chest) create_entity(pos, "mcl_chests:ender_chest_small", {"mcl_chests_ender.png"}, minetest.get_node(pos).param2, false, "mcl_chests_enderchest", "mcl_chests_chest", "chest") end, on_rightclick = function(pos, node, clicker) + if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 then + -- won't open if there is no space from the top + return false + end + minetest.show_formspec(clicker:get_player_name(), "mcl_chests:ender_chest_"..clicker:get_player_name(), formspec_ender_chest) player_chest_open(clicker, pos, "mcl_chests:ender_chest_small", {"mcl_chests_ender.png"}, node.param2, false, "mcl_chests_enderchest", "mcl_chests_chest") end, on_receive_fields = function(pos, formname, fields, sender) @@ -1051,11 +1054,11 @@ minetest.register_on_joinplayer(function(player) end) minetest.register_craft({ - output = 'mcl_chests:ender_chest', + output = "mcl_chests:ender_chest", recipe = { - {'mcl_core:obsidian', 'mcl_core:obsidian', 'mcl_core:obsidian'}, - {'mcl_core:obsidian', 'mcl_end:ender_eye', 'mcl_core:obsidian'}, - {'mcl_core:obsidian', 'mcl_core:obsidian', 'mcl_core:obsidian'}, + {"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"}, + {"mcl_core:obsidian", "mcl_end:ender_eye", "mcl_core:obsidian"}, + {"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"}, } }) @@ -1104,10 +1107,10 @@ local function formspec_shulker_box(name) name = S("Shulker Box") end return "size[9,8.75]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, name)).."]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. "list[current_name;main;0,0.5;9,3;]".. mcl_formspec.get_itemslot_bg(0,0.5,9,3).. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. "list[current_player;main;0,7.74;9,1;]".. @@ -1311,23 +1314,22 @@ for color, desc in pairs(boxtypes) do minetest.register_craft({ type = "shapeless", - output = 'mcl_chests:'..color..'_shulker_box', - recipe = { 'group:shulker_box', 'mcl_dye:'..color } + output = "mcl_chests:"..color.."_shulker_box", + recipe = { "group:shulker_box", "mcl_dye:"..color } }) end minetest.register_craft({ - output = 'mcl_chests:violet_shulker_box', + output = "mcl_chests:violet_shulker_box", recipe = { - {'mcl_mobitems:shulker_shell'}, - {'mcl_chests:chest'}, - {'mcl_mobitems:shulker_shell'}, + {"mcl_mobitems:shulker_shell"}, + {"mcl_chests:chest"}, + {"mcl_mobitems:shulker_shell"}, } }) -- Save metadata of shulker box when used in crafting minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) - local new = itemstack:get_name() if minetest.get_item_group(itemstack:get_name(), "shulker_box") ~= 1 then return end @@ -1406,3 +1408,13 @@ minetest.register_lbm({ meta:set_string("formspec", formspec_shulker_box) end, }) + +minetest.register_lbm({ + label = "Upgrade old ender chest formspec", + name = "mcl_chests:replace_old_ender_form", + nodenames = {"mcl_chests:ender_chest_small"}, + run_at_every_load = false, + action = function(pos, node) + minetest.get_meta(pos):set_string("formspec", "") + end, +}) diff --git a/mods/ITEMS/mcl_chests/locale/template.txt b/mods/ITEMS/mcl_chests/locale/template.txt index d680c24c..1d947184 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. Place the shulker box again to be able to retrieve its contents.= +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.= Shulker Box= Large Chest= Inventory= diff --git a/mods/ITEMS/mcl_chests/mod.conf b/mods/ITEMS/mcl_chests/mod.conf index 609b1fff..0ff5129c 100644 --- a/mods/ITEMS/mcl_chests/mod.conf +++ b/mods/ITEMS/mcl_chests/mod.conf @@ -1,3 +1,3 @@ name = mcl_chests -depends = mcl_init, mcl_formspec, mcl_core, mcl_sounds, mcl_end, mesecons, mcl_colors +depends = mcl_init, mcl_formspec, mcl_core, mcl_sounds, mcl_end, mesecons optional_depends = doc, screwdriver diff --git a/mods/ITEMS/mcl_clock/init.lua b/mods/ITEMS/mcl_clock/init.lua index d53d7507..65b32b91 100644 --- a/mods/ITEMS/mcl_clock/init.lua +++ b/mods/ITEMS/mcl_clock/init.lua @@ -1,7 +1,7 @@ -local S = minetest.get_translator("mcl_clock") +local S = minetest.get_translator(minetest.get_current_modname()) --[[ - mcl_clock, renew of the renew of the watch mod + mcl_clock, renew of the renew of the mcl_clock mod Original from Echo, here: http://forum.minetest.net/viewtopic.php?id=3795 ]]-- @@ -11,8 +11,7 @@ mcl_clock = {} -- This is the itemstring of the default clock item. It is used for the default inventory image, help entries, and the like mcl_clock.stereotype = "mcl_clock:clock" -local watch = {} -watch.old_time = -1 +mcl_clock.old_time = -1 local clock_frames = 64 @@ -22,30 +21,30 @@ local random_timer_trigger = 1.0 -- random clock spinning tick in seconds. Incre local random_frame = math.random(0, clock_frames-1) -- Image of all possible faces -watch.images = {} +mcl_clock.images = {} for frame=0, clock_frames-1 do local sframe = tostring(frame) if string.len(sframe) == 1 then sframe = "0" .. sframe end - table.insert(watch.images, "mcl_clock_clock_"..sframe..".png") + table.insert(mcl_clock.images, "mcl_clock_clock_"..sframe..".png") end local function round(num) return math.floor(num + 0.5) end -function watch.get_clock_frame() +function mcl_clock.get_clock_frame() local t = clock_frames * minetest.get_timeofday() t = round(t) if t == clock_frames then t = 0 end return tostring(t) end -local doc_mod = minetest.get_modpath("doc") ~= nil +local doc_mod = minetest.get_modpath("doc") -- Register items -function watch.register_item(name, image, creative, frame) +function mcl_clock.register_item(name, image, creative, frame) local g = 1 if creative then g = 0 @@ -78,7 +77,7 @@ end local force_clock_update_timer = 0 minetest.register_globalstep(function(dtime) - local now = watch.get_clock_frame() + local now = mcl_clock.get_clock_frame() force_clock_update_timer = force_clock_update_timer + dtime random_timer = random_timer + dtime -- This causes the random spinning of the clock @@ -87,16 +86,16 @@ minetest.register_globalstep(function(dtime) random_timer = 0 end - if watch.old_time == now and force_clock_update_timer < 60 then + if mcl_clock.old_time == now and force_clock_update_timer < 60 then return end force_clock_update_timer = 0 - watch.old_time = now + mcl_clock.old_time = now + mcl_clock.random_frame = random_frame for p, player in pairs(minetest.get_connected_players()) do for s, stack in pairs(player:get_inventory():get_list("main")) do - local dim = mcl_worlds.pos_to_dimension(player:get_pos()) local frame -- Clocks do not work in certain zones if not mcl_worlds.clock_works(player:get_pos()) then @@ -104,6 +103,7 @@ minetest.register_globalstep(function(dtime) else frame = now end + local count = stack:get_count() if stack:get_name() == mcl_clock.stereotype then player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..frame.." "..count) @@ -117,7 +117,7 @@ end) -- Immediately set correct clock time after crafting minetest.register_on_craft(function(itemstack) if itemstack:get_name() == mcl_clock.stereotype then - itemstack:set_name("mcl_clock:clock_"..watch.get_clock_frame()) + itemstack:set_name("mcl_clock:clock_"..mcl_clock.get_clock_frame()) end end) @@ -125,14 +125,14 @@ end) minetest.register_craft({ output = mcl_clock.stereotype, recipe = { - {'', 'mcl_core:gold_ingot', ''}, - {'mcl_core:gold_ingot', 'mesecons:redstone', 'mcl_core:gold_ingot'}, - {'', 'mcl_core:gold_ingot', ''} + {"", "mcl_core:gold_ingot", ""}, + {"mcl_core:gold_ingot", "mesecons:redstone", "mcl_core:gold_ingot"}, + {"", "mcl_core:gold_ingot", ""} } }) -- Clock tool -watch.register_item(mcl_clock.stereotype, watch.images[1], true, 1) +mcl_clock.register_item(mcl_clock.stereotype, mcl_clock.images[1], true, 1) -- Faces for a=0,clock_frames-1,1 do @@ -142,6 +142,6 @@ for a=0,clock_frames-1,1 do else b = b + 32 end - watch.register_item("mcl_clock:clock_"..tostring(a), watch.images[b+1], false, a+1) + mcl_clock.register_item("mcl_clock:clock_"..tostring(a), mcl_clock.images[b+1], false, a+1) end diff --git a/mods/ITEMS/mcl_cocoas/init.lua b/mods/ITEMS/mcl_cocoas/init.lua index f19f8515..60ea9e57 100644 --- a/mods/ITEMS/mcl_cocoas/init.lua +++ b/mods/ITEMS/mcl_cocoas/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_cocoas") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_cocoas = {} diff --git a/mods/ITEMS/mcl_colorblocks/init.lua b/mods/ITEMS/mcl_colorblocks/init.lua index 4981b39b..6eec8a9d 100644 --- a/mods/ITEMS/mcl_colorblocks/init.lua +++ b/mods/ITEMS/mcl_colorblocks/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_colorblocks") +local S = minetest.get_translator(minetest.get_current_modname()) local doc_mod = minetest.get_modpath("doc") local block = {} @@ -173,20 +173,20 @@ for _, row in ipairs(block.dyes) do -- Crafting recipes if craft_color_group then minetest.register_craft({ - output = 'mcl_colorblocks:hardened_clay_'..name..' 8', + output = "mcl_colorblocks:hardened_clay_"..name.." 8", recipe = { - {'mcl_colorblocks:hardened_clay', 'mcl_colorblocks:hardened_clay', 'mcl_colorblocks:hardened_clay'}, - {'mcl_colorblocks:hardened_clay', 'mcl_dye:'..craft_color_group, 'mcl_colorblocks:hardened_clay'}, - {'mcl_colorblocks:hardened_clay', 'mcl_colorblocks:hardened_clay', 'mcl_colorblocks:hardened_clay'}, + {"mcl_colorblocks:hardened_clay", "mcl_colorblocks:hardened_clay", "mcl_colorblocks:hardened_clay"}, + {"mcl_colorblocks:hardened_clay", "mcl_dye:"..craft_color_group, "mcl_colorblocks:hardened_clay"}, + {"mcl_colorblocks:hardened_clay", "mcl_colorblocks:hardened_clay", "mcl_colorblocks:hardened_clay"}, }, }) minetest.register_craft({ type = "shapeless", - output = 'mcl_colorblocks:concrete_powder_'..name..' 8', + output = "mcl_colorblocks:concrete_powder_"..name.." 8", recipe = { - 'mcl_core:sand', 'mcl_core:gravel', 'mcl_core:sand', - 'mcl_core:gravel', 'mcl_dye:'..craft_color_group, 'mcl_core:gravel', - 'mcl_core:sand', 'mcl_core:gravel', 'mcl_core:sand', + "mcl_core:sand", "mcl_core:gravel", "mcl_core:sand", + "mcl_core:gravel", "mcl_dye:"..craft_color_group, "mcl_core:gravel", + "mcl_core:sand", "mcl_core:gravel", "mcl_core:sand", } }) diff --git a/mods/ITEMS/mcl_compass/init.lua b/mods/ITEMS/mcl_compass/init.lua index f1545930..458ee8fd 100644 --- a/mods/ITEMS/mcl_compass/init.lua +++ b/mods/ITEMS/mcl_compass/init.lua @@ -1,10 +1,11 @@ -local S = minetest.get_translator("mcl_compass") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_compass = {} local compass_frames = 32 -local default_spawn_settings = minetest.settings:get("static_spawnpoint") +--Not sure spawn point should be dymanic (is it in mc?) +--local default_spawn_settings = minetest.settings:get("static_spawnpoint") -- Timer for random compass spinning local random_timer = 0 @@ -12,6 +13,27 @@ local random_timer_trigger = 0.5 -- random compass spinning tick in seconds. Inc local random_frame = math.random(0, compass_frames-1) +function mcl_compass.get_compass_image(pos, dir) + -- Compasses do not work in certain zones + if mcl_worlds.compass_works(pos) then + local spawn = {x=0,y=0,z=0} + local ssp = minetest.setting_get_pos("static_spawnpoint") + if ssp then + spawn = ssp + if type(spawn) ~= "table" or type(spawn.x) ~= "number" or type(spawn.y) ~= "number" or type(spawn.z) ~= "number" then + spawn = {x=0,y=0,z=0} + end + end + local angle_north = math.deg(math.atan2(spawn.x - pos.x, spawn.z - pos.z)) + if angle_north < 0 then angle_north = angle_north + 360 end + local angle_dir = -math.deg(dir) + local angle_relative = (angle_north - angle_dir + 180) % 360 + return math.floor((angle_relative/11.25) + 0.5) % compass_frames + else + return random_frame + end +end + minetest.register_globalstep(function(dtime) random_timer = random_timer + dtime @@ -30,27 +52,7 @@ minetest.register_globalstep(function(dtime) end if has_compass(player) then local pos = player:get_pos() - local dim = mcl_worlds.pos_to_dimension(pos) - local compass_image - -- Compasses do not work in certain zones - if not mcl_worlds.compass_works(pos) then - compass_image = random_frame - else - local spawn = {x=0,y=0,z=0} - local ssp = minetest.setting_get_pos("static_spawnpoint") - if ssp then - spawn = ssp - if type(spawn) ~= "table" or type(spawn.x) ~= "number" or type(spawn.y) ~= "number" or type(spawn.z) ~= "number" then - spawn = {x=0,y=0,z=0} - end - end - local dir = player:get_look_horizontal() - local angle_north = math.deg(math.atan2(spawn.x - pos.x, spawn.z - pos.z)) - if angle_north < 0 then angle_north = angle_north + 360 end - local angle_dir = -math.deg(dir) - local angle_relative = (angle_north - angle_dir + 180) % 360 - compass_image = math.floor((angle_relative/11.25) + 0.5) % compass_frames - end + local compass_image = mcl_compass.get_compass_image(pos, player:get_look_horizontal()) for j,stack in pairs(player:get_inventory():get_list("main")) do if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and @@ -70,7 +72,7 @@ for frame = 0, compass_frames-1 do table.insert(images, "mcl_compass_compass_"..s..".png") end -local doc_mod = minetest.get_modpath("doc") ~= nil +local doc_mod = minetest.get_modpath("doc") local stereotype_frame = 18 for i,img in ipairs(images) do @@ -78,7 +80,9 @@ for i,img in ipairs(images) do if i == stereotype_frame then inv = 0 end - local use_doc, longdesc, usagehelp, tt + local use_doc, longdesc, tt + --Why is there no usage help? This should be fixed. + --local usagehelp use_doc = i == stereotype_frame if use_doc then tt = S("Points to the world origin") @@ -90,7 +94,7 @@ for i,img in ipairs(images) do _tt_help = tt, _doc_items_create_entry = use_doc, _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, + --_doc_items_usagehelp = usagehelp, inventory_image = img, wield_image = img, stack_max = 64, @@ -104,11 +108,11 @@ for i,img in ipairs(images) do end minetest.register_craft({ - output = 'mcl_compass:'..stereotype_frame, + output = "mcl_compass:"..stereotype_frame, recipe = { - {'', 'mcl_core:iron_ingot', ''}, - {'mcl_core:iron_ingot', 'mesecons:redstone', 'mcl_core:iron_ingot'}, - {'', 'mcl_core:iron_ingot', ''} + {"", "mcl_core:iron_ingot", ""}, + {"mcl_core:iron_ingot", "mesecons:redstone", "mcl_core:iron_ingot"}, + {"", "mcl_core:iron_ingot", ""} } }) diff --git a/mods/ITEMS/mcl_compass/locale/mcl_compass.de.tr b/mods/ITEMS/mcl_compass/locale/mcl_compass.de.tr index a78b70c0..cf4c814c 100644 --- a/mods/ITEMS/mcl_compass/locale/mcl_compass.de.tr +++ b/mods/ITEMS/mcl_compass/locale/mcl_compass.de.tr @@ -1,4 +1,4 @@ # textdomain: mcl_compass -Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Kompasse sind Werkzeuge, die zum Ursprungspunkt der Welt (X@=0, Z@=0) oder den Einstiegspunkt der Welt zeigen. +Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Kompasse sind Werkzeuge, die zum Ursprungspunkt der Welt (X@=0, Z@=0) oder zum Einstiegspunkt der Welt zeigen. Compass=Kompass Points to the world origin=Zeigt zum Startpunkt der Welt diff --git a/mods/ITEMS/mcl_core/crafting.lua b/mods/ITEMS/mcl_core/crafting.lua index 7a2b6a5c..3ff2b142 100644 --- a/mods/ITEMS/mcl_core/crafting.lua +++ b/mods/ITEMS/mcl_core/crafting.lua @@ -4,189 +4,122 @@ -- Crafting definition -- +local function craft_planks(output, input) + minetest.register_craft({ + output = "mcl_core:"..output.."wood 4", + recipe = { + {"mcl_core:"..input}, + } + }) +end + +local planks = { + {"", "oak"}, + {"dark", "dark_oak"}, + {"jungle", "jungle"}, + {"acacia", "acacia"}, + {"spruce", "spruce"}, + {"birch", "birch"} +} + +for _, p in pairs(planks) do + craft_planks(p[1], p[1].."tree") + craft_planks(p[1], p[1].."tree_bark") + craft_planks(p[1], "stripped_"..p[2]) + craft_planks(p[1], "stripped_"..p[2].."_bark") +end + minetest.register_craft({ - output = 'mcl_core:wood 4', + type = "shapeless", + output = "mcl_core:mossycobble", + recipe = { "mcl_core:cobble", "mcl_core:vine" }, +}) + +minetest.register_craft({ + type = "shapeless", + output = "mcl_core:stonebrickmossy", + recipe = { "mcl_core:stonebrick", "mcl_core:vine" }, +}) + +minetest.register_craft({ + output = "mcl_core:coarse_dirt 4", recipe = { - {'mcl_core:tree'}, + {"mcl_core:dirt", "mcl_core:gravel"}, + {"mcl_core:gravel", "mcl_core:dirt"}, + } +}) +minetest.register_craft({ + output = "mcl_core:coarse_dirt 4", + recipe = { + {"mcl_core:gravel", "mcl_core:dirt"}, + {"mcl_core:dirt", "mcl_core:gravel"}, } }) minetest.register_craft({ - output = 'mcl_core:darkwood 4', + output = "mcl_core:sandstonesmooth 4", recipe = { - {'mcl_core:darktree'}, + {"mcl_core:sandstone","mcl_core:sandstone"}, + {"mcl_core:sandstone","mcl_core:sandstone"}, } }) minetest.register_craft({ - output = 'mcl_core:junglewood 4', + output = "mcl_core:redsandstonesmooth 4", recipe = { - {'mcl_core:jungletree'}, + {"mcl_core:redsandstone","mcl_core:redsandstone"}, + {"mcl_core:redsandstone","mcl_core:redsandstone"}, } }) minetest.register_craft({ - output = 'mcl_core:acaciawood 4', + output = "mcl_core:granite_smooth 4", recipe = { - {'mcl_core:acaciatree'}, - } -}) - -minetest.register_craft({ - output = 'mcl_core:sprucewood 4', - recipe = { - {'mcl_core:sprucetree'}, - } -}) - -minetest.register_craft({ - output = 'mcl_core:birchwood 4', - recipe = { - {'mcl_core:birchtree'}, - } -}) - --- Stripped Bark -minetest.register_craft({ - output = "mcl_core:stripped_oak_bark 3", - recipe = { - { "mcl_core:stripped_oak", "mcl_core:stripped_oak" }, - { "mcl_core:stripped_oak", "mcl_core:stripped_oak" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_acacia_bark 3", - recipe = { - { "mcl_core:stripped_acacia", "mcl_core:stripped_acacia" }, - { "mcl_core:stripped_acacia", "mcl_core:stripped_acacia" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_dark_oak_bark 3", - recipe = { - { "mcl_core:stripped_dark_oak", "mcl_core:stripped_dark_oak" }, - { "mcl_core:stripped_dark_oak", "mcl_core:stripped_dark_oak" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_birch_bark 3", - recipe = { - { "mcl_core:stripped_birch", "mcl_core:stripped_birch" }, - { "mcl_core:stripped_birch", "mcl_core:stripped_birch" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_spruce_bark 3", - recipe = { - { "mcl_core:stripped_spruce", "mcl_core:stripped_spruce" }, - { "mcl_core:stripped_spruce", "mcl_core:stripped_spruce" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_jungle_bark 3", - recipe = { - { "mcl_core:stripped_jungle", "mcl_core:stripped_jungle" }, - { "mcl_core:stripped_jungle", "mcl_core:stripped_jungle" }, - } -}) - - -minetest.register_craft({ - type = 'shapeless', - output = 'mcl_core:mossycobble', - recipe = { 'mcl_core:cobble', 'mcl_core:vine' }, -}) - -minetest.register_craft({ - type = 'shapeless', - output = 'mcl_core:stonebrickmossy', - recipe = { 'mcl_core:stonebrick', 'mcl_core:vine' }, -}) - -minetest.register_craft({ - output = 'mcl_core:coarse_dirt 4', - recipe = { - {'mcl_core:dirt', 'mcl_core:gravel'}, - {'mcl_core:gravel', 'mcl_core:dirt'}, - } -}) -minetest.register_craft({ - output = 'mcl_core:coarse_dirt 4', - recipe = { - {'mcl_core:gravel', 'mcl_core:dirt'}, - {'mcl_core:dirt', 'mcl_core:gravel'}, - } -}) - -minetest.register_craft({ - output = 'mcl_core:sandstonesmooth 4', - recipe = { - {'mcl_core:sandstone','mcl_core:sandstone'}, - {'mcl_core:sandstone','mcl_core:sandstone'}, - } -}) - -minetest.register_craft({ - output = 'mcl_core:redsandstonesmooth 4', - recipe = { - {'mcl_core:redsandstone','mcl_core:redsandstone'}, - {'mcl_core:redsandstone','mcl_core:redsandstone'}, - } -}) - -minetest.register_craft({ - output = 'mcl_core:granite_smooth 4', - recipe = { - {'mcl_core:granite', 'mcl_core:granite'}, - {'mcl_core:granite', 'mcl_core:granite'} + {"mcl_core:granite", "mcl_core:granite"}, + {"mcl_core:granite", "mcl_core:granite"} }, }) minetest.register_craft({ - output = 'mcl_core:andesite_smooth 4', + output = "mcl_core:andesite_smooth 4", recipe = { - {'mcl_core:andesite', 'mcl_core:andesite'}, - {'mcl_core:andesite', 'mcl_core:andesite'} + {"mcl_core:andesite", "mcl_core:andesite"}, + {"mcl_core:andesite", "mcl_core:andesite"} }, }) minetest.register_craft({ - output = 'mcl_core:diorite_smooth 4', + output = "mcl_core:diorite_smooth 4", recipe = { - {'mcl_core:diorite', 'mcl_core:diorite'}, - {'mcl_core:diorite', 'mcl_core:diorite'} + {"mcl_core:diorite", "mcl_core:diorite"}, + {"mcl_core:diorite", "mcl_core:diorite"} }, }) minetest.register_craft({ type = "shapeless", - output = 'mcl_core:granite', - recipe = {'mcl_core:diorite', 'mcl_nether:quartz'}, + output = "mcl_core:granite", + recipe = {"mcl_core:diorite", "mcl_nether:quartz"}, }) minetest.register_craft({ type = "shapeless", - output = 'mcl_core:andesite 2', - recipe = {'mcl_core:diorite', 'mcl_core:cobble'}, + output = "mcl_core:andesite 2", + recipe = {"mcl_core:diorite", "mcl_core:cobble"}, }) minetest.register_craft({ - output = 'mcl_core:diorite 2', + output = "mcl_core:diorite 2", recipe = { - {'mcl_core:cobble', 'mcl_nether:quartz'}, - {'mcl_nether:quartz', 'mcl_core:cobble'}, + {"mcl_core:cobble", "mcl_nether:quartz"}, + {"mcl_nether:quartz", "mcl_core:cobble"}, } }) minetest.register_craft({ - output = 'mcl_core:diorite 2', + output = "mcl_core:diorite 2", recipe = { - {'mcl_nether:quartz', 'mcl_core:cobble'}, - {'mcl_core:cobble', 'mcl_nether:quartz'}, + {"mcl_nether:quartz", "mcl_core:cobble"}, + {"mcl_core:cobble", "mcl_nether:quartz"}, } }) @@ -207,60 +140,60 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_core:stick 4', + output = "mcl_core:stick 4", recipe = { - {'group:wood'}, - {'group:wood'}, + {"group:wood"}, + {"group:wood"}, } }) minetest.register_craft({ - output = 'mcl_core:coalblock', + output = "mcl_core:coalblock", recipe = { - {'mcl_core:coal_lump', 'mcl_core:coal_lump', 'mcl_core:coal_lump'}, - {'mcl_core:coal_lump', 'mcl_core:coal_lump', 'mcl_core:coal_lump'}, - {'mcl_core:coal_lump', 'mcl_core:coal_lump', 'mcl_core:coal_lump'}, + {"mcl_core:coal_lump", "mcl_core:coal_lump", "mcl_core:coal_lump"}, + {"mcl_core:coal_lump", "mcl_core:coal_lump", "mcl_core:coal_lump"}, + {"mcl_core:coal_lump", "mcl_core:coal_lump", "mcl_core:coal_lump"}, } }) minetest.register_craft({ - output = 'mcl_core:coal_lump 9', + output = "mcl_core:coal_lump 9", recipe = { - {'mcl_core:coalblock'}, + {"mcl_core:coalblock"}, } }) minetest.register_craft({ - output = 'mcl_core:ironblock', + output = "mcl_core:ironblock", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"}, } }) minetest.register_craft({ - output = 'mcl_core:iron_ingot 9', + output = "mcl_core:iron_ingot 9", recipe = { - {'mcl_core:ironblock'}, + {"mcl_core:ironblock"}, } }) minetest.register_craft({ - output = 'mcl_core:goldblock', + output = "mcl_core:goldblock", recipe = { - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, } }) minetest.register_craft({ - output = 'mcl_core:gold_ingot 9', + output = "mcl_core:gold_ingot 9", recipe = { - {'mcl_core:goldblock'}, + {"mcl_core:goldblock"}, } }) @@ -294,119 +227,119 @@ minetest.register_craft({ minetest.register_craft({ type = "cooking", - output = 'mcl_core:iron_nugget', - recipe = 'mobs_mc:iron_horse_armor', + output = "mcl_core:iron_nugget", + recipe = "mobs_mc:iron_horse_armor", cooktime = 10, }) minetest.register_craft({ type = "cooking", - output = 'mcl_core:gold_nugget', - recipe = 'mobs_mc:gold_horse_armor', + output = "mcl_core:gold_nugget", + recipe = "mobs_mc:gold_horse_armor", cooktime = 10, }) minetest.register_craft({ - output = 'mcl_core:sandstone', + output = "mcl_core:sandstone", recipe = { - {'mcl_core:sand', 'mcl_core:sand'}, - {'mcl_core:sand', 'mcl_core:sand'}, + {"mcl_core:sand", "mcl_core:sand"}, + {"mcl_core:sand", "mcl_core:sand"}, } }) minetest.register_craft({ - output = 'mcl_core:redsandstone', + output = "mcl_core:redsandstone", recipe = { - {'mcl_core:redsand', 'mcl_core:redsand'}, - {'mcl_core:redsand', 'mcl_core:redsand'}, + {"mcl_core:redsand", "mcl_core:redsand"}, + {"mcl_core:redsand", "mcl_core:redsand"}, } }) minetest.register_craft({ - output = 'mcl_core:clay', + output = "mcl_core:clay", recipe = { - {'mcl_core:clay_lump', 'mcl_core:clay_lump'}, - {'mcl_core:clay_lump', 'mcl_core:clay_lump'}, + {"mcl_core:clay_lump", "mcl_core:clay_lump"}, + {"mcl_core:clay_lump", "mcl_core:clay_lump"}, } }) minetest.register_craft({ - output = 'mcl_core:brick_block', + output = "mcl_core:brick_block", recipe = { - {'mcl_core:brick', 'mcl_core:brick'}, - {'mcl_core:brick', 'mcl_core:brick'}, + {"mcl_core:brick", "mcl_core:brick"}, + {"mcl_core:brick", "mcl_core:brick"}, } }) minetest.register_craft({ - output = 'mcl_core:paper 3', + output = "mcl_core:paper 3", recipe = { - {'mcl_core:reeds', 'mcl_core:reeds', 'mcl_core:reeds'}, + {"mcl_core:reeds", "mcl_core:reeds", "mcl_core:reeds"}, } }) minetest.register_craft({ - output = 'mcl_core:ladder 3', + output = "mcl_core:ladder 3", recipe = { - {'mcl_core:stick', '', 'mcl_core:stick'}, - {'mcl_core:stick', 'mcl_core:stick', 'mcl_core:stick'}, - {'mcl_core:stick', '', 'mcl_core:stick'}, + {"mcl_core:stick", "", "mcl_core:stick"}, + {"mcl_core:stick", "mcl_core:stick", "mcl_core:stick"}, + {"mcl_core:stick", "", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_core:stonebrick 4', + output = "mcl_core:stonebrick 4", recipe = { - {'mcl_core:stone', 'mcl_core:stone'}, - {'mcl_core:stone', 'mcl_core:stone'}, + {"mcl_core:stone", "mcl_core:stone"}, + {"mcl_core:stone", "mcl_core:stone"}, } }) minetest.register_craft({ - output = 'mcl_core:lapisblock', + output = "mcl_core:lapisblock", recipe = { - {'mcl_dye:blue', 'mcl_dye:blue', 'mcl_dye:blue'}, - {'mcl_dye:blue', 'mcl_dye:blue', 'mcl_dye:blue'}, - {'mcl_dye:blue', 'mcl_dye:blue', 'mcl_dye:blue'}, + {"mcl_dye:blue", "mcl_dye:blue", "mcl_dye:blue"}, + {"mcl_dye:blue", "mcl_dye:blue", "mcl_dye:blue"}, + {"mcl_dye:blue", "mcl_dye:blue", "mcl_dye:blue"}, } }) minetest.register_craft({ - output = 'mcl_dye:blue 9', + output = "mcl_dye:blue 9", recipe = { - {'mcl_core:lapisblock'}, + {"mcl_core:lapisblock"}, } }) minetest.register_craft({ output = "mcl_core:emeraldblock", recipe = { - {'mcl_core:emerald', 'mcl_core:emerald', 'mcl_core:emerald'}, - {'mcl_core:emerald', 'mcl_core:emerald', 'mcl_core:emerald'}, - {'mcl_core:emerald', 'mcl_core:emerald', 'mcl_core:emerald'}, + {"mcl_core:emerald", "mcl_core:emerald", "mcl_core:emerald"}, + {"mcl_core:emerald", "mcl_core:emerald", "mcl_core:emerald"}, + {"mcl_core:emerald", "mcl_core:emerald", "mcl_core:emerald"}, } }) minetest.register_craft({ - output = 'mcl_core:emerald 9', + output = "mcl_core:emerald 9", recipe = { - {'mcl_core:emeraldblock'}, + {"mcl_core:emeraldblock"}, } }) minetest.register_craft({ output = "mcl_core:diamondblock", recipe = { - {'mcl_core:diamond', 'mcl_core:diamond', 'mcl_core:diamond'}, - {'mcl_core:diamond', 'mcl_core:diamond', 'mcl_core:diamond'}, - {'mcl_core:diamond', 'mcl_core:diamond', 'mcl_core:diamond'}, + {"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"}, + {"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"}, + {"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"}, } }) minetest.register_craft({ - output = 'mcl_core:diamond 9', + output = "mcl_core:diamond 9", recipe = { - {'mcl_core:diamondblock'}, + {"mcl_core:diamondblock"}, } }) @@ -414,7 +347,7 @@ minetest.register_craft({ output = "mcl_core:apple_gold", recipe = { {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, - {"mcl_core:gold_ingot", 'mcl_core:apple', "mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot", "mcl_core:apple", "mcl_core:gold_ingot"}, {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, } }) @@ -435,17 +368,17 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_core:snowblock', + output = "mcl_core:snowblock", recipe = { - {'mcl_throwing:snowball', 'mcl_throwing:snowball'}, - {'mcl_throwing:snowball', 'mcl_throwing:snowball'}, + {"mcl_throwing:snowball", "mcl_throwing:snowball"}, + {"mcl_throwing:snowball", "mcl_throwing:snowball"}, } }) minetest.register_craft({ - output = 'mcl_core:snow 6', + output = "mcl_core:snow 6", recipe = { - {'mcl_core:snowblock', 'mcl_core:snowblock', 'mcl_core:snowblock'}, + {"mcl_core:snowblock", "mcl_core:snowblock", "mcl_core:snowblock"}, } }) diff --git a/mods/ITEMS/mcl_core/craftitems.lua b/mods/ITEMS/mcl_core/craftitems.lua index 2428bb5e..03f30b7b 100644 --- a/mods/ITEMS/mcl_core/craftitems.lua +++ b/mods/ITEMS/mcl_core/craftitems.lua @@ -1,6 +1,6 @@ -- mods/default/craftitems.lua -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) -- -- Crafting items @@ -28,7 +28,6 @@ minetest.register_craftitem("mcl_core:coal_lump", { description = S("Coal"), _doc_items_longdesc = S("“Coal” refers to coal lumps obtained by digging coal ore which can be found underground. Coal is your standard furnace fuel, but it can also be used to make torches, coal blocks and a few other things."), _doc_items_hidden = false, - groups = { coal=1 }, inventory_image = "default_coal_lump.png", stack_max = 64, groups = { craftitem=1, coal=1 }, @@ -38,7 +37,6 @@ minetest.register_craftitem("mcl_core:charcoal_lump", { description = S("Charcoal"), _doc_items_longdesc = S("Charcoal is an alternative furnace fuel created by cooking wood in a furnace. It has the same burning time as coal and also shares many of its crafting recipes, but it can not be used to create coal blocks."), _doc_items_hidden = false, - groups = { coal=1 }, inventory_image = "mcl_core_charcoal.png", stack_max = 64, groups = { craftitem=1, coal=1 }, diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 0c25de94..f0633914 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -2,8 +2,13 @@ -- Lava vs water interactions -- +local modpath = minetest.get_modpath(minetest.get_current_modname()) + local mg_name = minetest.get_mapgen_setting("mg_name") +local math = math +local vector = vector + local OAK_TREE_ID = 1 local DARK_OAK_TREE_ID = 2 local SPRUCE_TREE_ID = 3 @@ -23,8 +28,8 @@ minetest.register_abm({ local lavatype = minetest.registered_nodes[node.name].liquidtype for w=1, #water do - local waternode = minetest.get_node(water[w]) - local watertype = minetest.registered_nodes[waternode.name].liquidtype + --local waternode = minetest.get_node(water[w]) + --local watertype = minetest.registered_nodes[waternode.name].liquidtype -- Lava on top of water: Water turns into stone if water[w].y < pos.y and water[w].x == pos.x and water[w].z == pos.z then minetest.set_node(water[w], {name="mcl_core:stone"}) @@ -53,7 +58,7 @@ minetest.register_abm({ -- -- Functions -mcl_core.grow_cactus = function(pos, node) +function mcl_core.grow_cactus(pos, node) pos.y = pos.y-1 local name = minetest.get_node(pos).name if minetest.get_item_group(name, "sand") ~= 0 then @@ -71,7 +76,7 @@ mcl_core.grow_cactus = function(pos, node) end end -mcl_core.grow_reeds = function(pos, node) +function mcl_core.grow_reeds(pos, node) pos.y = pos.y-1 local name = minetest.get_node(pos).name if minetest.get_item_group(name, "soil_sugarcane") ~= 0 then @@ -114,8 +119,8 @@ local function drop_attached_node(p) end -- Helper function for node actions for liquid flow -local liquid_flow_action = function(pos, group, action) - local check_detach = function(pos, xp, yp, zp) +local function liquid_flow_action(pos, group, action) + local function check_detach(pos, xp, yp, zp) local p = {x=pos.x+xp, y=pos.y+yp, z=pos.z+zp} local n = minetest.get_node_or_nil(p) if not n then @@ -190,6 +195,22 @@ minetest.register_abm({ end, }) +-- Make cactus destroy items +minetest.register_abm({ + label = "Cactus destroy items", + 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 + object:remove() + end + end + end, +}) + + minetest.register_abm({ label = "Sugar canes growth", nodenames = {"mcl_core:reeds"}, @@ -231,7 +252,7 @@ end -- Check if a node stops a tree from growing. Torches, plants, wood, tree, -- leaves and dirt does not affect tree growth. local function node_stops_growth(node) - if node.name == 'air' then + if node.name == "air" then return false end @@ -320,13 +341,12 @@ end -- oak tree. function mcl_core.generate_tree(pos, tree_type, options) pos.y = pos.y-1 - local nodename = minetest.get_node(pos).name + --local nodename = minetest.get_node(pos).name pos.y = pos.y+1 if not minetest.get_node_light(pos) then return end - local node local two_by_two = options and options.two_by_two local balloon = options and options.balloon @@ -374,7 +394,7 @@ end function mcl_core.generate_v6_oak_tree(pos) local trunk = "mcl_core:tree" local leaves = "mcl_core:leaves" - local node = {name = ""} + local node for dy=1,4 do pos.y = pos.y+dy if minetest.get_node(pos).name ~= "air" then @@ -393,10 +413,10 @@ function mcl_core.generate_v6_oak_tree(pos) node = {name = leaves} pos.y = pos.y+3 - local rarity = 0 + --[[local rarity = 0 if math.random(0, 10) == 3 then rarity = 1 - end + end]] for dx=-2,2 do for dz=-2,2 do for dy=0,3 do @@ -442,12 +462,12 @@ function mcl_core.generate_balloon_oak_tree(pos) local s = math.random(1, 12) if s == 1 then -- Small balloon oak - path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_oak_balloon.mts" + path = modpath .. "/schematics/mcl_core_oak_balloon.mts" offset = { x = -2, y = -1, z = -2 } else -- Large balloon oak local t = math.random(1, 4) - path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_oak_large_"..t..".mts" + path = modpath .. "/schematics/mcl_core_oak_large_"..t..".mts" if t == 1 or t == 3 then offset = { x = -3, y = -1, z = -3 } elseif t == 2 or t == 4 then @@ -458,16 +478,16 @@ function mcl_core.generate_balloon_oak_tree(pos) end -- Oak -function mcl_core.generate_oak_tree(pos) - local path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_oak_classic.mts" - local offset = { x = -2, y = -1, z = -2 } +local path_oak_tree = modpath.."/schematics/mcl_core_oak_classic.mts" - minetest.place_schematic(vector.add(pos, offset), path, "random", nil, false) +function mcl_core.generate_oak_tree(pos) + local offset = { x = -2, y = -1, z = -2 } + minetest.place_schematic(vector.add(pos, offset), path_oak_tree, "random", nil, false) end -- Birch function mcl_core.generate_birch_tree(pos) - local path = minetest.get_modpath("mcl_core") .. + local path = modpath .. "/schematics/mcl_core_birch.mts" minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, path, "random", nil, false) end @@ -579,26 +599,26 @@ function mcl_core.generate_v6_spruce_tree(pos) vm:write_to_map() end -mcl_core.generate_spruce_tree = function(pos) +function mcl_core.generate_spruce_tree(pos) local r = math.random(1, 3) - local path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_spruce_"..r..".mts" + local path = modpath .. "/schematics/mcl_core_spruce_"..r..".mts" minetest.place_schematic({ x = pos.x - 3, y = pos.y - 1, z = pos.z - 3 }, path, "0", nil, false) end -mcl_core.generate_huge_spruce_tree = function(pos) +function mcl_core.generate_huge_spruce_tree(pos) local r1 = math.random(1, 2) local r2 = math.random(1, 4) local path local offset = { x = -4, y = -1, z = -5 } if r1 <= 2 then -- Mega Spruce Taiga (full canopy) - path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_spruce_huge_"..r2..".mts" + path = modpath.."/schematics/mcl_core_spruce_huge_"..r2..".mts" else -- Mega Taiga (leaves only at top) if r2 == 1 or r2 == 3 then offset = { x = -3, y = -1, z = -4} end - path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_spruce_huge_up_"..r2..".mts" + path = modpath.."/schematics/mcl_core_spruce_huge_up_"..r2..".mts" end minetest.place_schematic(vector.add(pos, offset), path, "0", nil, false) end @@ -616,15 +636,14 @@ function mcl_core.generate_acacia_tree(pos) elseif r == 1 or r == 5 then offset = { x = -5, y = -1, z = -5 } end - local path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_acacia_"..r..".mts" + local path = modpath.."/schematics/mcl_core_acacia_"..r..".mts" minetest.place_schematic(vector.add(pos, offset), path, "random", nil, false) end -- Generate dark oak tree with 2×2 trunk. -- With pos being the lower X and the higher Z value of the trunk function mcl_core.generate_dark_oak_tree(pos) - local path = minetest.get_modpath("mcl_core") .. - "/schematics/mcl_core_dark_oak.mts" + local path = modpath.."/schematics/mcl_core_dark_oak.mts" minetest.place_schematic({x = pos.x - 3, y = pos.y - 1, z = pos.z - 4}, path, "random", nil, false) end @@ -724,8 +743,7 @@ function mcl_core.generate_v6_jungle_tree(pos) end function mcl_core.generate_jungle_tree(pos) - local path = minetest.get_modpath("mcl_core") .. - "/schematics/mcl_core_jungle_tree.mts" + local path = modpath.."/schematics/mcl_core_jungle_tree.mts" minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, path, "random", nil, false) end @@ -734,8 +752,7 @@ end function mcl_core.generate_huge_jungle_tree(pos) -- 2 variants local r = math.random(1, 2) - local path = minetest.get_modpath("mcl_core") .. - "/schematics/mcl_core_jungle_tree_huge_"..r..".mts" + local path = modpath.."/schematics/mcl_core_jungle_tree_huge_"..r..".mts" minetest.place_schematic({x = pos.x - 6, y = pos.y - 1, z = pos.z - 7}, path, "random", nil, false) end @@ -771,7 +788,6 @@ minetest.register_abm({ if pos == nil then return end - local can_change = false local above = {x=pos.x, y=pos.y+1, z=pos.z} local abovenode = minetest.get_node(above) if minetest.get_item_group(abovenode.name, "liquid") ~= 0 or minetest.get_item_group(abovenode.name, "opaque") == 1 then @@ -897,7 +913,7 @@ minetest.register_lbm({ -------------------------- local treelight = 9 -local sapling_grow_action = function(tree_id, soil_needed, one_by_one, two_by_two, sapling) +local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, sapling) return function(pos) local meta = minetest.get_meta(pos) if meta:get("grown") then return end @@ -939,7 +955,7 @@ local sapling_grow_action = function(tree_id, soil_needed, one_by_one, two_by_tw -- This sapling grows in a special way when there are 4 saplings in a 2×2 pattern if two_by_two then -- Check 8 surrounding saplings and try to find a 2×2 pattern - local is_sapling = function(pos, sapling) + local function is_sapling(pos, sapling) return minetest.get_node(pos).name == sapling end local p2 = {x=pos.x+1, y=pos.y, z=pos.z} @@ -1005,7 +1021,7 @@ local sapling_grow_action = function(tree_id, soil_needed, one_by_one, two_by_tw if one_by_one and check_tree_growth(pos, tree_id) then -- Single sapling minetest.set_node(pos, {name="air"}) - local r = math.random(1, 12) + --local r = math.random(1, 12) mcl_core.generate_tree(pos, tree_id) return end @@ -1026,7 +1042,7 @@ local grow_birch = sapling_grow_action(BIRCH_TREE_ID, 1, true, false) -- pos: Position -- node: Node table of the node at this position, from minetest.get_node -- Returns true on success and false on failure -mcl_core.grow_sapling = function(pos, node) +function mcl_core.grow_sapling(pos, node) local grow if node.name == "mcl_core:sapling" then grow = grow_oak @@ -1231,7 +1247,7 @@ minetest.register_abm({ end -- Add vines below pos (if empty) - local spread_down = function(origin, target, dir, node) + local function spread_down(origin, target, dir, node) if math.random(1, 2) == 1 then if minetest.get_node(target).name == "air" then minetest.add_node(target, {name = "mcl_core:vine", param2 = node.param2}) @@ -1240,7 +1256,7 @@ minetest.register_abm({ end -- Add vines above pos if it is backed up - local spread_up = function(origin, target, dir, node) + local function spread_up(origin, target, dir, node) local vines_in_area = minetest.find_nodes_in_area({x=origin.x-4, y=origin.y-1, z=origin.z-4}, {x=origin.x+4, y=origin.y+1, z=origin.z+4}, "mcl_core:vine") -- Less then 4 vines blocks around the ticked vines block (remember the ticked block is counted by above function as well) if #vines_in_area < 5 then @@ -1259,7 +1275,7 @@ minetest.register_abm({ end end - local spread_horizontal = function(origin, target, dir, node) + local function spread_horizontal(origin, target, dir, node) local vines_in_area = minetest.find_nodes_in_area({x=origin.x-4, y=origin.y-1, z=origin.z-4}, {x=origin.x+4, y=origin.y+1, z=origin.z+4}, "mcl_core:vine") -- Less then 4 vines blocks around the ticked vines block (remember the ticked block is counted by above function as well) if #vines_in_area < 5 then @@ -1296,7 +1312,7 @@ minetest.register_abm({ }) -- Returns true of the node supports vines -mcl_core.supports_vines = function(nodename) +function mcl_core.supports_vines(nodename) local def = minetest.registered_nodes[nodename] -- Rules: 1) walkable 2) full cube return def.walkable and @@ -1321,9 +1337,8 @@ mcl_core.leafdecay_enable_cache = true mcl_core.leafdecay_trunk_find_allow_accumulator = 0 minetest.register_globalstep(function(dtime) - local finds_per_second = 5000 - mcl_core.leafdecay_trunk_find_allow_accumulator = - math.floor(dtime * finds_per_second) + --local finds_per_second = 5000 + mcl_core.leafdecay_trunk_find_allow_accumulator = math.floor(dtime * 5000) end) minetest.register_abm({ @@ -1402,7 +1417,7 @@ minetest.register_abm({ for s=1, #surround do local spos = vector.add(p0, surround[s]) local maybe_vine = minetest.get_node(spos) - local surround_inverse = vector.multiply(surround[s], -1) + --local surround_inverse = vector.multiply(surround[s], -1) if maybe_vine.name == "mcl_core:vine" and (not mcl_core.check_vines_supported(spos, maybe_vine)) then minetest.remove_node(spos) vinedecay_particles(spos, maybe_vine) @@ -1516,7 +1531,7 @@ end -- -- The snowable nodes also MUST have _mcl_snowed defined to contain the name -- of the snowed node. -mcl_core.register_snowed_node = function(itemstring_snowed, itemstring_clear, tiles, sounds, clear_colorization, desc) +function mcl_core.register_snowed_node(itemstring_snowed, itemstring_clear, tiles, sounds, clear_colorization, desc) local def = table.copy(minetest.registered_nodes[itemstring_clear]) local create_doc_alias if def.description then @@ -1579,7 +1594,7 @@ end -- Reverts a snowed dirtlike node at pos to its original snow-less form. -- This function assumes there is no snow cover node above. This function -- MUST NOT be called if there is a snow cover node above pos. -mcl_core.clear_snow_dirt = function(pos, node) +function mcl_core.clear_snow_dirt(pos, node) local def = minetest.registered_nodes[node.name] if def._mcl_snowless then minetest.swap_node(pos, {name = def._mcl_snowless, param2=node.param2}) @@ -1591,7 +1606,7 @@ end -- on_construct -- Makes constructed snowable node snowed if placed below a snow cover node. -mcl_core.on_snowable_construct = function(pos) +function mcl_core.on_snowable_construct(pos) -- Myself local node = minetest.get_node(pos) @@ -1619,7 +1634,7 @@ end -- on_construct -- Makes snowable node below snowed. -mcl_core.on_snow_construct = function(pos) +function mcl_core.on_snow_construct(pos) local npos = {x=pos.x, y=pos.y-1, z=pos.z} local node = minetest.get_node(npos) local def = minetest.registered_nodes[node.name] @@ -1629,7 +1644,7 @@ mcl_core.on_snow_construct = function(pos) end -- after_destruct -- Clears snowed dirtlike node below. -mcl_core.after_snow_destruct = function(pos) +function mcl_core.after_snow_destruct(pos) local nn = minetest.get_node(pos).name -- No-op if snow was replaced with snow if minetest.get_item_group(nn, "snow_cover") == 1 then diff --git a/mods/ITEMS/mcl_core/init.lua b/mods/ITEMS/mcl_core/init.lua index 897382e0..c345d057 100644 --- a/mods/ITEMS/mcl_core/init.lua +++ b/mods/ITEMS/mcl_core/init.lua @@ -17,7 +17,7 @@ mcl_autogroup.register_diggroup("swordy_cobweb") mcl_autogroup.register_diggroup("hoey") -- Load files -local modpath = minetest.get_modpath("mcl_core") +local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/functions.lua") dofile(modpath.."/nodes_base.lua") -- Simple solid cubic nodes with simple definitions dofile(modpath.."/nodes_liquid.lua") -- Liquids diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.de.tr b/mods/ITEMS/mcl_core/locale/mcl_core.de.tr index 57ef530a..3d90dd5a 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.de.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.de.tr @@ -202,20 +202,39 @@ Stained glass is a decorative and mostly transparent block which comes in variou Stick=Stock Sticks are a very versatile crafting material; used in countless crafting recipes.=Stöcke sind ein vielseitiges Material, sie werden in zahllosen Fertigungsrezepten gebraucht. Stone=Stein +Stripped Acacia Log=Entrindeter Akazienstamm +Stripped Acacia Wood=Entrindetes Akazienholz +Stripped Birch Log=Entrindeter Birkenstamm +Stripped Birch Wood=Entrindetes Birkenholz +Stripped Dark Oak Log=Entrindeter Schwarzeichenstamm +Stripped Dark Oak Wood=Entrindetes Schwarzeichenholz +Stripped Jungle Log=Entrindeter Dschungelbaumstamm +Stripped Jungle Wood=Entrindetes Dschungelholz +Stripped Oak Log=Entrindeter Eichenstamm +Stripped Oak Wood=Entrindetes Eichenholz +Stripped Spruce Log=Entrindeter Fichtenstamm +Stripped Spruce Wood=Entrindetes Fichtenholz Stone Bricks=Steinziegel Sugar=Zucker Sugar Canes=Zuckerrohr 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.=Zuckerrohr ist eine Pflanze, die in der Herstellung gebraucht wird. Zuckerrohr wird in der Nähe von Wasser bis zu 3 zusätzliche Blöcke wachsen lassen, wenn sie sich neben Wasser befinden und auf einem Grasblock, auf Erde, Sand, roten Sand, Podsol oder grobe Erde platziert wurden. Wird ein Zuckerrohr abgebrochen, werden alle verbundenen Zuckerrohrblöcke ebenfalls abbrechen. Sugar canes can only be placed top of other sugar canes and on top of blocks on which they would grow.=Zuckerrohr kann nur auf Zuckerrohr platziert werden und auf Blöcken, auf denen Zuckerrohr wachsen würde. Sugar comes from sugar canes and is used to make sweet foods.=Zucker kommt von Zuckerrohr und wird benutzt, um süße Lebensmittel zu machen. +The stripped trunk of an acacia tree.=Der entrindete Stamm einer Akazie. +The stripped trunk of an birch tree.=Der entrindete Stamm einer Birke. +The stripped trunk of an dark oak tree.=Der entrindete Stamm einer Schwarzeiche. +The stripped trunk of an jungle tree.=Der entrindete Stamm eines Dschungelbaums. +The stripped trunk of an oak tree.=Der entrindete Stamm einer Eiche. +The stripped trunk of an spruce tree.=Der entrindete Stamm einer Fichte. The trunk of a birch tree.=Der Baumstamm einer Birke. The trunk of a dark oak tree.=Der Baumstamm einer Schwarzeiche. The trunk of a jungle tree.=Der Baumstamm eines Dschungelbaums. The trunk of a spruce tree.=Der Baumstamm einer Fichte. The trunk of an acacia.=Der Baumstamm einer Akazie. The trunk of an oak tree.=Der Baumstamm einer Eiche. -This block consists of a couple of loose stones and can't support itself.=Diser Block besteht aus ein paar losen Steinchen und kann sich nicht selbst tragen. +This block consists of a couple of loose stones and can't support itself.=Dieser Block besteht aus ein paar losen Steinchen und kann sich nicht selbst tragen. This is a decorative block surrounded by the bark of a tree trunk.=Dies ist ein dekorativer Block, der von der Rinde eines Baumstamms umgeben ist. +This is a decorative block.=Dies ist ein dekorativer Block. This is a full block of snow. Snow of this thickness is usually found in areas of extreme cold.=Ein ganzer Block aus Schnee. Schnee von dieser Dicke wird üblicherweise in Gebieten extremer Kälte gefunden. This is a piece of cactus commonly found in dry areas, especially deserts. Over time, cacti will grow up to 3 blocks high on sand or red sand. A cactus hurts living beings touching it with a damage of 1 HP every half second. When a cactus block is broken, all cactus blocks connected above it will break as well.=Dies ist ein Teil eines Kaktus, der für gewöhnlich in trockenen Gebieten wächst, vorallem Wüsten. Im Laufe der Zeit werden Kakteen auf bis zu 3 Blöcke hoch auf Sand oder rotem Sand wachsen. Ein Kaktus verletzt Lebewesen, die ihn berühren, er richtet jede halbe Sekunden 1 Schaden an. Wenn ein Kaktusblock bricht, werden alle Kaktusblöcke darüber auch abbrechen. This stone contains pure gold, a rare metal.=Dieser Stein enthält pures Gold, ein seltenes Metall. @@ -255,3 +274,4 @@ Slows down movement=Verlangsamt die Fortbewegung 2×2 saplings @= large tree=2×2 Setzlinge @= großer Baum Grows on sand or dirt next to water=Wächst auf Sand oder Erde neben Wasser Stackable=Stapelbar +Needs soil and water to grow=Braucht Nährboden und Wasser zum wachsen diff --git a/mods/ITEMS/mcl_core/locale/template.txt b/mods/ITEMS/mcl_core/locale/template.txt index f988435a..31320c1c 100644 --- a/mods/ITEMS/mcl_core/locale/template.txt +++ b/mods/ITEMS/mcl_core/locale/template.txt @@ -202,12 +202,30 @@ Stained glass is a decorative and mostly transparent block which comes in variou Stick= Sticks are a very versatile crafting material; used in countless crafting recipes.= Stone= +Stripped Acacia Log= +Stripped Acacia Wood= +Stripped Birch Log= +Stripped Birch Wood= +Stripped Dark Oak Log= +Stripped Dark Oak Wood= +Stripped Jungle Log= +Stripped Jungle Wood= +Stripped Oak Log= +Stripped Oak Wood= +Stripped Spruce Log= +Stripped Spruce Wood= Stone Bricks= Sugar= Sugar Canes= 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.= Sugar canes can only be placed top of other sugar canes and on top of blocks on which they would grow.= Sugar comes from sugar canes and is used to make sweet foods.= +The stripped trunk of an acacia tree.= +The stripped trunk of an birch tree.= +The stripped trunk of an dark oak tree.= +The stripped trunk of an jungle tree.= +The stripped trunk of an oak tree.= +The stripped trunk of an spruce tree.= The trunk of a birch tree.= The trunk of a dark oak tree.= The trunk of a jungle tree.= @@ -216,6 +234,7 @@ The trunk of an acacia.= The trunk of an oak tree.= This block consists of a couple of loose stones and can't support itself.= This is a decorative block surrounded by the bark of a tree trunk.= +This is a decorative block.= This is a full block of snow. Snow of this thickness is usually found in areas of extreme cold.= This is a piece of cactus commonly found in dry areas, especially deserts. Over time, cacti will grow up to 3 blocks high on sand or red sand. A cactus hurts living beings touching it with a damage of 1 HP every half second. When a cactus block is broken, all cactus blocks connected above it will break as well.= This stone contains pure gold, a rare metal.= diff --git a/mods/ITEMS/mcl_core/nodes_base.lua b/mods/ITEMS/mcl_core/nodes_base.lua index 4477f037..d4bfd763 100644 --- a/mods/ITEMS/mcl_core/nodes_base.lua +++ b/mods/ITEMS/mcl_core/nodes_base.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) -- Simple solid cubic nodes, most of them are the ground materials and simple building blocks @@ -16,7 +16,7 @@ mcl_core.fortune_drop_ore = { discrete_uniform_distribution = true, min_count = 2, max_count = 1, - get_chance = function (fortune_level) return 1 - 2 / (fortune_level + 2) end, + get_chance = function(fortune_level) return 1 - 2 / (fortune_level + 2) end, multiply = true, } @@ -28,7 +28,7 @@ minetest.register_node("mcl_core:stone", { is_ground_content = true, stack_max = 64, groups = {pickaxey=1, stone=1, building_block=1, material_stone=1}, - drop = 'mcl_core:cobble', + drop = "mcl_core:cobble", sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 1.5, @@ -48,7 +48,7 @@ minetest.register_node("mcl_core:stone_with_coal", { is_ground_content = true, stack_max = 64, groups = {pickaxey=1, building_block=1, material_stone=1, xp=1}, - drop = 'mcl_core:coal_lump', + drop = "mcl_core:coal_lump", sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 3, _mcl_hardness = 3, @@ -63,7 +63,7 @@ minetest.register_node("mcl_core:stone_with_iron", { is_ground_content = true, stack_max = 64, groups = {pickaxey=3, building_block=1, material_stone=1}, - drop = 'mcl_core:stone_with_iron', + drop = "mcl_core:stone_with_iron", sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 3, _mcl_hardness = 3, @@ -86,7 +86,7 @@ minetest.register_node("mcl_core:stone_with_gold", { }) local redstone_timer = 68.28 -local redstone_ore_activate = function(pos) +local function redstone_ore_activate(pos) minetest.swap_node(pos, {name="mcl_core:stone_with_redstone_lit"}) local t = minetest.get_node_timer(pos) t:start(redstone_timer) @@ -124,7 +124,7 @@ minetest.register_node("mcl_core:stone_with_redstone", { } }) -local redstone_ore_reactivate = function(pos) +local function redstone_ore_reactivate(pos) local t = minetest.get_node_timer(pos) t:start(redstone_timer) end @@ -179,11 +179,11 @@ minetest.register_node("mcl_core:stone_with_lapis", { drop = { max_items = 1, items = { - {items = {'mcl_dye:blue 8'},rarity = 5}, - {items = {'mcl_dye:blue 7'},rarity = 5}, - {items = {'mcl_dye:blue 6'},rarity = 5}, - {items = {'mcl_dye:blue 5'},rarity = 5}, - {items = {'mcl_dye:blue 4'}}, + {items = {"mcl_dye:blue 8"},rarity = 5}, + {items = {"mcl_dye:blue 7"},rarity = 5}, + {items = {"mcl_dye:blue 6"},rarity = 5}, + {items = {"mcl_dye:blue 5"},rarity = 5}, + {items = {"mcl_dye:blue 4"}}, } }, sounds = mcl_sounds.node_sound_stone_defaults(), @@ -369,7 +369,7 @@ minetest.register_node("mcl_core:dirt_with_grass", { 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}, - drop = 'mcl_core:dirt', + drop = "mcl_core:dirt", sounds = mcl_sounds.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.1}, }), @@ -422,7 +422,7 @@ minetest.register_node("mcl_core:mycelium", { is_ground_content = true, stack_max = 64, groups = {handy=1,shovely=1, dirt=2,spreading_dirt_type=1, enderman_takable=1, building_block=1}, - drop = 'mcl_core:dirt', + drop = "mcl_core:dirt", sounds = mcl_sounds.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.1}, }), @@ -442,7 +442,7 @@ minetest.register_node("mcl_core:podzol", { is_ground_content = true, stack_max = 64, groups = {handy=1,shovely=3, dirt=2,soil=1, soil_sapling=2, soil_sugarcane=1, enderman_takable=1, building_block=1}, - drop = 'mcl_core:dirt', + drop = "mcl_core:dirt", sounds = mcl_sounds.node_sound_dirt_defaults(), on_construct = mcl_core.on_snowable_construct, _mcl_snowed = "mcl_core:podzol_snow", @@ -487,8 +487,8 @@ minetest.register_node("mcl_core:gravel", { drop = { max_items = 1, items = { - {items = {'mcl_core:flint'},rarity = 10}, - {items = {'mcl_core:gravel'}} + {items = {"mcl_core:flint"},rarity = 10}, + {items = {"mcl_core:gravel"}} } }, sounds = mcl_sounds.node_sound_dirt_defaults({ @@ -501,15 +501,15 @@ minetest.register_node("mcl_core:gravel", { [1] = { max_items = 1, items = { - {items = {'mcl_core:flint'},rarity = 7}, - {items = {'mcl_core:gravel'}} + {items = {"mcl_core:flint"},rarity = 7}, + {items = {"mcl_core:gravel"}} } }, [2] = { max_items = 1, items = { - {items = {'mcl_core:flint'},rarity = 4}, - {items = {'mcl_core:gravel'}} + {items = {"mcl_core:flint"},rarity = 4}, + {items = {"mcl_core:gravel"}} } }, [3] = "mcl_core:flint", @@ -652,7 +652,7 @@ minetest.register_node("mcl_core:clay", { is_ground_content = true, stack_max = 64, groups = {handy=1,shovely=1, enderman_takable=1, building_block=1}, - drop = 'mcl_core:clay_lump 4', + drop = "mcl_core:clay_lump 4", sounds = mcl_sounds.node_sound_dirt_defaults(), _mcl_blast_resistance = 0.6, _mcl_hardness = 0.6, @@ -683,7 +683,7 @@ minetest.register_node("mcl_core:bedrock", { sounds = mcl_sounds.node_sound_stone_defaults(), is_ground_content = false, on_blast = function() end, - drop = '', + drop = "", _mcl_blast_resistance = 3600000, _mcl_hardness = -1, @@ -864,7 +864,7 @@ minetest.register_node("mcl_core:packed_ice", { -- Frosted Ice (4 nodes) for i=0,3 do local ice = {} - ice.increase_age = function(pos, ice_near, first_melt) + function ice.increase_age(pos, ice_near, first_melt) -- Increase age of frosted age or turn to water source if too old local nn = minetest.get_node(pos).name local age = tonumber(string.sub(nn, -1)) @@ -955,7 +955,7 @@ for i=1,8 do fixed = { -0.5, -0.5, -0.5, 0.5, -0.5 + (2*i)/16, 0.5 }, } end - local on_place = function(itemstack, placer, pointed_thing) + local function on_place(itemstack, placer, pointed_thing) -- Placement is only allowed on top of solid blocks if pointed_thing.type ~= "node" then -- no interaction possible with entities @@ -990,9 +990,8 @@ for i=1,8 do local itemcount = itemstack:get_count() local fakestack = ItemStack(itemstring.." "..itemcount) fakestack:set_name("mcl_core:snow_"..math.min(8, (i+g))) - local success - itemstack, success = minetest.item_place(fakestack, placer, pointed_thing) - minetest.sound_play(mcl_sounds.node_sound_snow_defaults().place, {pos = below}, true) + itemstack = minetest.item_place(fakestack, placer, pointed_thing) + minetest.sound_play(mcl_sounds.node_sound_snow_defaults().place, {pos = pointed_thing.under}, true) itemstack:set_name(itemstring) return itemstack end diff --git a/mods/ITEMS/mcl_core/nodes_cactuscane.lua b/mods/ITEMS/mcl_core/nodes_cactuscane.lua index 4ec00517..83910253 100644 --- a/mods/ITEMS/mcl_core/nodes_cactuscane.lua +++ b/mods/ITEMS/mcl_core/nodes_cactuscane.lua @@ -1,6 +1,6 @@ -- Cactus and Sugar Cane -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_node("mcl_core:cactus", { description = S("Cactus"), diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index d9ecd76d..9505bb19 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -1,7 +1,7 @@ -- Climbable nodes -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) -local rotate_climbable = function(pos, node, user, mode) +local function rotate_climbable(pos, node, user, mode) if mode == screwdriver.ROTATE_FACE then local r = screwdriver.rotate.wallmounted(pos, node, mode) node.param2 = r @@ -120,7 +120,6 @@ minetest.register_node("mcl_core:vine", { local node = minetest.get_node(under) local def = minetest.registered_nodes[node.name] if not def then return itemstack end - local groups = def.groups -- Check special rightclick action of pointed node if def and def.on_rightclick then diff --git a/mods/ITEMS/mcl_core/nodes_glass.lua b/mods/ITEMS/mcl_core/nodes_glass.lua index 85bf614f..6e7ab350 100644 --- a/mods/ITEMS/mcl_core/nodes_glass.lua +++ b/mods/ITEMS/mcl_core/nodes_glass.lua @@ -1,5 +1,5 @@ -- Glass nodes -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") minetest.register_node("mcl_core:glass", { @@ -20,7 +20,7 @@ minetest.register_node("mcl_core:glass", { }) ------------------------ --- Create Color Glass -- +-- Create Color Glass -- ------------------------ local canonical_color = "yellow" function mcl_core.add_stained_glass(desc, recipeitem, colorgroup, color) @@ -54,13 +54,13 @@ function mcl_core.add_stained_glass(desc, recipeitem, colorgroup, color) _mcl_hardness = 0.3, _mcl_silk_touch_drop = true, }) - + minetest.register_craft({ - output = 'mcl_core:glass_'..color..' 8', + output = "mcl_core:glass_"..color.." 8", recipe = { - {'mcl_core:glass','mcl_core:glass','mcl_core:glass'}, - {'mcl_core:glass',recipeitem,'mcl_core:glass'}, - {'mcl_core:glass','mcl_core:glass','mcl_core:glass'}, + {"mcl_core:glass","mcl_core:glass","mcl_core:glass"}, + {"mcl_core:glass",recipeitem,"mcl_core:glass"}, + {"mcl_core:glass","mcl_core:glass","mcl_core:glass"}, } }) diff --git a/mods/ITEMS/mcl_core/nodes_liquid.lua b/mods/ITEMS/mcl_core/nodes_liquid.lua index 4696a629..0e0f71a1 100644 --- a/mods/ITEMS/mcl_core/nodes_liquid.lua +++ b/mods/ITEMS/mcl_core/nodes_liquid.lua @@ -1,9 +1,11 @@ -- Liquids: Water and lava -local S = minetest.get_translator("mcl_core") -local N = function(s) return s end +local S = minetest.get_translator(minetest.get_current_modname()) -local WATER_ALPHA = 179 +local vector = vector +local math = math + +--local WATER_ALPHA = 179 local WATER_VISC = 1 local LAVA_VISC = 7 local LIGHT_LAVA = minetest.LIGHT_MAX @@ -13,13 +15,6 @@ if minetest.features.use_texture_alpha_string_modes then USE_TEXTURE_ALPHA = "blend" end -local lava_death_messages = { - N("@1 melted in lava."), - N("@1 took a bath in a hot lava tub."), - N("@1 died in lava."), - N("@1 could not survive in lava."), -} - minetest.register_node("mcl_core:water_flowing", { description = S("Flowing Water"), _doc_items_create_entry = false, @@ -145,7 +140,6 @@ minetest.register_node("mcl_core:lava_flowing", { liquid_renewable = false, liquid_range = 3, damage_per_second = 4*2, - _mcl_node_death_message = lava_death_messages, post_effect_color = {a=245, r=208, g=73, b=10}, groups = { lava=3, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15}, _mcl_blast_resistance = 100, @@ -200,22 +194,21 @@ S("• When lava is directly above water, the water turns into stone."), liquid_renewable = false, liquid_range = 3, damage_per_second = 4*2, - _mcl_node_death_message = lava_death_messages, post_effect_color = {a=245, r=208, g=73, b=10}, stack_max = 64, - groups = { lava=3, lava_source=1, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15}, + groups = { lava=3, lava_source=1, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15, fire_damage=1}, _mcl_blast_resistance = 100, -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode _mcl_hardness = -1, }) -local emit_lava_particle = function(pos) +local function emit_lava_particle(pos) local node = minetest.get_node(pos) if minetest.get_item_group(node.name, "lava_source") == 0 then return end local ppos = vector.add(pos, { x = math.random(-7, 7)/16, y = 0.45, z = math.random(-7, 7)/16}) - local spos = vector.add(ppos, { x = 0, y = -0.2, z = 0 }) + --local spos = vector.add(ppos, { x = 0, y = -0.2, z = 0 }) local vel = { x = math.random(-3, 3)/10, y = math.random(4, 7), z = math.random(-3, 3)/10 } local acc = { x = 0, y = -9.81, z = 0 } -- Lava droplet diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 8b36f069..67669a86 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -1,11 +1,13 @@ -- Other nodes -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_screwdriver = minetest.get_modpath("screwdriver") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way end + local alldirs = {{x=0,y=0,z=1}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=-1,y=0,z=0}, {x=0,y=-1,z=0}, {x=0,y=1,z=0}} minetest.register_node("mcl_core:bone_block", { @@ -31,7 +33,7 @@ minetest.register_node("mcl_core:slimeblock", { node_box = { type = "fixed", fixed = { - {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}, + {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}, {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, } }, @@ -39,7 +41,6 @@ minetest.register_node("mcl_core:slimeblock", { type = "regular", }, tiles = {"mcl_core_slime.png"}, - paramtype = "light", use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "blend" or true, stack_max = 64, -- According to Minecraft Wiki, bouncing off a slime block from a height off 255 blocks should result in a bounce height of 50 blocks @@ -53,7 +54,7 @@ minetest.register_node("mcl_core:slimeblock", { }, _mcl_blast_resistance = 0, _mcl_hardness = 0, - mvps_sticky = function (pos, node, piston_pos) + mvps_sticky = function(pos, node, piston_pos) local connected = {} for n, v in ipairs(alldirs) do local neighbor_pos = vector.add(pos, v) @@ -173,7 +174,7 @@ minetest.register_node("mcl_core:barrier", { drop = "", _mcl_blast_resistance = 36000008, _mcl_hardness = -1, - after_place_node = function (pos, placer, itemstack, pointed_thing) + after_place_node = function(pos, placer, itemstack, pointed_thing) if placer == nil then return end @@ -213,7 +214,7 @@ minetest.register_node("mcl_core:barrier", { -- Same as barrier, but non-pointable. This node is only to be used internally to separate realms. -- It must NOT be used for anything else. -- This node only exists because Minetest does not have support for “dimensions” yet and needs to --- be removed when support for this is implemented. +-- be removed when support for this is implemented. minetest.register_node("mcl_core:realm_barrier", { description = S("Realm Barrier"), _doc_items_create_entry = false, diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index 4af3eef3..c73829d6 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -1,14 +1,15 @@ -- Tree nodes: Wood, Wooden Planks, Sapling, Leaves, Stripped Wood -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_screwdriver = minetest.get_modpath("screwdriver") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way end -- Register tree trunk (wood) and bark -local register_tree_trunk = function(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark) +local function register_tree_trunk(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_varient) minetest.register_node("mcl_core:"..subname, { description = description_trunk, _doc_items_longdesc = longdesc, @@ -22,6 +23,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar on_rotate = on_rotate, _mcl_blast_resistance = 2, _mcl_hardness = 2, + _mcl_stripped_varient = stripped_varient, }) minetest.register_node("mcl_core:"..subname.."_bark", { @@ -37,6 +39,48 @@ local register_tree_trunk = function(subname, description_trunk, description_bar on_rotate = on_rotate, _mcl_blast_resistance = 2, _mcl_hardness = 2, + _mcl_stripped_varient = stripped_varient.."_bark", + }) + + minetest.register_craft({ + output = "mcl_core:"..subname.."_bark 3", + recipe = { + { "mcl_core:"..subname, "mcl_core:"..subname }, + { "mcl_core:"..subname, "mcl_core:"..subname }, + } + }) +end + +-- Register stripped trunk and stripped wood +local function register_stripped_trunk(subname, description_stripped_trunk, description_stripped_bark, longdesc, tile_stripped_inner, tile_stripped_bark) + minetest.register_node("mcl_core:"..subname, { + description = description_stripped_trunk, + _doc_items_longdesc = longdesc, + _doc_items_hidden = false, + tiles = {tile_stripped_inner, tile_stripped_inner, tile_stripped_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + stack_max = 64, + groups = {handy=1,axey=1, tree=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, + }) + + minetest.register_node("mcl_core:"..subname.."_bark", { + description = description_stripped_bark, + _doc_items_longdesc = S("This is a decorative block."), + tiles = {tile_stripped_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + stack_max = 64, + groups = {handy=1,axey=1, bark=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + is_ground_content = false, + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, }) minetest.register_craft({ @@ -48,167 +92,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar }) end --- Register stripped trunk -minetest.register_node("mcl_core:stripped_oak", { - description = "Stripped Oak Log", - _doc_items_longdesc = "Stripped Oak Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_acacia", { - description = "Stripped Acacia Log", - _doc_items_longdesc = "Stripped Acacia Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_dark_oak", { - description = "Stripped Dark Oak Log", - _doc_items_longdesc = "Stripped Dark Oak Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_birch", { - description = "Stripped Birch Log", - _doc_items_longdesc = "Stripped Birch Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_spruce", { - description = "Stripped Spruce Log", - _doc_items_longdesc = "Stripped Spruce Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_jungle", { - description = "Stripped Jungle Log", - _doc_items_longdesc = "Stripped Jungle Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - - --- Register stripped bark -minetest.register_node("mcl_core:stripped_oak_bark", { - description = "Stripped Oak Bark", - _doc_items_longdesc = "Stripped Oak Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_acacia_bark", { - description = "Stripped Acacia Bark", - _doc_items_longdesc = "Stripped Acacia Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_acacia_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_dark_oak_bark", { - description = "Stripped Dark Oak Bark", - _doc_items_longdesc = "Stripped Dark Oak Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_dark_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_birch_bark", { - description = "Stripped Birch Bark", - _doc_items_longdesc = "Stripped Birch Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_birch_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_spruce_bark", { - description = "Stripped Spruce Bark", - _doc_items_longdesc = "Stripped Spruce Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_spruce_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_jungle_bark", { - description = "Stripped Jungle Bark", - _doc_items_longdesc = "Stripped Jungles Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_jungle_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - - -local register_wooden_planks = function(subname, description, tiles) +local function register_wooden_planks(subname, description, tiles) minetest.register_node("mcl_core:"..subname, { description = description, _doc_items_longdesc = doc.sub.items.temp.build, @@ -223,14 +107,13 @@ local register_wooden_planks = function(subname, description, tiles) }) end -local register_leaves = function(subname, description, longdesc, tiles, sapling, drop_apples, sapling_chances, leafdecay_distance) - local drop +local function register_leaves(subname, description, longdesc, tiles, sapling, drop_apples, sapling_chances, leafdecay_distance) if leafdecay_distance == nil then leafdecay_distance = 4 end local apple_chances = {200, 180, 160, 120, 40} local stick_chances = {50, 45, 30, 35, 10} - + local function get_drops(fortune_level) local drop = { max_items = 1, @@ -291,7 +174,7 @@ local register_leaves = function(subname, description, longdesc, tiles, sapling, }) end -local register_sapling = function(subname, description, longdesc, tt_help, texture, selbox) +local function register_sapling(subname, description, longdesc, tt_help, texture, selbox) minetest.register_node("mcl_core:"..subname, { description = description, _tt_help = tt_help, @@ -333,12 +216,19 @@ end --------------------- -register_tree_trunk("tree", S("Oak Wood"), S("Oak Bark"), S("The trunk of an oak tree."), "default_tree_top.png", "default_tree.png") -register_tree_trunk("darktree", S("Dark Oak Wood"), S("Dark Oak Bark"), S("The trunk of a dark oak tree."), "mcl_core_log_big_oak_top.png", "mcl_core_log_big_oak.png") -register_tree_trunk("acaciatree", S("Acacia Wood"), S("Acacia Bark"), S("The trunk of an acacia."), "default_acacia_tree_top.png", "default_acacia_tree.png") -register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The trunk of a spruce tree."), "mcl_core_log_spruce_top.png", "mcl_core_log_spruce.png") -register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png") -register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png") +register_tree_trunk("tree", S("Oak Wood"), S("Oak Bark"), S("The trunk of an oak tree."), "default_tree_top.png", "default_tree.png", "mcl_core:stripped_oak") +register_tree_trunk("darktree", S("Dark Oak Wood"), S("Dark Oak Bark"), S("The trunk of a dark oak tree."), "mcl_core_log_big_oak_top.png", "mcl_core_log_big_oak.png", "mcl_core:stripped_dark_oak") +register_tree_trunk("acaciatree", S("Acacia Wood"), S("Acacia Bark"), S("The trunk of an acacia."), "default_acacia_tree_top.png", "default_acacia_tree.png", "mcl_core:stripped_acacia") +register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The trunk of a spruce tree."), "mcl_core_log_spruce_top.png", "mcl_core_log_spruce.png", "mcl_core:stripped_spruce") +register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png", "mcl_core:stripped_birch") +register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png", "mcl_core:stripped_jungle") + +register_stripped_trunk("stripped_oak", S("Stripped Oak Log"), S("Stripped Oak Wood"), S("The stripped trunk of an oak tree."), "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png") +register_stripped_trunk("stripped_acacia", S("Stripped Acacia Log"), S("Stripped Acacia Wood"), S("The stripped trunk of an acacia tree."), "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png") +register_stripped_trunk("stripped_dark_oak", S("Stripped Dark Oak Log"), S("Stripped Dark Oak Wood"), S("The stripped trunk of an dark oak tree."), "mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_side.png") +register_stripped_trunk("stripped_birch", S("Stripped Birch Log"), S("Stripped Birch Wood"), S("The stripped trunk of an birch tree."), "mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_side.png") +register_stripped_trunk("stripped_spruce", S("Stripped Spruce Log"), S("Stripped Spruce Wood"), S("The stripped trunk of an spruce tree."), "mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_side.png") +register_stripped_trunk("stripped_jungle", S("Stripped Jungle Log"), S("Stripped Jungle Wood"), S("The stripped trunk of an jungle tree."),"mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_side.png") register_wooden_planks("wood", S("Oak Wood Planks"), {"default_wood.png"}) register_wooden_planks("darkwood", S("Dark Oak Wood Planks"), {"mcl_core_planks_big_oak.png"}) diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_acacia_side.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_acacia_side.png index 2e2de8db..2b57a086 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_acacia_side.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_acacia_side.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_acacia_top.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_acacia_top.png index 0746884d..bd10499c 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_acacia_top.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_acacia_top.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_birch_side.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_birch_side.png index a27739c1..5eed80b3 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_birch_side.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_birch_side.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_birch_top.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_birch_top.png index e5290422..69d2e0bf 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_birch_top.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_birch_top.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_dark_oak_side.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_dark_oak_side.png index 9345a14d..32a8bfeb 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_dark_oak_side.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_dark_oak_side.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_dark_oak_top.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_dark_oak_top.png index fbc45938..48c6da9a 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_dark_oak_top.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_dark_oak_top.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_jungle_side.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_jungle_side.png index 74f9f03d..c6566965 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_jungle_side.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_jungle_side.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_jungle_top.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_jungle_top.png index bfa54d8f..028e37ea 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_jungle_top.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_jungle_top.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_oak_side.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_oak_side.png index 3bdffd76..c37220bb 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_oak_side.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_oak_side.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_oak_top.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_oak_top.png index b07c7261..e060862e 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_oak_top.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_oak_top.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_spruce_side.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_spruce_side.png index 11ea15be..55cb4cec 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_spruce_side.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_spruce_side.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_spruce_top.png b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_spruce_top.png index 7699612b..ec0dd2da 100644 Binary files a/mods/ITEMS/mcl_core/textures/mcl_core_stripped_spruce_top.png and b/mods/ITEMS/mcl_core/textures/mcl_core_stripped_spruce_top.png differ diff --git a/mods/ITEMS/mcl_crafting_table/init.lua b/mods/ITEMS/mcl_crafting_table/init.lua index 6df4c254..58b46d66 100644 --- a/mods/ITEMS/mcl_crafting_table/init.lua +++ b/mods/ITEMS/mcl_crafting_table/init.lua @@ -1,8 +1,8 @@ -local S = minetest.get_translator("mcl_crafting_table") +local S = minetest.get_translator(minetest.get_current_modname()) local formspec_escape = minetest.formspec_escape local show_formspec = minetest.show_formspec local C = minetest.colorize -local text_color = mcl_colors.DARK_GRAY +local text_color = "#313131" local itemslot_bg = mcl_formspec.get_itemslot_bg mcl_crafting_table = {} diff --git a/mods/ITEMS/mcl_doors/api_doors.lua b/mods/ITEMS/mcl_doors/api_doors.lua index f3dd0f46..7d00c4c6 100644 --- a/mods/ITEMS/mcl_doors/api_doors.lua +++ b/mods/ITEMS/mcl_doors/api_doors.lua @@ -1,4 +1,5 @@ -local S = minetest.get_translator("mcl_doors") +local S = minetest.get_translator(minetest.get_current_modname()) +local minetest_get_meta = minetest.get_meta -- This helper function calls on_place_node callbacks. local function on_place_node(place_to, newnode, @@ -164,14 +165,14 @@ function mcl_doors:register_door(name, def) end if def.only_placer_can_open then - local meta = minetest.get_meta(pt) + local meta = minetest_get_meta(pt) meta:set_string("doors_owner", "") - meta = minetest.get_meta(pt2) + meta = minetest_get_meta(pt2) meta:set_string("doors_owner", "") end - local meta1 = minetest.get_meta(pt) - local meta2 = minetest.get_meta(pt2) + local meta1 = minetest_get_meta(pt) + local meta2 = minetest_get_meta(pt2) -- save mirror state for the correct door if left_node.name:sub(1, #name) == name then meta1:set_int("is_mirrored", 1) @@ -198,9 +199,9 @@ function mcl_doors:register_door(name, def) local tb = def.tiles_bottom local function on_open_close(pos, dir, check_name, replace, replace_dir) - local meta1 = minetest.get_meta(pos) + local meta1 = minetest_get_meta(pos) pos.y = pos.y+dir - local meta2 = minetest.get_meta(pos) + local meta2 = minetest_get_meta(pos) -- if name of other door is not the same as check_name -> return if not minetest.get_node(pos).name == check_name then @@ -254,7 +255,7 @@ function mcl_doors:register_door(name, def) if not def.only_placer_can_open then return true end - local meta = minetest.get_meta(pos) + local meta = minetest_get_meta(pos) local pn = player:get_player_name() return meta:get_string("doors_owner") == pn end @@ -292,10 +293,15 @@ function mcl_doors:register_door(name, def) sounds = def.sounds, after_destruct = function(bottom, oldnode) - minetest.add_item(bottom, name) - local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } - if minetest.get_node(bottom).name ~= name.."_b_2" and minetest.get_node(top).name == name.."_t_1" then - minetest.remove_node(top) + local meta_bottom = minetest_get_meta(bottom) + if meta_bottom:get_int("rotation") == 1 then + meta_bottom:set_int("rotation", 0) + else + minetest.add_item(bottom, name) + local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } + if minetest.get_node(bottom).name ~= name.."_b_2" and minetest.get_node(top).name == name.."_t_1" then + minetest.remove_node(top) + end end end, @@ -305,13 +311,19 @@ function mcl_doors:register_door(name, def) action_on = on_mesecons_signal_open, }}, - on_rotate = function(pos, node, user, mode, param2) + on_rotate = function(bottom, node, user, mode, param2) if mode == screwdriver.ROTATE_FACE then - minetest.remove_node(pos) - node.param2 = screwdriver.rotate.facedir(pos, node, mode) - minetest.set_node(pos, node) + local meta_bottom = minetest_get_meta(bottom) + meta_bottom:set_int("rotation", 1) + node.param2 = screwdriver.rotate.facedir(bottom, node, mode) + minetest.swap_node(bottom, node) + + local top = {x=bottom.x,y=bottom.y+1,z=bottom.z} + local meta_top = minetest_get_meta(top) + meta_top:set_int("rotation", 1) node.name = name .."_t_1" - minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, node) + minetest.swap_node(top, node) + return true end return false @@ -353,9 +365,14 @@ function mcl_doors:register_door(name, def) sounds = def.sounds, after_destruct = function(top, oldnode) - local bottom = { x = top.x, y = top.y - 1, z = top.z } - if minetest.get_node(top).name ~= name.."_t_2" and minetest.get_node(bottom).name == name.."_b_1" and oldnode.name == name.."_t_1" then - minetest.dig_node(bottom) + local meta_top = minetest_get_meta(top) + if meta_top:get_int("rotation") == 1 then + meta_top:set_int("rotation", 0) + else + local bottom = { x = top.x, y = top.y - 1, z = top.z } + if minetest.get_node(top).name ~= name.."_t_2" and minetest.get_node(bottom).name == name.."_b_1" and oldnode.name == name.."_t_1" then + minetest.dig_node(bottom) + end end end, @@ -366,13 +383,19 @@ function mcl_doors:register_door(name, def) rules = mesecon.rules.flat, }}, - on_rotate = function(pos, node, user, mode, param2) + on_rotate = function(top, node, user, mode, param2) if mode == screwdriver.ROTATE_FACE then - minetest.remove_node(pos) - node.param2 = screwdriver.rotate.facedir(pos, node, mode) - minetest.set_node(pos, node) + local meta_top = minetest_get_meta(top) + meta_top:set_int("rotation", 1) + node.param2 = screwdriver.rotate.facedir(top, node, mode) + minetest.swap_node(top, node) + + local bottom = {x=top.x,y=top.y-1,z=top.z} + local meta_bottom = minetest_get_meta(bottom) + meta_bottom:set_int("rotation", 1) node.name = name .."_b_1" - minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z}, node) + minetest.swap_node(bottom, node) + return true end return false @@ -414,10 +437,15 @@ function mcl_doors:register_door(name, def) sounds = def.sounds, after_destruct = function(bottom, oldnode) - minetest.add_item(bottom, name) - local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } - if minetest.get_node(bottom).name ~= name.."_b_1" and minetest.get_node(top).name == name.."_t_2" then - minetest.remove_node(top) + local meta_bottom = minetest_get_meta(bottom) + if meta_bottom:get_int("rotation") == 1 then + meta_bottom:set_int("rotation", 0) + else + local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } + minetest.add_item(bottom, name) + if minetest.get_node(bottom).name ~= name.."_b_1" and minetest.get_node(top).name == name.."_t_2" then + minetest.remove_node(top) + end end end, @@ -427,13 +455,19 @@ function mcl_doors:register_door(name, def) action_off = on_mesecons_signal_close, }}, - on_rotate = function(pos, node, user, mode, param2) + on_rotate = function(bottom, node, user, mode, param2) if mode == screwdriver.ROTATE_FACE then - minetest.remove_node(pos) - node.param2 = screwdriver.rotate.facedir(pos, node, mode) - minetest.set_node(pos, node) + local meta_bottom = minetest_get_meta(bottom) + meta_bottom:set_int("rotation", 1) + node.param2 = screwdriver.rotate.facedir(bottom, node, mode) + minetest.swap_node(bottom, node) + + local top = {x=bottom.x,y=bottom.y+1,z=bottom.z} + local meta_top = minetest_get_meta(top) + meta_top:set_int("rotation", 1) node.name = name .."_t_2" - minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, node) + minetest.swap_node(top, node) + return true end return false @@ -475,9 +509,14 @@ function mcl_doors:register_door(name, def) sounds = def.sounds, after_destruct = function(top, oldnode) - local bottom = { x = top.x, y = top.y - 1, z = top.z } - if minetest.get_node(top).name ~= name.."_t_1" and minetest.get_node(bottom).name == name.."_b_2" and oldnode.name == name.."_t_2" then - minetest.dig_node(bottom) + local meta_top = minetest_get_meta(top) + if meta_top:get_int("rotation") == 1 then + meta_top:set_int("rotation", 0) + else + local bottom = { x = top.x, y = top.y - 1, z = top.z } + if minetest.get_node(top).name ~= name.."_t_1" and minetest.get_node(bottom).name == name.."_b_2" and oldnode.name == name.."_t_2" then + minetest.dig_node(bottom) + end end end, @@ -488,13 +527,19 @@ function mcl_doors:register_door(name, def) rules = mesecon.rules.flat, }}, - on_rotate = function(pos, node, user, mode, param2) + on_rotate = function(top, node, user, mode, param2) if mode == screwdriver.ROTATE_FACE then - minetest.remove_node(pos) - node.param2 = screwdriver.rotate.facedir(pos, node, mode) - minetest.set_node(pos, node) + local meta_top = minetest_get_meta(top) + meta_top:set_int("rotation", 1) + node.param2 = screwdriver.rotate.facedir(top, node, mode) + minetest.swap_node(top, node) + + local bottom = {x=top.x,y=top.y-1,z=top.z} + local meta_bottom = minetest_get_meta(bottom) + meta_bottom:set_int("rotation", 1) node.name = name .."_b_2" - minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z}, node) + minetest.swap_node(bottom, node) + return true end return false diff --git a/mods/ITEMS/mcl_doors/api_trapdoors.lua b/mods/ITEMS/mcl_doors/api_trapdoors.lua index c8f769c6..3d2a8e89 100644 --- a/mods/ITEMS/mcl_doors/api_trapdoors.lua +++ b/mods/ITEMS/mcl_doors/api_trapdoors.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_doors") +local S = minetest.get_translator(minetest.get_current_modname()) -- Wrapper around mintest.pointed_thing_to_face_pos. local function get_fpos(placer, pointed_thing) @@ -98,13 +98,11 @@ function mcl_doors:register_trapdoor(name, def) if not usagehelp and not def.only_redstone_can_open then usagehelp = S("To open or close this trapdoor, rightclick it or send a redstone signal to it.") end - if not tt_help then - if def.only_redstone_can_open then - tt_help = S("Openable by redstone power") - else - tt_help = S("Openable by players and redstone power") - end - end + if def.only_redstone_can_open then + tt_help = S("Openable by redstone power") + else + tt_help = S("Openable by players and redstone power") + end -- Closed trapdoor @@ -164,7 +162,7 @@ function mcl_doors:register_trapdoor(name, def) local fpos = get_fpos(placer, pointed_thing) - local origname = itemstack:get_name() + --local origname = itemstack:get_name() if p0.y - 1 == p1.y or (fpos > 0 and fpos < 0.5) or (fpos < -0.5 and fpos > -0.999999999) then param2 = param2 + 20 diff --git a/mods/ITEMS/mcl_doors/locale/mcl_doors.de.tr b/mods/ITEMS/mcl_doors/locale/mcl_doors.de.tr index 03be49a6..be88513c 100644 --- a/mods/ITEMS/mcl_doors/locale/mcl_doors.de.tr +++ b/mods/ITEMS/mcl_doors/locale/mcl_doors.de.tr @@ -16,9 +16,9 @@ Birch Trapdoor=Birkenfalltür Spruce Trapdoor=Fichtenfalltür Dark Oak Trapdoor=Schwarzeichenfalltür Jungle Trapdoor=Dschungelfalltür -Wooden trapdoors are horizontal barriers which can be opened and closed by hand or a redstone signal. They occupy the upper or lower part of a block, depending on how they have been placed. When open, they can be climbed like a ladder.=Holzfalltüren sind horizontale Barrieren, die von Hand oder mit einem Redstone-Signal geöffnet oder geschlossen werden können. Sie belegen den oberen oder unteren Teil eines Blocks, je nach dem, wie sie platziert wurden. Wenn geöffnet, können sie wie eine Leiter erklommen werden. +Wooden trapdoors are horizontal barriers which can be opened and closed by hand or a redstone signal. They occupy the upper or lower part of a block, depending on how they have been placed. When open, they can be climbed like a ladder.=Holzfalltüren sind horizontale Barrieren, die von Hand oder mit einem Redstone-Signal geöffnet oder geschlossen werden können. Sie belegen den oberen oder unteren Teil eines Blocks, je nachdem, wie sie platziert wurden. Wenn geöffnet, können sie wie eine Leiter erklommen werden. To open or close the trapdoor, rightclick it or send a redstone signal to it.=Um die Falltür zu öffnen oder zu schließen, rechtsklicken Sie sie oder schicken Sie ein Redstone-Signal zu ihr. Iron Trapdoor=Eisenfalltür -Iron trapdoors are horizontal barriers which can only be opened and closed by redstone signals, but not by hand. They occupy the upper or lower part of a block, depending on how they have been placed. When open, they can be climbed like a ladder.=Eisenfalltüren sind horizontale Barrieren, die nur mit einem Redstone-Signal geöffnet oder geschlossen werden können, nicht von Hand. Sie belegen den oberen oder unteren Teil eines Blocks, je nach dem, wie sie platziert wurden. Wenn geöffnet, können sie wie eine Leiter erklommen werden. +Iron trapdoors are horizontal barriers which can only be opened and closed by redstone signals, but not by hand. They occupy the upper or lower part of a block, depending on how they have been placed. When open, they can be climbed like a ladder.=Eisenfalltüren sind horizontale Barrieren, die nur mit einem Redstone-Signal geöffnet oder geschlossen werden können, nicht von Hand. Sie belegen den oberen oder unteren Teil eines Blocks, je nachdem, wie sie platziert wurden. Wenn geöffnet, können sie wie eine Leiter erklommen werden. Openable by players and redstone power=Zu öffnen von Spielern und Redstoneenergie Openable by redstone power=Zu öffnen von Redstoneenergie diff --git a/mods/ITEMS/mcl_doors/register.lua b/mods/ITEMS/mcl_doors/register.lua index 2ffd4b24..c998f653 100644 --- a/mods/ITEMS/mcl_doors/register.lua +++ b/mods/ITEMS/mcl_doors/register.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_doors") +local S = minetest.get_translator(minetest.get_current_modname()) --[[ Doors ]] @@ -260,9 +260,9 @@ mcl_doors:register_trapdoor("mcl_doors:iron_trapdoor", { }) minetest.register_craft({ - output = 'mcl_doors:iron_trapdoor', + output = "mcl_doors:iron_trapdoor", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot"}, } }) diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index 2897e96e..6771a95e 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -7,13 +7,16 @@ -- Note: As this uses basecolor_*, you'd need 9 of these. -- minetest.register_craft({ -- type = "shapeless", --- output = ':item_yellow', --- recipe = {':item_no_color', 'group:basecolor_yellow'}, +-- output = ":item_yellow", +-- recipe = {":item_no_color", "group:basecolor_yellow"}, -- }) mcl_dye = {} -local S = minetest.get_translator("mcl_dye") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math +local string = string -- Other mods can use these for looping through available colors mcl_dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"} @@ -94,7 +97,7 @@ for d=1, #dyelocal.dyes do end -- Takes an unicolor group name (e.g. “unicolor_white”) and returns a corresponding dye name (if it exists), nil otherwise. -mcl_dye.unicolor_to_dye = function(unicolor_group) +function mcl_dye.unicolor_to_dye(unicolor_group) local color = dyelocal.unicolor_to_dye_id[unicolor_group] if color then return "mcl_dye:" .. color @@ -126,7 +129,7 @@ end -- Bone Meal -mcl_dye.apply_bone_meal = function(pointed_thing) +function mcl_dye.apply_bone_meal(pointed_thing) -- Bone meal currently spawns all flowers found in the plains. local flowers_table_plains = { "mcl_flowers:dandelion", @@ -216,25 +219,24 @@ mcl_dye.apply_bone_meal = function(pointed_thing) end return false -- Wheat, Potato, Carrot, Pumpkin Stem, Melon Stem: Advance by 2-5 stages - elseif string.find(n.name, "mcl_farming:wheat_") ~= nil then + elseif string.find(n.name, "mcl_farming:wheat_") then 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_") ~= nil then + elseif string.find(n.name, "mcl_farming:potato_") then 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_") ~= nil then + elseif string.find(n.name, "mcl_farming:carrot_") then 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_") ~= nil then + elseif string.find(n.name, "mcl_farming:pumpkin_") then 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_") ~= nil then + elseif string.find(n.name, "mcl_farming:melontige_") then 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_") ~= nil then + elseif string.find(n.name, "mcl_farming:beetroot_") then -- Beetroot: 75% chance to advance to next stage - if math.random(1,100) <= 75 then + 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 @@ -327,7 +329,7 @@ minetest.register_craftitem("mcl_dye:white", { _doc_items_usagehelp = S("Rightclick a sheep to turn its wool white. Rightclick a plant to speed up its growth. Note that not all plants can be fertilized like this. When you rightclick a grass block, tall grass and flowers will grow all over the place."), stack_max = 64, groups = dyelocal.dyes[1][4], - on_place = function(itemstack, user, pointed_thing) + on_place = function(itemstack, user, pointed_thing) -- Use pointed node's on_rightclick function first, if present local node = minetest.get_node(pointed_thing.under) if user and not user:get_player_control().sneak then diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index ca936c31..ecc9fe11 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_enchanting") +local S = minetest.get_translator(minetest.get_current_modname()) -- Taken from https://minecraft.gamepedia.com/Enchanting @@ -10,25 +10,6 @@ local function increase_damage(damage_group, factor) end end --- requires engine change ---[[mcl_enchanting.enchantments.aqua_affinity = { - name = S("Aqua Affinity"), - max_level = 1, - primary = {armor_head = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {}, - weight = 2, - description = S("Increases underwater mining speed."), - curse = false, - on_enchant = function() end, - requires_tool = false, - treasure = false, - power_range_table = {{1, 41}}, - inv_combat_tab = true, - inv_tool_tab = false, -}]]-- - -- implemented via on_enchant and additions in mobs_mc; Slowness IV part unimplemented mcl_enchanting.enchantments.bane_of_arthropods = { name = S("Bane of Arthropods"), @@ -48,25 +29,6 @@ mcl_enchanting.enchantments.bane_of_arthropods = { inv_tool_tab = false, } --- implemented in mcl_armor -mcl_enchanting.enchantments.blast_protection = { - name = S("Blast Protection"), - max_level = 4, - primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {fire_protection = true, protection = true, projectile_protection = true}, - weight = 2, - description = S("Reduces explosion damage and knockback."), - curse = false, - on_enchant = function() end, - requires_tool = false, - treasure = false, - power_range_table = {{5, 13}, {13, 21}, {21, 29}, {29, 37}}, - inv_combat_tab = true, - inv_tool_tab = false, -} - -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.channeling = { name = S("Channeling"), @@ -86,25 +48,6 @@ mcl_enchanting.enchantments.blast_protection = { inv_tool_tab = false, }]]-- --- implemented in mcl_armor -mcl_enchanting.enchantments.curse_of_binding = { - name = S("Curse of Binding"), - max_level = 1, - primary = {}, - secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - disallow = {}, - incompatible = {}, - weight = 1, - description = S("Item cannot be removed from armor slots except due to death, breaking or in Creative Mode."), - curse = true, - on_enchant = function() end, - requires_tool = false, - treasure = true, - power_range_table = {{25, 50}}, - inv_combat_tab = true, - inv_tool_tab = false, -} - -- implemented in mcl_death_drop mcl_enchanting.enchantments.curse_of_vanishing = { name = S("Curse of Vanishing"), @@ -164,24 +107,6 @@ mcl_enchanting.enchantments.efficiency = { inv_tool_tab = true, } --- implemented in mcl_armor -mcl_enchanting.enchantments.feather_falling = { - name = S("Feather Falling"), - max_level = 4, - primary = {armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {}, - weight = 5, - description = S("Reduces fall damage."),curse = false, - on_enchant = function() end, - requires_tool = false, - treasure = false, - power_range_table = {{5, 11}, {11, 17}, {17, 23}, {23, 29}}, - inv_combat_tab = true, - inv_tool_tab = false, -} - -- implemented in mcl_mobs and via register_on_punchplayer callback mcl_enchanting.enchantments.fire_aspect = { name = S("Fire Aspect"), @@ -207,31 +132,12 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, if wielditem then local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect") if fire_aspect_level > 0 then - mcl_burning.set_on_fire(player, fire_aspect_level * 4, hitter:get_player_name()) + mcl_burning.set_on_fire(player, fire_aspect_level * 4) end end end end) --- implemented in mcl_armor -mcl_enchanting.enchantments.fire_protection = { - name = S("Fire Protection"), - max_level = 4, - primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {blast_protection = true, protection = true, projectile_protection = true}, - weight = 5, - description = S("Reduces fire damage."), - curse = false, - on_enchant = function() end, - requires_tool = false, - treasure = false, - power_range_table = {{10, 18}, {18, 26}, {26, 34}, {34, 42}}, - inv_combat_tab = true, - inv_tool_tab = false, -} - mcl_enchanting.enchantments.flame = { name = S("Flame"), max_level = 1, @@ -530,44 +436,6 @@ mcl_enchanting.enchantments.power = { inv_tool_tab = false, } --- implemented in mcl_armor -mcl_enchanting.enchantments.projectile_protection = { - name = S("Projectile Protection"), - max_level = 4, - primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {blast_protection = true, fire_protection = true, protection = true}, - weight = 5, - description = S("Reduces projectile damage."), - curse = false, - on_enchant = function() end, - requires_tool = false, - treasure = false, - power_range_table = {{1, 16}, {11, 26}, {21, 36}, {31, 46}, {41, 56}}, - inv_combat_tab = true, - inv_tool_tab = false, -} - --- implemented in mcl_armor -mcl_enchanting.enchantments.protection = { - name = S("Protection"), - max_level = 4, - primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true}, - weight = 10, - description = S("Reduces most types of damage by 4% for each level."), - curse = false, - on_enchant = function() end, - requires_tool = false, - treasure = false, - power_range_table = {{1, 12}, {12, 23}, {23, 34}, {34, 45}}, - inv_combat_tab = true, - inv_tool_tab = false, -} - -- implemented via minetest.calculate_knockback (together with the Knockback enchantment) and mcl_bows mcl_enchanting.enchantments.punch = { name = S("Punch"), @@ -739,25 +607,6 @@ mcl_enchanting.enchantments.soul_speed = { inv_tool_tab = false, }]]-- --- implemented in mcl_armor -mcl_enchanting.enchantments.thorns = { - name = S("Thorns"), - max_level = 3, - primary = {armor_head = true}, - secondary = {armor_torso = true, armor_legs = true, armor_feet = true}, - disallow = {non_combat_armor = true}, - incompatible = {}, - weight = 1, - description = S("Reflects some of the damage taken when hit, at the cost of reducing durability with each proc."), - curse = false, - on_enchant = function() end, - requires_tool = false, - treasure = false, - power_range_table = {{10, 61}, {30, 71}, {50, 81}}, - inv_combat_tab = true, - inv_tool_tab = false, -} - -- for tools & weapons implemented via on_enchant; for bows implemented in mcl_bows; for armor implemented in mcl_armor and mcl_tt; for fishing rods implemented in mcl_fishing mcl_enchanting.enchantments.unbreaking = { name = S("Unbreaking"), @@ -770,12 +619,17 @@ mcl_enchanting.enchantments.unbreaking = { description = S("Increases item durability."), curse = false, on_enchant = function(itemstack, level) - local tool_capabilities = itemstack:get_tool_capabilities() - for group, capability in pairs(tool_capabilities.groupcaps) do - capability.uses = capability.uses * (1 + level) + local name = itemstack:get_name() + if not minetest.registered_tools[name].tool_capabilities then + return end + + local tool_capabilities = itemstack:get_tool_capabilities() tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level) itemstack:get_meta():set_tool_capabilities(tool_capabilities) + + -- Unbreaking for groupcaps is handled in this function. + mcl_enchanting.update_groupcaps(itemstack) end, requires_tool = true, treasure = false, diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index ea69d186..d2a74994 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_enchanting") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape function mcl_enchanting.is_book(itemname) @@ -6,17 +6,21 @@ function mcl_enchanting.is_book(itemname) end function mcl_enchanting.get_enchantments(itemstack) + if not itemstack then + return {} + end return minetest.deserialize(itemstack:get_meta():get_string("mcl_enchanting:enchantments")) or {} end function mcl_enchanting.unload_enchantments(itemstack) local itemdef = itemstack:get_definition() if itemdef.tool_capabilities then - itemstack:get_meta():set_tool_capabilities(itemdef.tool_capabilities) + itemstack:get_meta():set_tool_capabilities(nil) end local meta = itemstack:get_meta() if meta:get_string("name") == "" then meta:set_string("description", "") + meta:set_string("groupcaps_hash", "") end end @@ -246,7 +250,7 @@ local function get_after_use_callback(itemdef) itemstack:add_wear(digparams.wear) end - local enchantments = mcl_enchanting.get_enchantments(itemstack) + --local enchantments = mcl_enchanting.get_enchantments(itemstack) mcl_enchanting.update_groupcaps(itemstack) end end @@ -266,7 +270,8 @@ 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.texture = itemdef.texture or itemname:gsub("%:", "_") + 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 new_def._mcl_enchanting_enchanted_tool = new_name new_def.after_use = get_after_use_callback(itemdef) local register_list = register_item_list @@ -287,7 +292,7 @@ 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 supported, _, _, primary = mcl_enchanting.can_enchant(itemstack, enchantment, 1) + 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 @@ -468,13 +473,13 @@ function mcl_enchanting.show_enchanting_formspec(player) local formspec = "" .. "size[9.07,8.6;]" .. "formspec_version[3]" - .. "label[0,0;" .. C(mcl_colors.DARK_GRAY) .. F(table_name) .. "]" + .. "label[0,0;" .. C("#313131") .. F(table_name) .. "]" .. mcl_formspec.get_itemslot_bg(0.2, 2.4, 1, 1) .. "list[current_player;enchanting_item;0.2,2.4;1,1]" .. mcl_formspec.get_itemslot_bg(1.1, 2.4, 1, 1) .. "image[1.1,2.4;1,1;mcl_enchanting_lapis_background.png]" .. "list[current_player;enchanting_lapis;1.1,2.4;1,1]" - .. "label[0,4;" .. C(mcl_colors.DARK_GRAY) .. F(S("Inventory")).."]" + .. "label[0,4;" .. C("#313131") .. F(S("Inventory")).."]" .. mcl_formspec.get_itemslot_bg(0, 4.5, 9, 3) .. mcl_formspec.get_itemslot_bg(0, 7.74, 9, 1) .. "list[current_player;main;0,4.5;9,3;9]" @@ -501,11 +506,11 @@ function mcl_enchanting.show_enchanting_formspec(player) local hover_ending = (can_enchant and "_hovered" or "_off") formspec = formspec .. "container[3.2," .. y .. "]" - .. (slot and "tooltip[button_" .. i .. ";" .. C(mcl_colors.GRAY) .. F(slot.description) .. " " .. C(mcl_colors.WHITE) .. " . . . ?\n\n" .. (enough_levels and C(enough_lapis and mcl_colors.GRAY or mcl_colors.RED) .. F(S("@1 Lapis Lazuli", i)) .. "\n" .. C(mcl_colors.GRAY) .. F(S("@1 Enchantment Levels", i)) or C(mcl_colors.RED) .. F(S("Level requirement: @1", slot.level_requirement))) .. "]" or "") + .. (slot and "tooltip[button_" .. i .. ";" .. C("#818181") .. ((slot.description and F(slot.description)) or "") .. " " .. C("#FFFFFF") .. " . . . ?\n\n" .. (enough_levels and C(enough_lapis and "#818181" or "#FC5454") .. F(S("@1 Lapis Lazuli", i)) .. "\n" .. C("#818181") .. F(S("@1 Enchantment Levels", i)) or C("#FC5454") .. F(S("Level requirement: @1", slot.level_requirement))) .. "]" or "") .. "style[button_" .. i .. ";bgimg=mcl_enchanting_button" .. ending .. ".png;bgimg_hovered=mcl_enchanting_button" .. hover_ending .. ".png;bgimg_pressed=mcl_enchanting_button" .. hover_ending .. ".png]" .. "button[0,0;7.5,1.3;button_" .. i .. ";]" .. (slot and "image[0,0;1.3,1.3;mcl_enchanting_number_" .. i .. ending .. ".png]" or "") - .. (slot and "label[7.2,1.1;" .. C(can_enchant and mcl_colors.GREEN or mcl_colors.DARK_GREEN) .. slot.level_requirement .. "]" or "") + .. (slot and "label[7.2,1.1;" .. C(can_enchant and "#80FF20" or "#407F10") .. slot.level_requirement .. "]" or "") .. (slot and slot.glyphs or "") .. "container_end[]" y = y + 1.35 diff --git a/mods/ITEMS/mcl_enchanting/groupcaps.lua b/mods/ITEMS/mcl_enchanting/groupcaps.lua index 37502954..a445b73f 100644 --- a/mods/ITEMS/mcl_enchanting/groupcaps.lua +++ b/mods/ITEMS/mcl_enchanting/groupcaps.lua @@ -45,18 +45,30 @@ end -- To make it more efficient it will first check a hash value to determine if -- the tool needs to be updated. function mcl_enchanting.update_groupcaps(itemstack) - if not itemstack:get_meta():get("tool_capabilities") then + local name = itemstack:get_name() + if not minetest.registered_tools[name].tool_capabilities then return end - local name = itemstack:get_name() - local level = mcl_enchanting.get_enchantment(itemstack, "efficiency") - local groupcaps = get_efficiency_groupcaps(name, level) + local efficiency = mcl_enchanting.get_enchantment(itemstack, "efficiency") + local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") + if unbreaking == 0 and efficiency == 0 then + return + end + + local groupcaps = get_efficiency_groupcaps(name, efficiency) local hash = itemstack:get_meta():get_string("groupcaps_hash") if not hash or hash ~= groupcaps.hash then local tool_capabilities = itemstack:get_tool_capabilities() - tool_capabilities.groupcaps = groupcaps.values + tool_capabilities.groupcaps = table.copy(groupcaps.values) + + -- Increase the number of uses depending on the unbreaking level + -- of the tool. + for group, capability in pairs(tool_capabilities.groupcaps) do + capability.uses = capability.uses * (1 + unbreaking) + end + itemstack:get_meta():set_tool_capabilities(tool_capabilities) itemstack:get_meta():set_string("groupcaps_hash", groupcaps.hash) end diff --git a/mods/ITEMS/mcl_enchanting/init.lua b/mods/ITEMS/mcl_enchanting/init.lua index 855e3bf3..5aec1ced 100644 --- a/mods/ITEMS/mcl_enchanting/init.lua +++ b/mods/ITEMS/mcl_enchanting/init.lua @@ -1,5 +1,9 @@ -local modpath = minetest.get_modpath("mcl_enchanting") -local S = minetest.get_translator("mcl_enchanting") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + +local math = math +local vector = vector mcl_enchanting = { book_offset = vector.new(0, 0.75, 0), @@ -122,7 +126,7 @@ minetest.register_chatcommand("forceenchant", { return false, S("Player '@1' cannot be found.", target_name) end local itemstack = target:get_wielded_item() - local can_enchant, errorstring, extra_info = mcl_enchanting.can_enchant(itemstack, enchantment, level) + local _, errorstring = mcl_enchanting.can_enchant(itemstack, enchantment, level) if errorstring == "enchantment invalid" then return false, S("There is no such enchantment '@1'.", enchantment) elseif errorstring == "item missing" then @@ -148,7 +152,7 @@ minetest.register_craftitem("mcl_enchanting:book_enchanted", { minetest.register_alias("mcl_books:book_enchanted", "mcl_enchanting:book_enchanted") -local spawn_book_entity = function(pos, respawn) +local function spawn_book_entity(pos, respawn) if respawn then -- Check if we already have a book local objs = minetest.get_objects_inside_radius(pos, 1) @@ -242,9 +246,9 @@ minetest.register_node("mcl_enchanting:table", { on_rotate = rotate, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local player_meta = clicker:get_meta() - local table_meta = minetest.get_meta(pos) - local num_bookshelves = table_meta:get_int("mcl_enchanting:num_bookshelves") - local table_name = table_meta:get_string("name") + --local table_meta = minetest.get_meta(pos) + --local num_bookshelves = table_meta:get_int("mcl_enchanting:num_bookshelves") + local table_name = minetest.get_meta(pos):get_string("name") if table_name == "" then table_name = S("Enchant") end @@ -361,4 +365,4 @@ minetest.register_on_joinplayer(mcl_enchanting.initialize_player) minetest.register_on_player_receive_fields(mcl_enchanting.handle_formspec_fields) minetest.register_allow_player_inventory_action(mcl_enchanting.allow_inventory_action) minetest.register_on_player_inventory_action(mcl_enchanting.on_inventory_action) -table.insert(tt.registered_snippets, 1, mcl_enchanting.enchantments_snippet) +tt.register_priority_snippet(mcl_enchanting.enchantments_snippet) diff --git a/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.de.tr b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.de.tr index 68077578..ecc08b5d 100644 --- a/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.de.tr +++ b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.de.tr @@ -17,8 +17,8 @@ Efficiency=Effizienz Increases mining speed.=Erhöht Grabegeschwindigkeit. Feather Falling=Federfall Reduces fall damage.=Reduziert Fallschaden. -Fire Aspect=Feieraspekt -Sets target on fire.=Zündes das Ziel an. +Fire Aspect=Feueraspekt +Sets target on fire.=Zündet das Ziel an. Fire Protection=Feuerschutz Reduces fire damage.=Reduziert Feuerschaden Flame=Flamme @@ -31,7 +31,7 @@ Impaling=Aufspießen Trident deals additional damage to ocean mobs.=Dreizack richtet Zusatzschaden an Ozeanmobs an. Infinity=Unendlichkeit Shooting consumes no regular arrows.=Schüsse verbrauchen keine regulären Pfeile. -Knockback=Rückschlag. +Knockback=Rückschlag Increases knockback.=Verstärkt Rückschlag. Looting=Plünderer Increases mob loot.=Erhöht Abwürfe von Mobs. @@ -43,7 +43,7 @@ Lure=Köder Decreases time until rod catches something.=Reduziert die Zeit, bis die Angel etwas fängt. Mending=Ausbessern Repair the item while gaining XP orbs.=Gegenstand reparieren, während man Erfahrungskugeln erhält. -Multishot=Mehrschuss +Multishot=Mehrfachschuss Shoot 3 arrows at the cost of one.=3 Pfeile zum Preis von 1 schießen. Piercing=Durchbohren Arrows passes through multiple objects.=Pfeile durchdringen mehrere Objekte. @@ -74,7 +74,7 @@ Increases sweeping attack damage.=Erhöht Schwungangriffsschaden. Thorns=Dornen Reflects some of the damage taken when hit, at the cost of reducing durability with each proc.=Reflektiert etwas des Schadens beim Erleiden eines Treffers, auf Kosten der Haltbarkeit. Unbreaking=Haltbarkeit -Increases item durability.=Erhöht Haldbarkeit des Gegenstands. +Increases item durability.=Erhöht Haltbarkeit des Gegenstands. Inventory=Inventar @1 Lapis Lazuli=@1 Lapislazuli @1 Enchantment Levels=@1 Verzauberungsstufen diff --git a/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.fr.tr b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.fr.tr index 582f0e59..e1178e78 100644 --- a/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.fr.tr +++ b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.fr.tr @@ -1,18 +1,18 @@ # textdomain: mcl_enchanting Aqua Affinity=Affinité aquatique -Increases underwater mining speed.=Augmente la vitesse de minage sous-marine. +Increases underwater mining speed.=Augmente la vitesse de minage sous-marine. Bane of Arthropods=Fléau des arthropodes -Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).=Augmente les dégâts et applique la lenteur IV aux mobs arthropodes (araignées, araignées des cavernes, lépismes argentés et endermites). +Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).=Augmente les dégâts et applique la lenteur IV aux mobs arthropodes (araignées, araignées des cavernes, lépismes argentés et endermites). Blast Protection=Protection contre les explosions -Reduces explosion damage and knockback.=Réduit les dégâts d'explosion et de recul. +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. +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 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. Depth Strider=Agilité aquatique -Increases underwater movement speed.=Augmente la vitesse de déplacement sous l'eau. +Increases underwater movement speed.=Augmente la vitesse de déplacement sous l'eau. Efficiency=Efficacité Increases mining speed.=Augmente la vitesse de minage. Feather Falling=Chute amortie @@ -22,21 +22,21 @@ Sets target on fire.=Définit la cible en feu. Fire Protection=Protection contre le feu Reduces fire damage.=Reduit les dégats de feu. Flame=Flamme -Arrows set target on fire.=Les flèches mettent le feu à la cible. +Arrows set target on fire.=Les flèches mettent le feu à la cible. Fortune=Fortune Increases certain block drops.=Multiplie les items droppés Frost Walker=Semelles givrantes -Turns water beneath the player into frosted ice and prevents the damage from magma blocks.=Transforme l'eau sous le joueur en glace givrée et empêche les dommages causés par les blocs de magma. +Turns water beneath the player into frosted ice and prevents the damage from magma blocks.=Transforme l'eau sous le joueur en glace givrée et empêche les dommages causés par les blocs de magma. Impaling=Empalement -Trident deals additional damage to ocean mobs.=Trident inflige des dégâts supplémentaires aux mobs océaniques. +Trident deals additional damage to ocean mobs.=Trident inflige des dégâts supplémentaires aux mobs océaniques. Infinity=Infinité -Shooting consumes no regular arrows.=Le tir ne consomme pas de flèches standard. +Shooting consumes no regular arrows.=Le tir ne consomme pas de flèches standard. Knockback=Recul Increases knockback.=Augmente le recul. Looting=Butin -Increases mob loot.=Augmente le butin des mobs. +Increases mob loot.=Augmente le butin des mobs. Loyalty=Loyauté -Trident returns after being thrown. Higher levels reduce return time.=Trident revient après avoir été jeté. Des niveaux plus élevés réduisent le temps de retour. +Trident returns after being thrown. Higher levels reduce return time.=Trident revient après avoir été jeté. Des niveaux plus élevés réduisent le temps de retour. Luck of the Sea=Chance de la mer Increases rate of good loot (enchanting books, etc.)=Augmente le taux de bon butin (livres enchanteurs, etc.) Lure=Appât @@ -44,17 +44,17 @@ Decreases time until rod catches something.=Diminue le temps jusqu'à ce qu'un p Mending=Raccommodage Repair the item while gaining XP orbs.=Réparez l'objet tout en gagnant des points d'XP. Multishot=Tir multiple -Shoot 3 arrows at the cost of one.=Tirez sur 3 flèches au prix d'une. +Shoot 3 arrows at the cost of one.=Tirez sur 3 flèches au prix d'une. Piercing=Perforation -Arrows passes through multiple objects.=Les flèches traversent plusieurs objets. +Arrows passes through multiple objects.=Les flèches traversent plusieurs objets. Power=Puissance -Increases arrow damage.=Augmente les dégâts des flèches. +Increases arrow damage.=Augmente les dégâts des flèches. Projectile Protection=Protection contre les projectiles -Reduces projectile damage.=Réduit les dommages causés par les projectiles. +Reduces projectile damage.=Réduit les dommages causés par les projectiles. Protection=Protection -Reduces most types of damage by 4% for each level.=éduit la plupart des types de dégâts de 4% pour chaque niveau. +Reduces most types of damage by 4% for each level.=éduit la plupart des types de dégâts de 4% pour chaque niveau. Punch=Frappe -Increases arrow knockback.=Augmente le recul de la flèche. +Increases arrow knockback.=Augmente le recul de la flèche. Quick Charge=Charge rapide Decreases crossbow charging time.=Diminue le temps de chargement de l'arbalète. Respiration=Apnée @@ -66,18 +66,18 @@ Increases damage.=Augmente les dégâts. Silk Touch=Toucher de soie Mined blocks drop themselves.=Les blocs minés tombent d'eux-mêmes. Smite=Châtiment -Increases damage to undead mobs.=Augmente les dégâts infligés aux monstres morts-vivants. +Increases damage to undead mobs.=Augmente les dégâts infligés aux monstres morts-vivants. Soul Speed=Agilité des âmes -Increases walking speed on soul sand.=Augmente la vitesse de marche sur le sable de l'âme. +Increases walking speed on soul sand.=Augmente la vitesse de marche sur le sable de l'âme. Sweeping Edge=Affilage -Increases sweeping attack damage.=Augmente les dégâts de l'épée +Increases sweeping attack damage.=Augmente les dégâts de l'épée Thorns=Épines Reflects some of the damage taken when hit, at the cost of reducing durability with each proc.=Reflète une partie des dégâts subis lors de la frappe, au prix d'une réduction de la durabilité à chaque déclenchement. Unbreaking=Solidité Increases item durability.=Augmente la durabilité des objets. Inventory=Inventaire -@1 × Lapis Lazuli=@1 × Lapis Lazuli -Enchantment levels: @1=Niveaux d'enchantement: @1 +@1 Lapis Lazuli=@1 Lapis Lazuli +@1 Enchantment Levels=@1 Niveaux d'enchantement Level requirement: @1=Niveau requis: @1 Enchant an item=Enchanter un objet []= [] @@ -85,16 +85,16 @@ Usage: /enchant []=Usage: /enchant []=Usage: /forceenchant [] The target item is not enchantable.=L'objet cible n'est pas enchantable. '@1' is not a valid number.='@1' n'est pas un nombre valide. -Enchanted Book=Livre enchanté +Enchanted Book=Livre enchanté Enchanting Table=Table d'enchantement Enchant=Enchantement diff --git a/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.ru.tr b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.ru.tr index 6ea2038b..6cd1e1db 100644 --- a/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.ru.tr +++ b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.ru.tr @@ -2,7 +2,7 @@ Aqua Affinity=Родство с водой Increases underwater mining speed.=Увеличивает скорость добычи под водой. Bane of Arthropods=Бич членистоногих -Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).=Увеличивает урон и применяет Замедление IV к насекомым и членистоногим (паукам, пещерным паукам, чешуйницам и чешуйницам края). +Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).=Увеличивает урон и применяет Замедление IV к насекомым и членистоногим (паукам, пещерным паукам, чешуйницам и чешуйницам края). Blast Protection=Взрывоустойчивость Reduces explosion damage and knockback.=Уменьшает урон и отдачу от взрывов. Channeling=Громовержец @@ -76,8 +76,8 @@ Reflects some of the damage taken when hit, at the cost of reducing durability w Unbreaking=Нерушимость Increases item durability.=Увеличивает прочность предмета. Inventory=Инвентарь -@1 × Lapis Lazuli=@1 × Ляпис-лазурь -Enchantment levels: @1=Уровень зачаровывания: @1 +@1 Lapis Lazuli=@1 Ляпис-лазурь +@1 Enchantment Levels=@1 Уровень зачаровывания Level requirement: @1=Требуемый уровень: @1 Enchant an item=Зачаровать предмет []=<игрок> <зачарование> [<уровень>] diff --git a/mods/ITEMS/mcl_enchanting/locale/template.txt b/mods/ITEMS/mcl_enchanting/locale/template.txt index f186ef37..08fa8209 100644 --- a/mods/ITEMS/mcl_enchanting/locale/template.txt +++ b/mods/ITEMS/mcl_enchanting/locale/template.txt @@ -76,8 +76,8 @@ Reflects some of the damage taken when hit, at the cost of reducing durability w Unbreaking= Increases item durability.= Inventory= -@1 × Lapis Lazuli= -Enchantment levels: @1= +@1 Lapis Lazuli= +@1 Enchantment Levels= Level requirement: @1= Enchant an item= []= diff --git a/mods/ITEMS/mcl_end/building.lua b/mods/ITEMS/mcl_end/building.lua index 94fd2643..3c8f7f66 100644 --- a/mods/ITEMS/mcl_end/building.lua +++ b/mods/ITEMS/mcl_end/building.lua @@ -1,7 +1,8 @@ -- Building blocks and decorative nodes -local S = minetest.get_translator("mcl_end") +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_screwdriver = minetest.get_modpath("screwdriver") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way diff --git a/mods/ITEMS/mcl_end/chorus_plant.lua b/mods/ITEMS/mcl_end/chorus_plant.lua index 9622e618..24307b5e 100644 --- a/mods/ITEMS/mcl_end/chorus_plant.lua +++ b/mods/ITEMS/mcl_end/chorus_plant.lua @@ -1,7 +1,10 @@ -- Chorus plants -- This includes chorus flowers, chorus plant stem nodes and chorus fruit -local S = minetest.get_translator("mcl_end") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math +local table = table --- Plant parts --- @@ -29,10 +32,10 @@ local no_detach = {} -- This detaches all chorus plants that are/were attached -- at start_pos. -mcl_end.detach_chorus_plant = function(start_pos, digger) +function mcl_end.detach_chorus_plant(start_pos, digger) -- This node should not call a detach function, do NOTHING local hash = minetest.hash_node_position(start_pos) - if no_detach[hash] ~= nil then + if no_detach[hash] then return end @@ -106,11 +109,11 @@ mcl_end.detach_chorus_plant = function(start_pos, digger) no_detach = {} end -mcl_end.check_detach_chorus_plant = function(pos, oldnode, oldmetadata, digger) +function mcl_end.check_detach_chorus_plant(pos, oldnode, oldmetadata, digger) mcl_end.detach_chorus_plant(pos, digger) end -mcl_end.check_blast_chorus_plant = function(pos) +function mcl_end.check_blast_chorus_plant(pos) minetest.remove_node(pos) mcl_end.detach_chorus_plant(pos) end @@ -139,7 +142,7 @@ minetest.register_node("mcl_end:chorus_flower", { node_placement_prediction = "", on_place = function(itemstack, placer, pointed_thing) local node_under = minetest.get_node(pointed_thing.under) - local node_above = minetest.get_node(pointed_thing.above) + --local node_above = minetest.get_node(pointed_thing.above) if placer and not placer:get_player_control().sneak then -- Use pointed node's on_rightclick function first, if present if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then @@ -309,7 +312,7 @@ minetest.register_node("mcl_end:chorus_plant", { }) -- Grow a complete chorus plant at pos -mcl_end.grow_chorus_plant = function(pos, node) +function mcl_end.grow_chorus_plant(pos, node, pr) local flowers = { pos } -- Plant initial flower (if it isn't there already) if not node then @@ -321,7 +324,7 @@ mcl_end.grow_chorus_plant = function(pos, node) while true do local new_flowers_list = {} for f=1, #flowers do - local new_flowers = mcl_end.grow_chorus_plant_step(flowers[f], minetest.get_node(flowers[f])) + local new_flowers = mcl_end.grow_chorus_plant_step(flowers[f], minetest.get_node(flowers[f]), pr) if #new_flowers > 0 then table.insert(new_flowers_list, new_flowers) end @@ -340,7 +343,7 @@ end -- Grow a single step of a chorus plant at pos. -- Pos must be a chorus flower. -mcl_end.grow_chorus_plant_step = function(pos, node) +function mcl_end.grow_chorus_plant_step(pos, node, pr) local new_flower_buds = {} local above = { x = pos.x, y = pos.y + 1, z = pos.z } local node_above = minetest.get_node(above) @@ -396,7 +399,7 @@ mcl_end.grow_chorus_plant_step = function(pos, node) if grow_chance then local new_flowers = {} - local r = math.random(1, 100) + local r = pr:next(1, 100) local age = node.param2 if r <= grow_chance then table.insert(new_flowers, above) @@ -404,13 +407,12 @@ mcl_end.grow_chorus_plant_step = function(pos, node) age = age + 1 local branches if branching == false then - branches = math.random(1, 4) + branches = pr:next(1, 4) elseif branching == true then - branches = math.random(0, 3) + branches = pr:next(0, 3) end - local branch_grown = false for b=1, branches do - local next_branch = math.random(1, #around) + local next_branch = pr:next(1, #around) local branch = vector.add(pos, around[next_branch]) local below_branch = vector.add(branch, {x=0,y=-1,z=0}) if minetest.get_node(below_branch).name == "air" then @@ -451,13 +453,15 @@ mcl_end.grow_chorus_plant_step = function(pos, node) end --- ABM --- +local seed = minetest.get_mapgen_params().seed +local pr = PseudoRandom(seed) minetest.register_abm({ label = "Chorus plant growth", nodenames = { "mcl_end:chorus_flower" }, interval = 35.0, chance = 4.0, action = function(pos, node, active_object_count, active_object_count_wider) - mcl_end.grow_chorus_plant_step(pos, node) + mcl_end.grow_chorus_plant_step(pos, node, pr) end, }) @@ -470,7 +474,7 @@ minetest.register_abm({ -- * Maximum attempts: 16 -- -- Returns true on success. -local random_teleport = function(player) +local function random_teleport(player) local pos = player:get_pos() -- 16 attempts to find a suitable position for a=1, 16 do diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua index 720d8ed8..b7c80c55 100644 --- a/mods/ITEMS/mcl_end/end_crystal.lua +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mcl_end") +local S = minetest.get_translator(minetest.get_current_modname()) + +local vector = vector local explosion_strength = 6 @@ -27,8 +29,16 @@ end local function crystal_explode(self, puncher) if self._exploded then return end self._exploded = true - local strength = puncher and explosion_strength or 1 - mcl_explosions.explode(vector.add(self.object:get_pos(), {x = 0, y = 1.5, z = 0}), strength, {drop_chance = 1}, puncher) + local strength = 1 + local source + if puncher then + strength = explosion_strength + local reason = {} + mcl_damage.from_punch(reason, puncher) + mcl_damage.finish_reason(reason) + source = reason.source + end + mcl_explosions.explode(vector.add(self.object:get_pos(), {x = 0, y = 1.5, z = 0}), strength, {drop_chance = 1}, self.object, source) minetest.after(0, self.object.remove, self.object) end @@ -37,7 +47,7 @@ local function set_crystal_animation(self) end local function spawn_crystal(pos) - local crystal = minetest.add_entity(pos, "mcl_end:crystal") + minetest.add_entity(pos, "mcl_end:crystal") if not vector.equals(pos, vector.floor(pos)) then return end if mcl_worlds.pos_to_dimension(pos) ~= "end" then return end local portal_center diff --git a/mods/ITEMS/mcl_end/eye_of_ender.lua b/mods/ITEMS/mcl_end/eye_of_ender.lua index afac9ebf..ea3d70ab 100644 --- a/mods/ITEMS/mcl_end/eye_of_ender.lua +++ b/mods/ITEMS/mcl_end/eye_of_ender.lua @@ -1,5 +1,5 @@ -- Eye of Ender -local S = minetest.get_translator("mcl_end") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_entity("mcl_end:ender_eye", { physical = false, diff --git a/mods/ITEMS/mcl_farming/beetroot.lua b/mods/ITEMS/mcl_farming/beetroot.lua index 7caf5103..e312aa26 100644 --- a/mods/ITEMS/mcl_farming/beetroot.lua +++ b/mods/ITEMS/mcl_farming/beetroot.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_craftitem("mcl_farming:beetroot_seeds", { description = S("Beetroot Seeds"), diff --git a/mods/ITEMS/mcl_farming/carrots.lua b/mods/ITEMS/mcl_farming/carrots.lua index 4599d39e..7983c58a 100644 --- a/mods/ITEMS/mcl_farming/carrots.lua +++ b/mods/ITEMS/mcl_farming/carrots.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) for i=1, 7 do local texture, sel_height @@ -63,10 +63,10 @@ minetest.register_node("mcl_farming:carrot", { drop = { max_items = 1, items = { - { items = {'mcl_farming:carrot_item 4'}, rarity = 5 }, - { items = {'mcl_farming:carrot_item 3'}, rarity = 2 }, - { items = {'mcl_farming:carrot_item 2'}, rarity = 2 }, - { items = {'mcl_farming:carrot_item 1'} }, + { items = {"mcl_farming:carrot_item 4"}, rarity = 5 }, + { items = {"mcl_farming:carrot_item 3"}, rarity = 2 }, + { items = {"mcl_farming:carrot_item 2"}, rarity = 2 }, + { items = {"mcl_farming:carrot_item 1"} }, } }, selection_box = { @@ -91,7 +91,7 @@ minetest.register_craftitem("mcl_farming:carrot_item", { on_secondary_use = minetest.item_eat(3), on_place = function(itemstack, placer, pointed_thing) local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:carrot_1") - if new ~= nil then + if new then return new else return minetest.do_item_eat(3, nil, itemstack, placer, pointed_thing) @@ -112,9 +112,9 @@ minetest.register_craftitem("mcl_farming:carrot_item_gold", { minetest.register_craft({ output = "mcl_farming:carrot_item_gold", recipe = { - {'mcl_core:gold_nugget', 'mcl_core:gold_nugget', 'mcl_core:gold_nugget'}, - {'mcl_core:gold_nugget', 'mcl_farming:carrot_item', 'mcl_core:gold_nugget'}, - {'mcl_core:gold_nugget', 'mcl_core:gold_nugget', 'mcl_core:gold_nugget'}, + {"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"}, + {"mcl_core:gold_nugget", "mcl_farming:carrot_item", "mcl_core:gold_nugget"}, + {"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"}, } }) diff --git a/mods/ITEMS/mcl_farming/hoes.lua b/mods/ITEMS/mcl_farming/hoes.lua index db470b99..28ad938f 100644 --- a/mods/ITEMS/mcl_farming/hoes.lua +++ b/mods/ITEMS/mcl_farming/hoes.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) local function create_soil(pos, inv) if pos == nil then diff --git a/mods/ITEMS/mcl_farming/melon.lua b/mods/ITEMS/mcl_farming/melon.lua index 38b4c713..b3e49a61 100644 --- a/mods/ITEMS/mcl_farming/melon.lua +++ b/mods/ITEMS/mcl_farming/melon.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) -- Seeds minetest.register_craftitem("mcl_farming:melon_seeds", { @@ -25,11 +25,11 @@ local melon_base_def = { drop = { max_items = 1, items = { - { items = {'mcl_farming:melon_item 7'}, rarity = 14 }, - { items = {'mcl_farming:melon_item 6'}, rarity = 10 }, - { items = {'mcl_farming:melon_item 5'}, rarity = 5 }, - { items = {'mcl_farming:melon_item 4'}, rarity = 2 }, - { items = {'mcl_farming:melon_item 3'} }, + { items = {"mcl_farming:melon_item 7"}, rarity = 14 }, + { items = {"mcl_farming:melon_item 6"}, rarity = 10 }, + { items = {"mcl_farming:melon_item 5"}, rarity = 5 }, + { items = {"mcl_farming:melon_item 4"}, rarity = 2 }, + { items = {"mcl_farming:melon_item 3"} }, } }, sounds = mcl_sounds.node_sound_wood_defaults(), @@ -144,11 +144,11 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_farming:melon', + output = "mcl_farming:melon", recipe = { - {'mcl_farming:melon_item', 'mcl_farming:melon_item', 'mcl_farming:melon_item'}, - {'mcl_farming:melon_item', 'mcl_farming:melon_item', 'mcl_farming:melon_item'}, - {'mcl_farming:melon_item', 'mcl_farming:melon_item', 'mcl_farming:melon_item'}, + {"mcl_farming:melon_item", "mcl_farming:melon_item", "mcl_farming:melon_item"}, + {"mcl_farming:melon_item", "mcl_farming:melon_item", "mcl_farming:melon_item"}, + {"mcl_farming:melon_item", "mcl_farming:melon_item", "mcl_farming:melon_item"}, } }) diff --git a/mods/ITEMS/mcl_farming/potatoes.lua b/mods/ITEMS/mcl_farming/potatoes.lua index a7f5a708..79cd1311 100644 --- a/mods/ITEMS/mcl_farming/potatoes.lua +++ b/mods/ITEMS/mcl_farming/potatoes.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) -- Premature potato plants @@ -67,11 +67,11 @@ minetest.register_node("mcl_farming:potato", { inventory_image = "mcl_farming_potatoes_stage_3.png", drop = { items = { - { items = {'mcl_farming:potato_item 1'} }, - { items = {'mcl_farming:potato_item 1'}, rarity = 2 }, - { items = {'mcl_farming:potato_item 1'}, rarity = 2 }, - { items = {'mcl_farming:potato_item 1'}, rarity = 2 }, - { items = {'mcl_farming:potato_item_poison 1'}, rarity = 50 } + { items = {"mcl_farming:potato_item 1"} }, + { items = {"mcl_farming:potato_item 1"}, rarity = 2 }, + { items = {"mcl_farming:potato_item 1"}, rarity = 2 }, + { items = {"mcl_farming:potato_item 1"}, rarity = 2 }, + { items = {"mcl_farming:potato_item_poison 1"}, rarity = 50 } } }, selection_box = { @@ -97,7 +97,7 @@ minetest.register_craftitem("mcl_farming:potato_item", { on_secondary_use = minetest.item_eat(1), on_place = function(itemstack, placer, pointed_thing) local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:potato_1") - if new ~= nil then + if new then return new else return minetest.do_item_eat(1, nil, itemstack, placer, pointed_thing) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index 72b4e541..5850aa8b 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -1,6 +1,7 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_screwdriver = minetest.get_modpath("screwdriver") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_simple @@ -111,12 +112,17 @@ pumpkin_face_base_def.description = S("Pumpkin") pumpkin_face_base_def._doc_items_longdesc = S("A pumpkin can be worn as a helmet. Pumpkins grow from pumpkin stems, which in turn grow from pumpkin seeds.") pumpkin_face_base_def._doc_items_usagehelp = nil pumpkin_face_base_def.tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face.png"} +pumpkin_face_base_def.groups.armor=1 +pumpkin_face_base_def.groups.non_combat_armor=1 pumpkin_face_base_def.groups.armor_head=1 +pumpkin_face_base_def.groups.non_combat_armor_head=1 pumpkin_face_base_def._mcl_armor_mob_range_factor = 0 pumpkin_face_base_def._mcl_armor_mob_range_mob = "mobs_mc:enderman" -pumpkin_face_base_def.groups.non_combat_armor=1 +pumpkin_face_base_def._mcl_armor_element = "head" +pumpkin_face_base_def._mcl_armor_texture = "mcl_farming_pumpkin_face.png" +pumpkin_face_base_def._mcl_armor_preview = "mcl_farming_pumpkin_face_preview.png" if minetest.get_modpath("mcl_armor") then - pumpkin_face_base_def.on_secondary_use = armor.on_armor_use + pumpkin_face_base_def.on_secondary_use = mcl_armor.equip_on_use end -- Register stem growth diff --git a/mods/ITEMS/mcl_farming/shared_functions.lua b/mods/ITEMS/mcl_farming/shared_functions.lua index c4cb2fd7..e942415f 100644 --- a/mods/ITEMS/mcl_farming/shared_functions.lua +++ b/mods/ITEMS/mcl_farming/shared_functions.lua @@ -1,11 +1,15 @@ +local math = math +local tostring = tostring + mcl_farming.plant_lists = {} + local plant_lists = {} local plant_nodename_to_id_list = {} local function get_intervals_counter(pos, interval, chance) local meta = minetest.get_meta(pos) - local time_speed = tonumber(minetest.settings:get('time_speed') or 72) + local time_speed = tonumber(minetest.settings:get("time_speed") or 72) local current_game_time if time_speed == nil then return 1 @@ -161,7 +165,7 @@ function mcl_farming:place_seed(itemstack, placer, pointed_thing, plantname) if string.find(farmland.name, "mcl_farming:soil") and string.find(place_s.name, "air") then minetest.sound_play(minetest.registered_nodes[plantname].sounds.place, {pos = pos}, true) minetest.add_node(pos, {name=plantname, param2 = minetest.registered_nodes[plantname].place_param2}) - local intervals_counter = get_intervals_counter(pos, 1, 1) + --local intervals_counter = get_intervals_counter(pos, 1, 1) else return end @@ -190,7 +194,7 @@ end function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, stem_itemstring, stem_def, stem_drop, gourd_itemstring, gourd_def, grow_interval, grow_chance, connected_stem_texture, gourd_on_construct_extra) - local connected_stem_names = { + local connected_stem_names = { connected_stem_basename .. "_r", connected_stem_basename .. "_l", connected_stem_basename .. "_t", @@ -206,7 +210,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s -- Connect the stem at stempos to the first neighboring gourd block. -- No-op if not a stem or no gourd block found - local try_connect_stem = function(stempos) + local function try_connect_stem(stempos) local stem = minetest.get_node(stempos) if stem.name ~= full_unconnected_stem then return false @@ -232,7 +236,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s -- Register gourd if not gourd_def.after_dig_node then - gourd_def.after_dig_node = function(blockpos, oldnode, oldmetadata, user) + function gourd_def.after_dig_node(blockpos, oldnode, oldmetadata, user) -- Disconnect any connected stems, turning them back to normal stems for n=1, #neighbors do local offset = neighbors[n] @@ -247,7 +251,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s end end if not gourd_def.on_construct then - gourd_def.on_construct = function(blockpos) + function gourd_def.on_construct(blockpos) -- Connect all unconnected stems at full size for n=1, #neighbors do local stempos = vector.add(blockpos, neighbors[n]) @@ -295,7 +299,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s end if not stem_def.on_construct then - stem_def.on_construct = function(stempos) + function stem_def.on_construct(stempos) -- Connect stem to gourd (if possible) try_connect_stem(stempos) end diff --git a/mods/ITEMS/mcl_farming/soil.lua b/mods/ITEMS/mcl_farming/soil.lua index 0c0e3b83..8b31d888 100644 --- a/mods/ITEMS/mcl_farming/soil.lua +++ b/mods/ITEMS/mcl_farming/soil.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_node("mcl_farming:soil", { tiles = {"mcl_farming_farmland_dry.png", "default_dirt.png"}, @@ -76,7 +76,7 @@ minetest.register_abm({ end -- Check an area of 9×2×9 around the node for nodename (9×9 on same level and 9×9 below) - local check_surroundings = function(pos, nodename) + local function check_surroundings(pos, nodename) local nodes = minetest.find_nodes_in_area({x=pos.x-4,y=pos.y,z=pos.z-4}, {x=pos.x+4,y=pos.y+1,z=pos.z+4}, {nodename}) return #nodes > 0 end @@ -99,7 +99,7 @@ minetest.register_abm({ -- No decay near unloaded areas since these might include water. if not check_surroundings(pos, "ignore") then if wet <= 0 then - local n_def = minetest.registered_nodes[node.name] or nil + --local n_def = minetest.registered_nodes[node.name] or nil local nn = minetest.get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z}) if not nn or not nn.name then return diff --git a/mods/ITEMS/mcl_farming/wheat.lua b/mods/ITEMS/mcl_farming/wheat.lua index e3ee79ea..da1b84b2 100644 --- a/mods/ITEMS/mcl_farming/wheat.lua +++ b/mods/ITEMS/mcl_farming/wheat.lua @@ -1,11 +1,14 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_craftitem("mcl_farming:wheat_seeds", { -- Original Minecraft name: “Seeds” description = S("Wheat Seeds"), _tt_help = S("Grows on farmland"), _doc_items_longdesc = S("Grows into a wheat plant. Chickens like wheat seeds."), - _doc_items_usagehelp = S("Place the wheat seeds on farmland (which can be created with a hoe) to plant a wheat plant. They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it wheat seeds."), + _doc_items_usagehelp = S([[ + Place the wheat seeds on farmland (which can be created with a hoe) to plant a wheat plant. + They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it wheat seeds. + ]]), groups = { craftitem=1 }, inventory_image = "mcl_farming_wheat_seeds.png", on_place = function(itemstack, placer, pointed_thing) @@ -28,7 +31,10 @@ for i=1,7 do if i == 1 then create = true name = S("Premature Wheat Plant") - longdesc = S("Premature wheat plants grow on farmland under sunlight in 8 stages. On hydrated farmland, they grow faster. They can be harvested at any time but will only yield a profit when mature.") + longdesc = S([[ + Premature wheat plants grow on farmland under sunlight in 8 stages. + On hydrated farmland, they grow faster. They can be harvested at any time but will only yield a profit when mature. + ]]) else create = false end @@ -54,7 +60,8 @@ for i=1,7 do {-0.5, -0.5, -0.5, 0.5, sel_heights[i], 0.5} }, }, - groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, + groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, + dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, }) @@ -62,7 +69,10 @@ end minetest.register_node("mcl_farming:wheat", { description = S("Mature Wheat Plant"), - _doc_items_longdesc = S("Mature wheat plants are ready to be harvested for wheat and wheat seeds. They won't grow any further."), + _doc_items_longdesc = S([[ + Mature wheat plants are ready to be harvested for wheat and wheat seeds. + They won't grow any further. + ]]), sunlight_propagates = true, paramtype = "light", paramtype2 = "meshoptions", @@ -75,13 +85,14 @@ minetest.register_node("mcl_farming:wheat", { drop = { max_items = 4, items = { - { items = {'mcl_farming:wheat_seeds'} }, - { items = {'mcl_farming:wheat_seeds'}, rarity = 2}, - { items = {'mcl_farming:wheat_seeds'}, rarity = 5}, - { items = {'mcl_farming:wheat_item'} } + { items = {"mcl_farming:wheat_seeds"} }, + { items = {"mcl_farming:wheat_seeds"}, rarity = 2}, + { items = {"mcl_farming:wheat_seeds"}, rarity = 5}, + { items = {"mcl_farming:wheat_item"} } } }, - groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, + groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1, attached_node=1, + dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, }) @@ -99,14 +110,14 @@ minetest.register_craftitem("mcl_farming:wheat_item", { minetest.register_craft({ output = "mcl_farming:bread", recipe = { - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, } }) minetest.register_craft({ output = "mcl_farming:cookie 8", recipe = { - {'mcl_farming:wheat_item', 'mcl_dye:brown', 'mcl_farming:wheat_item'}, + {"mcl_farming:wheat_item", "mcl_dye:brown", "mcl_farming:wheat_item"}, } }) @@ -131,7 +142,7 @@ minetest.register_craftitem("mcl_farming:bread", { on_secondary_use = minetest.item_eat(5), }) -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local mod_screwdriver = minetest.get_modpath("screwdriver") local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way @@ -144,9 +155,9 @@ minetest.register_node("mcl_farming:hay_block", { is_ground_content = false, stack_max = 64, paramtype2 = "facedir", - is_ground_content = false, on_place = mcl_util.rotate_axis, - groups = {handy=1, hoey=1, flammable=2, fire_encouragement=60, fire_flammability=20, building_block=1, fall_damage_add_percent=-80}, + groups = {handy=1, hoey=1, flammable=2, fire_encouragement=60, + fire_flammability=20, building_block=1, fall_damage_add_percent=-80}, sounds = mcl_sounds.node_sound_leaves_defaults(), on_rotate = on_rotate, _mcl_blast_resistance = 0.5, @@ -154,18 +165,18 @@ minetest.register_node("mcl_farming:hay_block", { }) minetest.register_craft({ - output = 'mcl_farming:hay_block', + output = "mcl_farming:hay_block", recipe = { - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, } }) minetest.register_craft({ - output = 'mcl_farming:wheat_item 9', + output = "mcl_farming:wheat_item 9", recipe = { - {'mcl_farming:hay_block'}, + {"mcl_farming:hay_block"}, } }) diff --git a/mods/ITEMS/mcl_fences/init.lua b/mods/ITEMS/mcl_fences/init.lua index 650854f8..243cc221 100644 --- a/mods/ITEMS/mcl_fences/init.lua +++ b/mods/ITEMS/mcl_fences/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_fences") +local S = minetest.get_translator(minetest.get_current_modname()) -- Node box local p = {-2/16, -0.5, -2/16, 2/16, 0.5, 2/16} @@ -20,7 +20,7 @@ local cz2 = {-2/16, -0.5, 2/16, 2/16, 1.01, 0.5} --unten(quer) z mcl_fences = {} -mcl_fences.register_fence = function(id, fence_name, texture, groups, hardness, blast_resistance, connects_to, sounds) +function mcl_fences.register_fence(id, fence_name, texture, groups, hardness, blast_resistance, connects_to, sounds) local cgroups = table.copy(groups) if cgroups == nil then cgroups = {} end cgroups.fence = 1 @@ -72,11 +72,11 @@ mcl_fences.register_fence = function(id, fence_name, texture, groups, hardness, return fence_id end -mcl_fences.register_fence_gate = function(id, fence_gate_name, texture, groups, hardness, blast_resistance, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close) +function mcl_fences.register_fence_gate(id, fence_gate_name, texture, groups, hardness, blast_resistance, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close) local meta2 local state2 = 0 - local function update_gate(pos, node) + local function update_gate(pos, node) minetest.set_node(pos, node) end @@ -237,7 +237,7 @@ mcl_fences.register_fence_gate = function(id, fence_gate_name, texture, groups, return gate_id, open_gate_id end -mcl_fences.register_fence_and_fence_gate = function(id, fence_name, fence_gate_name, texture_fence, groups, hardness, blast_resistance, connects_to, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close, texture_fence_gate) +function mcl_fences.register_fence_and_fence_gate(id, fence_name, fence_gate_name, texture_fence, groups, hardness, blast_resistance, connects_to, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close, texture_fence_gate) if texture_fence_gate == nil then texture_fence_gate = texture_fence end @@ -272,17 +272,17 @@ for w=1, #woods do mcl_fences.register_fence_and_fence_gate(id, wood[2], wood[3], wood[4], wood_groups, 2, 15, wood_connect, wood_sounds) minetest.register_craft({ - output = 'mcl_fences:'..id..' 3', + output = "mcl_fences:"..id.." 3", recipe = { - {wood[6], 'mcl_core:stick', wood[6]}, - {wood[6], 'mcl_core:stick', wood[6]}, + {wood[6], "mcl_core:stick", wood[6]}, + {wood[6], "mcl_core:stick", wood[6]}, } }) minetest.register_craft({ - output = 'mcl_fences:'..id_gate, + output = "mcl_fences:"..id_gate, recipe = { - {'mcl_core:stick', wood[6], 'mcl_core:stick'}, - {'mcl_core:stick', wood[6], 'mcl_core:stick'}, + {"mcl_core:stick", wood[6], "mcl_core:stick"}, + {"mcl_core:stick", wood[6], "mcl_core:stick"}, } }) end @@ -292,7 +292,7 @@ end mcl_fences.register_fence("nether_brick_fence", S("Nether Brick Fence"), "mcl_fences_fence_nether_brick.png", {pickaxey=1, deco_block=1, fence_nether_brick=1}, 2, 30, {"group:fence_nether_brick"}, mcl_sounds.node_sound_stone_defaults()) minetest.register_craft({ - output = 'mcl_fences:nether_brick_fence 6', + output = "mcl_fences:nether_brick_fence 6", recipe = { {"mcl_nether:nether_brick", "mcl_nether:netherbrick", "mcl_nether:nether_brick"}, {"mcl_nether:nether_brick", "mcl_nether:netherbrick", "mcl_nether:nether_brick"}, diff --git a/mods/ITEMS/mcl_fences/locale/mcl_fences.de.tr b/mods/ITEMS/mcl_fences/locale/mcl_fences.de.tr index 5a76fc59..e4f2a5fa 100644 --- a/mods/ITEMS/mcl_fences/locale/mcl_fences.de.tr +++ b/mods/ITEMS/mcl_fences/locale/mcl_fences.de.tr @@ -1,6 +1,6 @@ # textdomain: mcl_fences Fences are structures which block the way. Fences will connect to each other and solid blocks. They cannot be jumped over with a simple jump.=Zäune sind Gebäude, die den Weg blockieren. Sie verbinden sich gegenseitig und anderen festen Blöcken. Man kann sie nicht mit normalen Sprüngen überspringen. -Fence gates can be opened or closed and can't be jumped over. Fences will connect nicely to fence gates.=Zauntore können geöffnet und geschlossen werden und können nicht übersprungen werden. Zäune werden sich gut mit Zauntoren verbinden. +Fence gates can be opened or closed and can't be jumped over. Fences will connect nicely to fence gates.=Zauntore können geöffnet und geschlossen werden und können nicht übersprungen werden. Zäune lassen sich gut mit Zauntoren verbinden. Right-click the fence gate to open or close it.=Rechtsklicken Sie auf ein Zauntor, um es zu öffnen oder zu schließen. Oak Fence=Eichenzaun Oak Fence Gate=Eichenzauntor diff --git a/mods/ITEMS/mcl_fire/fire_charge.lua b/mods/ITEMS/mcl_fire/fire_charge.lua index f4d2da32..4d18e44e 100644 --- a/mods/ITEMS/mcl_fire/fire_charge.lua +++ b/mods/ITEMS/mcl_fire/fire_charge.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_fire") +local S = minetest.get_translator(minetest.get_current_modname()) local get_node = minetest.get_node local add_entity = minetest.add_entity @@ -6,7 +6,7 @@ local add_entity = minetest.add_entity -- Fire Charge minetest.register_craftitem("mcl_fire:fire_charge", { description = S("Fire Charge"), - _tt_help = S("Dispenser projectile").."\n"..S("Starts fires and ignites blocks"), + _tt_help = S("Dispenser projectile").."\n"..S("Starts fires and ignites blocks"), _doc_items_longdesc = S("Fire charges are primarily projectiles which can be launched from dispensers, they will fly in a straight line and burst into a fire on impact. Alternatively, they can be used to ignite fires directly."), _doc_items_usagehelp = S("Put the fire charge into a dispenser and supply it with redstone power to launch it. To ignite a fire directly, simply place the fire charge on the ground, which uses it up."), inventory_image = "mcl_fire_fire_charge.png", @@ -14,11 +14,9 @@ minetest.register_craftitem("mcl_fire:fire_charge", { stack_max = 64, on_place = function(itemstack, user, pointed_thing) -- Use pointed node's on_rightclick function first, if present - local node = get_node(pointed_thing.under) - if user and not user: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, user, itemstack) or itemstack - end + local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing) + if new_stack then + return new_stack end -- Check protection @@ -29,6 +27,7 @@ minetest.register_craftitem("mcl_fire:fire_charge", { end -- Ignite/light fire + local node = get_node(pointed_thing.under) if pointed_thing.type == "node" then local nodedef = minetest.registered_nodes[node.name] if nodedef and nodedef._on_ignite then @@ -59,7 +58,7 @@ minetest.register_craftitem("mcl_fire:fire_charge", { }) minetest.register_craft({ - type = 'shapeless', - output = 'mcl_fire:fire_charge 3', - recipe = { 'mcl_mobitems:blaze_powder', 'group:coal', 'mcl_mobitems:gunpowder' }, + type = "shapeless", + output = "mcl_fire:fire_charge 3", + recipe = { "mcl_mobitems:blaze_powder", "group:coal", "mcl_mobitems:gunpowder" }, }) diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index b0e711e0..39a4ce88 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -1,11 +1,11 @@ -local S = minetest.get_translator("mcl_fire") +local S = minetest.get_translator(minetest.get_current_modname()) local get_node = minetest.get_node local add_node = minetest.add_node -- Flint and Steel minetest.register_tool("mcl_fire:flint_and_steel", { description = S("Flint and Steel"), - _tt_help = S("Starts fires and ignites blocks"), + _tt_help = S("Starts fires and ignites blocks"), _doc_items_longdesc = S("Flint and steel is a tool to start fires and ignite blocks."), _doc_items_usagehelp = S("Rightclick the surface of a block to attempt to light a fire in front of it or ignite the block. A few blocks have an unique reaction when ignited."), inventory_image = "mcl_fire_flint_and_steel.png", @@ -14,11 +14,9 @@ minetest.register_tool("mcl_fire:flint_and_steel", { groups = { tool = 1, }, on_place = function(itemstack, user, pointed_thing) -- Use pointed node's on_rightclick function first, if present - local node = get_node(pointed_thing.under) - if user and not user: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, user, itemstack) or itemstack - end + local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing) + if new_stack then + return new_stack end -- Check protection local protname = user:get_player_name() @@ -76,7 +74,7 @@ minetest.register_tool("mcl_fire:flint_and_steel", { }) minetest.register_craft({ - type = 'shapeless', - output = 'mcl_fire:flint_and_steel', - recipe = { 'mcl_core:iron_ingot', 'mcl_core:flint'}, + type = "shapeless", + output = "mcl_fire:flint_and_steel", + recipe = { "mcl_core:iron_ingot", "mcl_core:flint"}, }) diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 95d76c45..9f1337a5 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -1,10 +1,10 @@ -- Global namespace for functions mcl_fire = {} -local modpath = minetest.get_modpath(minetest.get_current_modname()) -local S = minetest.get_translator("mcl_fire") -local N = function(s) return s end +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) local has_mcl_portals = minetest.get_modpath("mcl_portals") @@ -47,94 +47,16 @@ local alldirs= { x = 0, y = 0, z = 1} } --- 3 exptime variants because the animation is not tied to particle expiration time. --- 3 colorized variants to imitate minecraft's -local smoke_pdef_base = { - amount = 0.001, - time = 0, - -- minpos = vector.add(pos, { x = -0.45, y = -0.45, z = -0.45 }), - -- maxpos = vector.add(pos, { x = 0.45, y = 0.45, z = 0.45 }), +local smoke_pdef = { + amount = 0.009, + maxexptime = 4.0, minvel = { x = -0.1, y = 0.3, z = -0.1 }, maxvel = { x = 0.1, y = 1.6, z = 0.1 }, - -- minexptime = 3 exptime variants, - -- maxexptime = 3 exptime variants minsize = 4.0, maxsize = 4.5, - -- texture = "mcl_particles_smoke_anim.png^[colorize:#000000:(3 colourize variants)", - animation = { - type = "vertical_frames", - aspect_w = 8, - aspect_h = 8, - -- length = 3 exptime variants - }, - collisiondetection = true, + minrelpos = { x = -0.45, y = -0.45, z = -0.45 }, + maxrelpos = { x = 0.45, y = 0.45, z = 0.45 }, } -local smoke_pdef_cached = {} -local spawn_smoke = function(pos) - local min = math.min - local new_minpos = vector.add(pos, { x = -0.45, y = -0.45, z = -0.45 }) - local new_maxpos = vector.add(pos, { x = 0.45, y = 0.45, z = 0.45 }) - - -- populate the cache - if not next(smoke_pdef_cached) then - -- the last frame plays for 1/8 * N seconds, so we can take advantage of it - -- to have varying exptime for each variant. - local exptimes = { 0.75, 1.5, 4.0 } - local colorizes = { "199", "209", "243" } -- round(78%, 82%, 90% of 256) - 1 - - local id = 1 - for _,exptime in ipairs(exptimes) do - for _,colorize in ipairs(colorizes) do - smoke_pdef_base.minpos = new_minpos - smoke_pdef_base.maxpos = new_maxpos - smoke_pdef_base.maxexptime = exptime - smoke_pdef_base.animation.length = exptime + 0.1 - -- minexptime must be set such that the last frame is actully rendered, - -- even if its very short. Larger exptime -> larger range - smoke_pdef_base.minexptime = min(exptime, (7.0/8.0 * (exptime + 0.1) + 0.1)) - smoke_pdef_base.texture = "mcl_particles_smoke_anim.png^[colorize:#000000:" ..colorize - - smoke_pdef_cached[id] = table.copy(smoke_pdef_base) - - mcl_particles.add_node_particlespawner(pos, smoke_pdef_cached[id], "high") - - id = id + 1 - end - end - - -- cache already populated - else - for i, smoke_pdef in ipairs(smoke_pdef_cached) do - smoke_pdef.minpos = new_minpos - smoke_pdef.maxpos = new_maxpos - mcl_particles.add_node_particlespawner(pos, smoke_pdef, "high") - end - end - ---[[ Old smoke pdef - local spawn_smoke = function(pos) - mcl_particles.add_node_particlespawner(pos, { - amount = 0.1, - time = 0, - minpos = vector.add(pos, { x = -0.45, y = -0.45, z = -0.45 }), - maxpos = vector.add(pos, { x = 0.45, y = 0.45, z = 0.45 }), - minvel = { x = 0, y = 0.5, z = 0 }, - maxvel = { x = 0, y = 0.6, z = 0 }, - minexptime = 2.0, - maxexptime = 2.0, - minsize = 3.0, - maxsize = 4.0, - texture = "mcl_particles_smoke_anim.png^[colorize:#000000:127", - animation = { - type = "vertical_frames", - aspect_w = 8, - aspect_h = 8, - length = 2.1, - }, - }, "high") - -- ]] - -end -- -- Items @@ -164,18 +86,11 @@ else eternal_fire_help = S("Eternal fire is a damaging block. Eternal fire can be extinguished by punches and nearby water blocks. Other than (normal) fire, eternal fire does not get extinguished on its own and also continues to burn under rain. Punching eternal fire is safe, but it hurts if you stand inside.") end -local fire_death_messages = { - N("@1 has been cooked crisp."), - N("@1 felt the burn."), - N("@1 died in the flames."), - N("@1 died in a fire."), -} - -local fire_timer = function(pos) +local function fire_timer(pos) minetest.get_node_timer(pos):start(math.random(3, 7)) end -local spawn_fire = function(pos, age) +local function spawn_fire(pos, age) set_node(pos, {name="mcl_fire:fire", param2 = age}) minetest.check_single_for_falling({x=pos.x, y=pos.y+1, z=pos.z}) end @@ -202,7 +117,6 @@ minetest.register_node("mcl_fire:fire", { buildable_to = true, sunlight_propagates = true, damage_per_second = 1, - _mcl_node_death_message = fire_death_messages, groups = {fire = 1, dig_immediate = 3, not_in_creative_inventory = 1, dig_by_piston=1, destroys_items=1, set_on_fire=8}, floodable = true, on_flood = function(pos, oldnode, newnode) @@ -303,7 +217,7 @@ minetest.register_node("mcl_fire:fire", { end fire_timer(pos) - spawn_smoke(pos) + mcl_particles.spawn_smoke(pos, "fire", smoke_pdef) end, on_destruct = function(pos) mcl_particles.delete_node_particlespawners(pos) @@ -333,7 +247,6 @@ minetest.register_node("mcl_fire:eternal_fire", { buildable_to = true, sunlight_propagates = true, damage_per_second = 1, - _mcl_node_death_message = fire_death_messages, groups = {fire = 1, dig_immediate = 3, not_in_creative_inventory = 1, dig_by_piston = 1, destroys_items = 1, set_on_fire=8}, floodable = true, on_flood = function(pos, oldnode, newnode) @@ -367,7 +280,7 @@ minetest.register_node("mcl_fire:eternal_fire", { if has_mcl_portals then --Calling directly minetest.get_modpath consumes 4x more compute time mcl_portals.light_nether_portal(pos) end - spawn_smoke(pos) + mcl_particles.spawn_smoke(pos, "fire", smoke_pdef) end, on_destruct = function(pos) mcl_particles.delete_node_particlespawners(pos) @@ -600,7 +513,7 @@ end -- * pointed_thing: Pointed thing to ignite -- * player: Player who sets fire or nil if nobody -- * allow_on_fire: If false, can't ignite fire on fire (default: true) -mcl_fire.set_fire = function(pointed_thing, player, allow_on_fire) +function mcl_fire.set_fire(pointed_thing, player, allow_on_fire) local pname if player == nil then pname = "" @@ -627,7 +540,7 @@ minetest.register_lbm({ nodenames = {"group:fire"}, run_at_every_load = true, action = function(pos, node) - spawn_smoke(pos) + mcl_particles.spawn_smoke(pos, "fire", smoke_pdef) end, }) diff --git a/mods/ITEMS/mcl_fire/mod.conf b/mods/ITEMS/mcl_fire/mod.conf index da94d927..4a1d52ee 100644 --- a/mods/ITEMS/mcl_fire/mod.conf +++ b/mods/ITEMS/mcl_fire/mod.conf @@ -1,3 +1,3 @@ name = mcl_fire -depends = mcl_core, mcl_worlds, mcl_sounds, mcl_particles +depends = mcl_core, mcl_worlds, mcl_sounds, mcl_particles, mcl_util optional_depends = mcl_portals \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/README.txt b/mods/ITEMS/mcl_fireworks/README.txt new file mode 100644 index 00000000..4cf71fc9 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/README.txt @@ -0,0 +1,7 @@ +Firework mod for Mineclone 2 + +by NO11 and and some parts by j45 + +Sound credits: + +* mcl_firework_rocket.ogg (tnt_ignite.ogg): Own derivate work of sound by Ned Bouhalassa (CC0) created in 2005, source: diff --git a/mods/ITEMS/mcl_fireworks/crafting.lua b/mods/ITEMS/mcl_fireworks/crafting.lua new file mode 100644 index 00000000..a9e156aa --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/crafting.lua @@ -0,0 +1,17 @@ +minetest.register_craft({ + type = "shapeless", + output = "mcl_fireworks:rocket_1 3", + recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "mcl_fireworks:rocket_2 3", + recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "mcl_fireworks:rocket_3 3", + recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, +}) \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/init.lua b/mods/ITEMS/mcl_fireworks/init.lua new file mode 100644 index 00000000..cd192258 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/init.lua @@ -0,0 +1,4 @@ +local path = minetest.get_modpath("mcl_fireworks") + +dofile(path .. "/register.lua") +dofile(path .. "/crafting.lua") \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.de.tr b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.de.tr new file mode 100644 index 00000000..9f909810 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.de.tr @@ -0,0 +1,3 @@ +# textdomain: mcl_fireworks +Firework Rocket=Feuerwerksrakete +Flight Duration:=Flugdauer: \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/locale/template.txt b/mods/ITEMS/mcl_fireworks/locale/template.txt new file mode 100644 index 00000000..e66eb06a --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/locale/template.txt @@ -0,0 +1,3 @@ +# textdomain: mcl_fireworks +Firework Rocket= +Flight Duration:= \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/mod.conf b/mods/ITEMS/mcl_fireworks/mod.conf new file mode 100644 index 00000000..cf9e34e9 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/mod.conf @@ -0,0 +1,2 @@ +name = mcl_fireworks +description = Adds fun fireworks to the game which players can use. \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua new file mode 100644 index 00000000..23066b66 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -0,0 +1,28 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +local tt_help = S("Flight Duration:") +local description = S("Firework Rocket") + +local function register_rocket(n, duration, force) + minetest.register_craftitem("mcl_fireworks:rocket_" .. n, { + description = description, + _tt_help = tt_help .. " " .. duration, + inventory_image = "mcl_fireworks_rocket.png", + stack_max = 64, + on_use = function(itemstack, user, pointed_thing) + local elytra = mcl_playerplus.elytra[user] + if elytra.active and elytra.rocketing <= 0 then + elytra.rocketing = duration + if not minetest.is_creative_enabled(user:get_player_name()) then + itemstack:take_item() + end + minetest.sound_play("mcl_fireworks_rocket", {pos = user:get_pos()}) + end + return itemstack + end, + }) +end + +register_rocket(1, 2.2, 10) +register_rocket(2, 4.5, 20) +register_rocket(3, 6, 30) diff --git a/mods/ITEMS/mcl_fireworks/sounds/mcl_fireworks_rocket.ogg b/mods/ITEMS/mcl_fireworks/sounds/mcl_fireworks_rocket.ogg new file mode 100644 index 00000000..aa232f0d Binary files /dev/null and b/mods/ITEMS/mcl_fireworks/sounds/mcl_fireworks_rocket.ogg differ diff --git a/mods/ITEMS/mcl_fireworks/textures/mcl_fireworks_rocket.png b/mods/ITEMS/mcl_fireworks/textures/mcl_fireworks_rocket.png new file mode 100644 index 00000000..682a8c40 Binary files /dev/null and b/mods/ITEMS/mcl_fireworks/textures/mcl_fireworks_rocket.png differ diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index 2bd0ed51..e0c78832 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -1,11 +1,6 @@ --Fishing Rod, Bobber, and Flying Bobber mechanics and Bobber artwork by Rootyjr. -local S = minetest.get_translator("mcl_fishing") -local mod_throwing = minetest.get_modpath("mcl_throwing") - -local entity_mapping = { - ["mcl_fishing:bobber"] = "mcl_fishing:bobber_entity", -} +local S = minetest.get_translator(minetest.get_current_modname()) local bobber_ENTITY={ physical = false, @@ -42,8 +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 @@ -61,7 +55,6 @@ local fish = function(itemstack, player, pointed_thing) local itemname local items local itemcount = 1 - local itemwear = 0 local pr = PseudoRandom(os.time() * math.random(1, 100)) local r = pr:next(1, 100) local fish_values = {85, 84.8, 84.7, 84.5} @@ -173,7 +166,7 @@ local fish = function(itemstack, player, pointed_thing) if noent == true then local playerpos = player:get_pos() local dir = player:get_look_dir() - local obj = mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name()) + mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name()) end end @@ -197,7 +190,7 @@ local bobber_on_step = function(self, dtime) end local wield = player:get_wielded_item() --Check if player is nearby - if self.player ~= nil and player ~= nil then + if self.player and player then --Destroy bobber if item not wielded. if ((not wield) or (minetest.get_item_group(wield:get_name(), "fishing_rod") <= 0)) then self.object:remove() @@ -312,7 +305,7 @@ local flying_bobber_ENTITY={ } -- Movement function of flying bobber -local flying_bobber_on_step = function(self, dtime) +local function flying_bobber_on_step(self, dtime) self.timer=self.timer+dtime local pos = self.object:get_pos() local node = minetest.get_node(pos) @@ -322,12 +315,9 @@ local flying_bobber_on_step = function(self, dtime) -- Destroy when hitting a solid node if self._lastpos.x~=nil then if (def and (def.walkable or def.liquidtype == "flowing" or def.liquidtype == "source")) or not def then - local make_child= function(object) - local ent = object:get_luaentity() - ent.player = self._thrower - ent.child = true - end - make_child(minetest.add_entity(self._lastpos, "mcl_fishing:bobber_entity")) + local ent = minetest.add_entity(self._lastpos, "mcl_fishing:bobber_entity"):get_luaentity() + ent.player = self._thrower + ent.child = true self.object:remove() return end @@ -344,10 +334,8 @@ mcl_throwing.register_throwable_object("mcl_fishing:flying_bobber", "mcl_fishing -- If player leaves area, remove bobber. minetest.register_on_leaveplayer(function(player) local objs = minetest.get_objects_inside_radius(player:get_pos(), 250) - local num = 0 local ent = nil local noent = true - for n = 1, #objs do ent = objs[n]:get_luaentity() if ent then @@ -400,17 +388,17 @@ minetest.register_tool("mcl_fishing:fishing_rod", { minetest.register_craft({ output = "mcl_fishing:fishing_rod", recipe = { - {'','','mcl_core:stick'}, - {'','mcl_core:stick','mcl_mobitems:string'}, - {'mcl_core:stick','','mcl_mobitems:string'}, + {"","","mcl_core:stick"}, + {"","mcl_core:stick","mcl_mobitems:string"}, + {"mcl_core:stick","","mcl_mobitems:string"}, } }) minetest.register_craft({ output = "mcl_fishing:fishing_rod", recipe = { - {'mcl_core:stick', '', ''}, - {'mcl_mobitems:string', 'mcl_core:stick', ''}, - {'mcl_mobitems:string','','mcl_core:stick'}, + {"mcl_core:stick", "", ""}, + {"mcl_mobitems:string", "mcl_core:stick", ""}, + {"mcl_mobitems:string","","mcl_core:stick"}, } }) minetest.register_craft({ diff --git a/mods/ITEMS/mcl_fishing/locale/mcl_fishing.de.tr b/mods/ITEMS/mcl_fishing/locale/mcl_fishing.de.tr index 10f90859..b80c186c 100644 --- a/mods/ITEMS/mcl_fishing/locale/mcl_fishing.de.tr +++ b/mods/ITEMS/mcl_fishing/locale/mcl_fishing.de.tr @@ -7,12 +7,12 @@ Raw fish is obtained by fishing and is a food item which can be eaten safely. Co Cooked Fish=Gekochter Fisch Mmh, fish! This is a healthy food item.=Mhh, Fisch! Ein gesundes Lebensmittel. Raw Salmon=Roher Lachs -Raw salmon is obtained by fishing and is a food item which can be eaten safely. Cooking it improves its nutritional value.=Lohen Lachs erhält man beim Angeln. Er ist ein Lebensmittel, der sicher verzehrt werden kann. +Raw salmon is obtained by fishing and is a food item which can be eaten safely. Cooking it improves its nutritional value.=Rohen Lachs erhält man beim Angeln. Er ist ein Lebensmittel, das sicher verzehrt werden kann. Cooked Salmon=Gekochter Lachs This is a healthy food item which can be eaten.=Ein gesundes essbares Lebensmittel. Clownfish=Clownfisch -Clownfish may be obtained by fishing (and luck) and is a food item which can be eaten safely.=Einen Clownfisch kann man beim Angeln mit etwas Glück fangen. Er ist ein Lebensmittel, der sicher verzehrt werden kann. +Clownfish may be obtained by fishing (and luck) and is a food item which can be eaten safely.=Einen Clownfisch kann man beim Angeln mit etwas Glück fangen. Er ist ein Lebensmittel, das sicher verzehrt werden kann. Pufferfish=Kugelfisch -Pufferfish are a common species of fish and can be obtained by fishing. They can technically be eaten, but they are very bad for humans. Eating a pufferfish only restores 1 hunger point and will poison you very badly (which drains your health non-fatally) and causes serious food poisoning (which increases your hunger).=Kugelfische sind eine verbreitete Fischart, die geangelt werden können. Sie können theoretisch gegessen werden, aber sie sind sehr schlecht für Menschen. Es gibt nur 1 Hungerpunkt und es wird Sie schwer vergiften (was Ihre Gesundheit verringert, aber nicht bis zum Tod) und Ihr Hungerpegel wird aufgrund der schweren Lebensmittelvergiftung stark ansteigen. +Pufferfish are a common species of fish and can be obtained by fishing. They can technically be eaten, but they are very bad for humans. Eating a pufferfish only restores 1 hunger point and will poison you very badly (which drains your health non-fatally) and causes serious food poisoning (which increases your hunger).=Kugelfische sind eine verbreitete Fischart, die geangelt werden kann. Sie können theoretisch gegessen werden, aber sie sind sehr schlecht für Menschen. Es gibt nur 1 Hungerpunkt und es wird Sie schwer vergiften (was Ihre Gesundheit verringert, aber nicht bis zum Tod) und Ihr Hungerpegel wird aufgrund der schweren Lebensmittelvergiftung stark ansteigen. Catches fish in water=Fängt Fische im Wasser Very poisonous=Sehr giftig diff --git a/mods/ITEMS/mcl_flowerpots/init.lua b/mods/ITEMS/mcl_flowerpots/init.lua index 21d4c04e..578553b3 100644 --- a/mods/ITEMS/mcl_flowerpots/init.lua +++ b/mods/ITEMS/mcl_flowerpots/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_flowerpots") +local S = minetest.get_translator(minetest.get_current_modname()) local has_doc = minetest.get_modpath("doc") mcl_flowerpots = {} @@ -49,11 +49,11 @@ minetest.register_node("mcl_flowerpots:flower_pot", { }) minetest.register_craft({ - output = 'mcl_flowerpots:flower_pot', + output = "mcl_flowerpots:flower_pot", recipe = { - {'mcl_core:brick', '', 'mcl_core:brick'}, - {'', 'mcl_core:brick', ''}, - {'', '', ''}, + {"mcl_core:brick", "", "mcl_core:brick"}, + {"", "mcl_core:brick", ""}, + {"", "", ""}, } }) diff --git a/mods/ITEMS/mcl_flowerpots/locale/mcl_flowerpots.de.tr b/mods/ITEMS/mcl_flowerpots/locale/mcl_flowerpots.de.tr index 3031e38d..a110d5ff 100644 --- a/mods/ITEMS/mcl_flowerpots/locale/mcl_flowerpots.de.tr +++ b/mods/ITEMS/mcl_flowerpots/locale/mcl_flowerpots.de.tr @@ -1,6 +1,6 @@ # textdomain: mcl_flowerpots Dandelion Flower Pot=Blumentopf mit Löwenzahn -Poppy Floer Pot=Blumentopf mit Mohn +Poppy Flower Pot=Blumentopf mit Mohn Blue Orchid Flower Pot=Blumentopf mit blauer Orchidee Allium Flower Pot=Blumentopf mit Sternlauch Azure Bluet Flower Pot=Blumentopf mit Porzellansternchen diff --git a/mods/ITEMS/mcl_flowerpots/locale/mcl_flowerpots.es.tr b/mods/ITEMS/mcl_flowerpots/locale/mcl_flowerpots.es.tr index b303194b..fd12b1b4 100644 --- a/mods/ITEMS/mcl_flowerpots/locale/mcl_flowerpots.es.tr +++ b/mods/ITEMS/mcl_flowerpots/locale/mcl_flowerpots.es.tr @@ -1,6 +1,6 @@ # textdomain: mcl_flowerpots Dandelion Flower Pot=Maceta con diente de león -Poppy Floer Pot=Maceta con amapola +Poppy Flower Pot=Maceta con amapola Blue Orchid Flower Pot=Maceta con orquídeas azules Allium Flower Pot=Maceta con puerro Azure Bluet Flower Pot=Maceta con flor azul celeste @@ -22,4 +22,4 @@ Fern Flower Pot=Maceta con helecho Cactus Flower Pot=Maceta con cactus Flower Pot=Maceta Flower pots are decorative blocks in which flowers and other small plants can be placed.=Las macetas son bloques decorativos en los que se pueden colocar flores y otras plantas pequeñas. -Just place a plant on the flower pot. Flower pots can hold small flowers (not higher than 1 block), saplings, ferns, dead bushes, mushrooms and cacti. Rightclick a potted plant to retrieve the plant.=Simplemente coloque una planta en la maceta. Las macetas pueden contener flores pequeñas (no más de 1 bloque), árboles jóvenes, helechos, arbustos muertos, hongos y cactus. Haga clic derecho en una planta en maceta para recuperar la planta. \ No newline at end of file +Just place a plant on the flower pot. Flower pots can hold small flowers (not higher than 1 block), saplings, ferns, dead bushes, mushrooms and cacti. Rightclick a potted plant to retrieve the plant.=Simplemente coloque una planta en la maceta. Las macetas pueden contener flores pequeñas (no más de 1 bloque), árboles jóvenes, helechos, arbustos muertos, hongos y cactus. Haga clic derecho en una planta en maceta para recuperar la planta. diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index a155ebd0..14e0df5c 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -1,7 +1,9 @@ -local S = minetest.get_translator("mcl_flowers") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + +local mod_screwdriver = minetest.get_modpath("screwdriver") local has_mcl_flowerpots = minetest.get_modpath("mcl_flowerpots") -local modpath = minetest.get_modpath("mcl_flowers") mcl_flowers = {} mcl_flowers.registered_simple_flowers = {} @@ -58,7 +60,7 @@ function mcl_flowers.register_simple_flower(name, def) local newname = "mcl_flowers:"..name if not def._mcl_silk_touch_drop then def._mcl_silk_touch_drop = nil end if not def.drop then def.drop = newname end - mcl_flowers.registered_simple_flowers[newname] = { + mcl_flowers.registered_simple_flowers[newname] = { name=name, desc=def.desc, image=def.image, @@ -101,10 +103,10 @@ local wheat_seed_drop = { max_items = 1, items = { { - items = {'mcl_farming:wheat_seeds'}, + items = {"mcl_farming:wheat_seeds"}, rarity = 8, }, - } + }, } local fortune_wheat_seed_drop = { @@ -180,12 +182,12 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im if not inv_img then inv_img = top_img end - local usagehelp, noncreative, create_entry, paramtype2, palette + local create_entry, paramtype2, palette if is_flower == nil then is_flower = true end - local bottom_groups = {flammable=2,fire_encouragement=60,fire_flammability=100, non_mycelium_plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1, plant=1,double_plant=1,deco_block=1,not_in_creative_inventory=noncreative} + local bottom_groups = {flammable=2, fire_encouragement=60, fire_flammability=100, non_mycelium_plant=1, attached_node=1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1, plant=1, double_plant=1, deco_block=1} if is_flower then bottom_groups.flower = 1 bottom_groups.place_flowerlike = 1 @@ -200,7 +202,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im palette = "mcl_core_palette_grass.png" end if longdesc == nil then - noncreative = 1 + bottom_groups.not_in_creative_inventory = 1 create_entry = false end -- Drop itself by default @@ -458,7 +460,6 @@ minetest.register_node("mcl_flowers:waterlily", { end end end - return itemstack end, on_rotate = on_rotate, @@ -469,32 +470,29 @@ minetest.register_alias("mcl_core:tallgrass", "mcl_flowers:tallgrass") -- mcimport support: re-adds missing double_plant tops in mcimported worlds. local mg_name = minetest.get_mapgen_setting("mg_name") -local mod_mcimport = minetest.get_modpath("mcimport") ~= nil +local mod_mcimport = minetest.get_modpath("mcimport") + local fix_doubleplants = minetest.settings:get_bool("fix_doubleplants", true) +if mod_mcimport and mg_name == "singlenode" and fix_doubleplants == true then + local flowernames = { "peony", "rose_bush", "lilac", "sunflower", "double_fern", "double_grass" } - if mod_mcimport and mg_name == "singlenode" and fix_doubleplants == true then - local flowernames = { "peony", "rose_bush", "lilac", "sunflower", "double_fern", "double_grass" } - for c=1, 6 do - local flowername = flowernames[c] - end - - minetest.register_lbm({ - label = "Add double plant tops.", - name = "mcl_flowers:double_plant_topper", - run_at_every_load = true, - nodenames = { "mcl_flowers:peony", "mcl_flowers:rose_bush", "mcl_flowers:lilac", "mcl_flowers:sunflower", "mcl_flowers:double_fern", "mcl_flowers:double_grass" }, - action = function(pos, node) - for c=1, 6 do - local flowername = flowernames[c] - local bottom = pos - local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } - if node.name == "mcl_flowers:"..flowername then - minetest.set_node(top, {name = "mcl_flowers:"..flowername.."_top"}) - end + minetest.register_lbm({ + label = "Add double plant tops.", + name = "mcl_flowers:double_plant_topper", + run_at_every_load = true, + nodenames = { "mcl_flowers:peony", "mcl_flowers:rose_bush", "mcl_flowers:lilac", "mcl_flowers:sunflower", "mcl_flowers:double_fern", "mcl_flowers:double_grass" }, + action = function(pos, node) + for c = 1, 6 do + local flowername = flowernames[c] + local bottom = pos + local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } + if node.name == "mcl_flowers:"..flowername then + minetest.set_node(top, {name = "mcl_flowers:"..flowername.."_top"}) end - end, - }) - end + end + end, + }) +end dofile(modpath.."/register.lua") diff --git a/mods/ITEMS/mcl_flowers/locale/mcl_flowers.de.tr b/mods/ITEMS/mcl_flowers/locale/mcl_flowers.de.tr index 7c4a83b8..0e1262e3 100644 --- a/mods/ITEMS/mcl_flowers/locale/mcl_flowers.de.tr +++ b/mods/ITEMS/mcl_flowers/locale/mcl_flowers.de.tr @@ -12,9 +12,9 @@ Allium=Sternlauch Azure Bluet=Porzellansternchen Blue Orchid=Blaue Orchidee Tall Grass=Hohes Gras -Tall grass is a small plant which often occurs on the surface of grasslands. It can be harvested for wheat seeds. By using bone meal, tall grass can be turned into double tallgrass which is two blocks high.=Hohes Gras ist eine kleine Pflanze, die oft auf Wiesenflächen wächst. Es kann für Weizensamen abgeerntet werden. Mit Knochenmehl wird sich hohes Gras zu doppelhohem Gras verwandeln. +Tall grass is a small plant which often occurs on the surface of grasslands. It can be harvested for wheat seeds. By using bone meal, tall grass can be turned into double tallgrass which is two blocks high.=Hohes Gras ist eine kleine Pflanze, die oft auf Wiesenflächen wächst. Es kann für Weizensamen abgeerntet werden. Mit Knochenmehl lässt sich hohes Gras zu doppelhohem Gras verwandeln. Fern=Farn -Ferns are small plants which occur naturally in jungles and taigas. They can be harvested for wheat seeds. By using bone meal, a fern can be turned into a large fern which is two blocks high.=Farne sind kleine Pflanzen, die oft in Dschungeln und Taigas vorkommen. Sie können für Weizensamen abgeerntet werden. Mit Knochenmehl wird sich ein Farn zu einem großen Farn, der zwei Blöcke hoch ist, verwandeln. +Ferns are small plants which occur naturally in jungles and taigas. They can be harvested for wheat seeds. By using bone meal, a fern can be turned into a large fern which is two blocks high.=Farne sind kleine Pflanzen, die oft in Dschungeln und Taigas vorkommen. Sie können für Weizensamen abgeerntet werden. Mit Knochenmehl lässt sich ein Farn zu einem großen Farn, der zwei Blöcke hoch ist, verwandeln. (Top Part)=(Oberseite) Peony=Pfingstrose A peony is a large plant which occupies two blocks. It is mainly used in dye production.=Eine Pfingstrose ist eine große Pflanze, die zwei Blöcke hoch ist. Sie wird hauptsächlich für die Farbenproduktion gebraucht. diff --git a/mods/ITEMS/mcl_flowers/register.lua b/mods/ITEMS/mcl_flowers/register.lua index 9b65caeb..b45f3e1e 100644 --- a/mods/ITEMS/mcl_flowers/register.lua +++ b/mods/ITEMS/mcl_flowers/register.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_flowers") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_flowers.register_simple_flower("poppy", { desc = S("Poppy"), diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index 1d1ecc03..e31406f6 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -1,5 +1,5 @@ -local S = minetest.get_translator("mcl_furnaces") +local S = minetest.get_translator(minetest.get_current_modname()) local LIGHT_ACTIVE_FURNACE = 13 @@ -9,12 +9,12 @@ local LIGHT_ACTIVE_FURNACE = 13 local function active_formspec(fuel_percent, item_percent) return "size[9,8.75]".. - "label[0,4;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. "list[current_player;main;0,7.74;9,1;]".. mcl_formspec.get_itemslot_bg(0,7.74,9,1).. - "label[2.75,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Furnace"))).."]".. + "label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Furnace"))).."]".. "list[current_name;src;2.75,0.5;1,1;]".. mcl_formspec.get_itemslot_bg(2.75,0.5,1,1).. "list[current_name;fuel;2.75,2.5;1,1;]".. @@ -38,12 +38,12 @@ local function active_formspec(fuel_percent, item_percent) end local inactive_formspec = "size[9,8.75]".. - "label[0,4;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,4.5,9,3).. "list[current_player;main;0,7.74;9,1;]".. mcl_formspec.get_itemslot_bg(0,7.74,9,1).. - "label[2.75,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Furnace"))).."]".. + "label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Furnace"))).."]".. "list[current_name;src;2.75,0.5;1,1;]".. mcl_formspec.get_itemslot_bg(2.75,0.5,1,1).. "list[current_name;fuel;2.75,2.5;1,1;]".. @@ -217,14 +217,14 @@ end local function furnace_reset_delta_time(pos) local meta = minetest.get_meta(pos) - local time_speed = tonumber(minetest.settings:get('time_speed') or 72) + local time_speed = tonumber(minetest.settings:get("time_speed") or 72) if (time_speed < 0.1) then return end local time_multiplier = 86400 / time_speed local current_game_time = .0 + ((minetest.get_day_count() + minetest.get_timeofday()) * time_multiplier) - -- TODO: Change meta:get/set_string() to get/set_float() for 'last_gametime'. + -- TODO: Change meta:get/set_string() to get/set_float() for "last_gametime". -- In Windows *_float() works OK but under Linux it returns rounded unusable values like 449540.000000000 local last_game_time = meta:get_string("last_gametime") if last_game_time then @@ -239,7 +239,7 @@ end local function furnace_get_delta_time(pos, elapsed) local meta = minetest.get_meta(pos) - local time_speed = tonumber(minetest.settings:get('time_speed') or 72) + local time_speed = tonumber(minetest.settings:get("time_speed") or 72) local current_game_time if (time_speed < 0.1) then return meta, elapsed @@ -384,7 +384,6 @@ local function furnace_node_timer(pos, elapsed) -- Update formspec and node -- local formspec = inactive_formspec - local item_state local item_percent = 0 if cookable then item_percent = math.floor(src_time / cooked.time * 100) @@ -414,7 +413,7 @@ local function furnace_node_timer(pos, elapsed) meta:set_float("fuel_time", fuel_time) meta:set_float("src_time", src_time) if srclist then - meta:set_string("src_item", srclist[1]:get_name()) + meta:set_string("src_item", src_item) else meta:set_string("src_item", "") end @@ -441,7 +440,12 @@ minetest.register_node("mcl_furnaces:furnace", { _tt_help = S("Uses fuel to smelt or cook items"), _doc_items_longdesc = S("Furnaces cook or smelt several items, using a furnace fuel, into something else."), _doc_items_usagehelp = - S("Use the furnace to open the furnace menu. Place a furnace fuel in the lower slot and the source material in the upper slot. The furnace will slowly use its fuel to smelt the item. The result will be placed into the output slot at the right side.").."\n".. + S([[ + Use the furnace to open the furnace menu. + Place a furnace fuel in the lower slot and the source material in the upper slot. + The furnace will slowly use its fuel to smelt the item. + The result will be placed into the output slot at the right side. + ]]).."\n".. S("Use the recipe book to see what you can smelt, what you can use as fuel and how long it will burn."), _doc_items_hidden = false, tiles = { @@ -474,9 +478,9 @@ minetest.register_node("mcl_furnaces:furnace", { local meta = minetest.get_meta(pos) meta:set_string("formspec", inactive_formspec) local inv = meta:get_inventory() - inv:set_size('src', 1) - inv:set_size('fuel', 1) - inv:set_size('dst', 1) + inv:set_size("src", 1) + inv:set_size("fuel", 1) + inv:set_size("dst", 1) end, on_destruct = function(pos) mcl_particles.delete_node_particlespawners(pos) diff --git a/mods/ITEMS/mcl_furnaces/mod.conf b/mods/ITEMS/mcl_furnaces/mod.conf index 99a1ad0b..fe0b9c20 100644 --- a/mods/ITEMS/mcl_furnaces/mod.conf +++ b/mods/ITEMS/mcl_furnaces/mod.conf @@ -1,3 +1,3 @@ name = mcl_furnaces -depends = mcl_init, mcl_formspec, mcl_core, mcl_sounds, mcl_craftguide, mcl_achievements, mcl_particles, mcl_colors +depends = mcl_init, mcl_formspec, mcl_core, mcl_sounds, mcl_craftguide, mcl_achievements, mcl_particles optional_depends = doc, screwdriver diff --git a/mods/ITEMS/mcl_heads/init.lua b/mods/ITEMS/mcl_heads/init.lua index 2000c707..78356de7 100644 --- a/mods/ITEMS/mcl_heads/init.lua +++ b/mods/ITEMS/mcl_heads/init.lua @@ -1,11 +1,11 @@ -local S = minetest.get_translator("mcl_heads") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") local mod_screwdriver = minetest.get_modpath("screwdriver") local equip_armor if minetest.get_modpath("mcl_armor") then - equip_armor = armor.on_armor_use + equip_armor = mcl_armor.equip_on_use end -- Heads system @@ -42,7 +42,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) { -0.25, -0.5, -0.25, 0.25, 0.0, 0.25, }, }, }, - groups = {handy=1, armor_head=1,non_combat_armor=1, head=1, deco_block=1, dig_by_piston=1 }, + groups = {handy = 1, armor = 1, armor_head = 1, non_combat_armor = 1, non_combat_armor_head = 1, head = 1, deco_block = 1, dig_by_piston = 1}, -- The head textures are based off the textures of an actual mob. tiles = { -- Note: bottom texture is overlaid over top texture to get rid of possible transparency. @@ -91,7 +91,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) local itemstring = itemstack:get_name() local fakestack = ItemStack(itemstack) - local idef = fakestack:get_definition() + --local idef = fakestack:get_definition() local retval if wdir == 0 or wdir == 1 then return minetest.item_place(itemstack, placer, pointed_thing) @@ -101,9 +101,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) if not retval then return itemstack end - - local success - itemstack, success = minetest.item_place(fakestack, placer, pointed_thing, wdir) + itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir) itemstack:set_name(itemstring) return itemstack end, @@ -113,6 +111,9 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) _mcl_armor_mob_range_mob = rangemob, _mcl_armor_mob_range_factor = rangefactor, + _mcl_armor_element = "head", + _mcl_armor_texture = "mcl_heads_" .. name .. ".png", + _mcl_armor_preview = "mcl_heads_" .. name .. "_preview.png", _mcl_blast_resistance = 1, _mcl_hardness = 1, }) diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index e9b3f75e..ca6cb60e 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -1,13 +1,13 @@ -local S = minetest.get_translator("mcl_hoppers") +local S = minetest.get_translator(minetest.get_current_modname()) --[[ BEGIN OF NODE DEFINITIONS ]] local mcl_hoppers_formspec = "size[9,7]".. - "label[2,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Hopper"))).."]".. + "label[2,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Hopper"))).."]".. "list[current_name;main;2,0.5;5,1;]".. mcl_formspec.get_itemslot_bg(2,0.5,5,1).. - "label[0,2;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]".. + "label[0,2;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,2.5;9,3;9]".. mcl_formspec.get_itemslot_bg(0,2.5,9,3).. "list[current_player;main;0,5.74;9,1;]".. @@ -152,7 +152,7 @@ def_hopper_enabled.on_place = function(itemstack, placer, pointed_thing) local z = upos.z - apos.z local fake_itemstack = ItemStack(itemstack) - local newnode, param2 + local param2 if x == -1 then fake_itemstack:set_name("mcl_hoppers:hopper_side") param2 = 0 @@ -166,7 +166,7 @@ def_hopper_enabled.on_place = function(itemstack, placer, pointed_thing) fake_itemstack:set_name("mcl_hoppers:hopper_side") param2 = 1 end - local itemstack, success = minetest.item_place_node(fake_itemstack, placer, pointed_thing, param2) + local itemstack,_ = minetest.item_place_node(fake_itemstack, placer, pointed_thing, param2) itemstack:set_name("mcl_hoppers:hopper") return itemstack end @@ -411,7 +411,6 @@ minetest.register_abm({ -- Move an item from the hopper into container below local downnode = minetest.get_node(downpos) if not minetest.registered_nodes[downnode.name] then return end - g = minetest.registered_nodes[downnode.name].groups.container mcl_util.move_item_container(pos, downpos) end, }) @@ -462,7 +461,7 @@ minetest.register_abm({ -- Put fuel into fuel slot local sinv = minetest.get_inventory({type="node", pos = pos}) local dinv = minetest.get_inventory({type="node", pos = front}) - local slot_id, stack = mcl_util.get_eligible_transfer_item_slot(sinv, "main", dinv, "fuel", is_transferrable_fuel) + local slot_id,_ = mcl_util.get_eligible_transfer_item_slot(sinv, "main", dinv, "fuel", is_transferrable_fuel) if slot_id then mcl_util.move_item_container(pos, front, nil, slot_id, "fuel") end diff --git a/mods/ITEMS/mcl_hoppers/mod.conf b/mods/ITEMS/mcl_hoppers/mod.conf index 53f514f3..c89292f6 100644 --- a/mods/ITEMS/mcl_hoppers/mod.conf +++ b/mods/ITEMS/mcl_hoppers/mod.conf @@ -1,4 +1,4 @@ name = mcl_hoppers description = It's just a clone of Minecraft hoppers, functions nearly identical to them minus mesecons making them stop and the way they're placed. -depends = mcl_core, mcl_formspec, mcl_sounds, mcl_util, mcl_colors +depends = mcl_core, mcl_formspec, mcl_sounds, mcl_util optional_depends = doc, screwdriver diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index 073933fc..d46a393b 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_itemframes") +local S = minetest.get_translator(minetest.get_current_modname()) local VISUAL_SIZE = 0.3 @@ -13,8 +13,8 @@ minetest.register_entity("mcl_itemframes:item",{ _scale = 1, on_activate = function(self, staticdata) - if staticdata ~= nil and staticdata ~= "" then - local data = staticdata:split(';') + if staticdata and staticdata ~= "" then + local data = staticdata:split(";") if data and data[1] and data[2] then self._nodename = data[1] self._texture = data[2] @@ -25,7 +25,7 @@ minetest.register_entity("mcl_itemframes:item",{ end end end - if self._texture ~= nil then + if self._texture then self.object:set_properties({ textures={self._texture}, visual_size={x=VISUAL_SIZE/self._scale, y=VISUAL_SIZE/self._scale}, @@ -33,10 +33,10 @@ minetest.register_entity("mcl_itemframes:item",{ end end, get_staticdata = function(self) - if self._nodename ~= nil and self._texture ~= nil then - local ret = self._nodename .. ';' .. self._texture - if self._scale ~= nil then - ret = ret .. ';' .. self._scale + if self._nodename and self._texture then + local ret = self._nodename .. ";" .. self._texture + if self._scale then + ret = ret .. ";" .. self._scale end return ret end @@ -44,7 +44,7 @@ minetest.register_entity("mcl_itemframes:item",{ end, _update_texture = function(self) - if self._texture ~= nil then + if self._texture then self.object:set_properties({ textures={self._texture}, visual_size={x=VISUAL_SIZE/self._scale, y=VISUAL_SIZE/self._scale}, @@ -53,6 +53,24 @@ minetest.register_entity("mcl_itemframes:item",{ end, }) +minetest.register_entity("mcl_itemframes:map", { + initial_properties = { + visual = "upright_sprite", + visual_size = {x = 1, y = 1}, + pointable = false, + physical = false, + collide_with_objects = false, + textures = {"blank.png"}, + }, + on_activate = function(self, staticdata) + self.id = staticdata + self.object:set_properties({textures = {mcl_maps.load_map(self.id)}}) + end, + get_staticdata = function(self) + return self.id + end, +}) + local facedir = {} facedir[0] = {x=0,y=0,z=1} @@ -61,13 +79,10 @@ facedir[2] = {x=0,y=0,z=-1} facedir[3] = {x=-1,y=0,z=0} local remove_item_entity = function(pos, node) - local objs = nil if node.name == "mcl_itemframes:item_frame" then - objs = minetest.get_objects_inside_radius(pos, .5) - end - if objs then - for _, obj in ipairs(objs) do - if obj and obj:get_luaentity() and obj:get_luaentity().name == "mcl_itemframes:item" then + for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do + local entity = obj:get_luaentity() + if entity and (entity.name == "mcl_itemframes:item" or entity.name == "mcl_itemframes:map") then obj:remove() end end @@ -89,25 +104,27 @@ local update_item_entity = function(pos, node, param2) pos.y = pos.y + posad.y*6.5/16 pos.z = pos.z + posad.z*6.5/16 end - local e = minetest.add_entity(pos, "mcl_itemframes:item") - local lua = e:get_luaentity() - lua._nodename = node.name - local itemname = item:get_name() - if itemname == "" or itemname == nil then - lua._texture = "blank.png" - lua._scale = 1 - else - lua._texture = itemname - local def = minetest.registered_items[itemname] - if def and def.wield_scale then - lua._scale = def.wield_scale.x - else + local yaw = math.pi*2 - param2 * math.pi/2 + local map_id = item:get_meta():get_string("mcl_maps:id") + if map_id == "" then + local e = minetest.add_entity(pos, "mcl_itemframes:item") + local lua = e:get_luaentity() + lua._nodename = node.name + local itemname = item:get_name() + if itemname == "" or itemname == nil then + lua._texture = "blank.png" lua._scale = 1 + else + lua._texture = itemname + local def = minetest.registered_items[itemname] + lua._scale = def and def.wield_scale and def.wield_scale.x or 1 end - end - lua:_update_texture() - if node.name == "mcl_itemframes:item_frame" then - local yaw = math.pi*2 - param2 * math.pi/2 + lua:_update_texture() + if node.name == "mcl_itemframes:item_frame" then + e:set_yaw(yaw) + end + else + local e = minetest.add_entity(pos, "mcl_itemframes:map", map_id) e:set_yaw(yaw) end end @@ -148,6 +165,21 @@ minetest.register_node("mcl_itemframes:item_frame",{ groups = { dig_immediate=3,deco_block=1,dig_by_piston=1,container=7,attached_node_facedir=1 }, sounds = mcl_sounds.node_sound_defaults(), node_placement_prediction = "", + on_timer = function(pos) + local inv = minetest.get_meta(pos):get_inventory() + local stack = inv:get_stack("main", 1) + local itemname = stack:get_name() + if minetest.get_item_group(itemname, "clock") > 0 then + local new_name = "mcl_clock:clock_" .. (mcl_worlds.clock_works(pos) and mcl_clock.old_time or mcl_clock.random_frame) + if itemname ~= new_name then + stack:set_name(new_name) + inv:set_stack("main", 1, stack) + local node = minetest.get_node(pos) + update_item_entity(pos, node, node.param2) + end + minetest.get_node_timer(pos):start(1.0) + end + end, on_place = function(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then return itemstack @@ -188,6 +220,13 @@ minetest.register_node("mcl_itemframes:item_frame",{ end local put_itemstack = ItemStack(itemstack) put_itemstack:set_count(1) + local itemname = put_itemstack:get_name() + if minetest.get_item_group(itemname, "compass") > 0 then + put_itemstack:set_name("mcl_compass:" .. mcl_compass.get_compass_image(pos, minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2)))) + end + if minetest.get_item_group(itemname, "clock") > 0 then + minetest.get_node_timer(pos):start(1.0) + end inv:set_stack("main", 1, put_itemstack) update_item_entity(pos, node) -- Add node infotext when item has been named @@ -237,12 +276,12 @@ minetest.register_node("mcl_itemframes:item_frame",{ on_rotate = function(pos, node, user, mode, param2) if mode == screwdriver.ROTATE_FACE then -- Rotate face - local meta = minetest.get_meta(pos) + --local meta = minetest.get_meta(pos) local node = minetest.get_node(pos) local objs = nil if node.name == "mcl_itemframes:item_frame" then - objs = minetest.get_objects_inside_radius(pos, .5) + objs = minetest.get_objects_inside_radius(pos, 0.5) end if objs then for _, obj in ipairs(objs) do @@ -260,11 +299,11 @@ minetest.register_node("mcl_itemframes:item_frame",{ }) minetest.register_craft({ - output = 'mcl_itemframes:item_frame', + output = "mcl_itemframes:item_frame", recipe = { - {'mcl_core:stick', 'mcl_core:stick', 'mcl_core:stick'}, - {'mcl_core:stick', 'mcl_mobitems:leather', 'mcl_core:stick'}, - {'mcl_core:stick', 'mcl_core:stick', 'mcl_core:stick'}, + {"mcl_core:stick", "mcl_core:stick", "mcl_core:stick"}, + {"mcl_core:stick", "mcl_mobitems:leather", "mcl_core:stick"}, + {"mcl_core:stick", "mcl_core:stick", "mcl_core:stick"}, } }) diff --git a/mods/ITEMS/mcl_itemframes/mod.conf b/mods/ITEMS/mcl_itemframes/mod.conf index 39f4370a..ff09c3bc 100644 --- a/mods/ITEMS/mcl_itemframes/mod.conf +++ b/mods/ITEMS/mcl_itemframes/mod.conf @@ -1,3 +1,3 @@ name = mcl_itemframes -depends = mcl_core, mcl_sounds +depends = mcl_core, mcl_sounds, mcl_compass, mcl_maps optional_depends = screwdriver diff --git a/mods/ITEMS/mcl_jukebox/init.lua b/mods/ITEMS/mcl_jukebox/init.lua index 067848f5..ebee6f7b 100644 --- a/mods/ITEMS/mcl_jukebox/init.lua +++ b/mods/ITEMS/mcl_jukebox/init.lua @@ -1,4 +1,7 @@ -local S = minetest.get_translator("mcl_jukebox") +local S = minetest.get_translator(minetest.get_current_modname()) +local C = minetest.colorize + +local math = math mcl_jukebox = {} mcl_jukebox.registered_records = {} @@ -20,8 +23,8 @@ function mcl_jukebox.register_record(title, author, identifier, image, sound) local usagehelp = S("Place a music disc into an empty jukebox to play the music. Use the jukebox again to retrieve the music disc. The music can only be heard by you, not by other players.") minetest.register_craftitem(":mcl_jukebox:record_"..identifier, { description = - core.colorize(mcl_colors.AQUA, S("Music Disc")) .. "\n" .. - core.colorize(mcl_colors.GRAY, S("@1—@2", author, title)), + C(mcl_colors.AQUA, S("Music Disc")) .. "\n" .. + C(mcl_colors.GRAY, S("@1—@2", author, title)), _doc_items_create_entry = true, _doc_items_entry_name = entryname, _doc_items_longdesc = longdesc, @@ -45,7 +48,7 @@ local function now_playing(player, name) end local id - if hud ~= nil then + if hud then id = hud player:hud_change(id, "text", text) else @@ -67,12 +70,11 @@ local function now_playing(player, name) if not player or not player:is_player() or not active_huds[playername] or not hud_sequence_numbers[playername] or seq ~= hud_sequence_numbers[playername] then return end - if id ~= nil and id == active_huds[playername] then + if id and id == active_huds[playername] then player:hud_remove(active_huds[playername]) active_huds[playername] = nil end end, {playername, id, hud_sequence_numbers[playername]}) - end minetest.register_on_leaveplayer(function(player) @@ -83,19 +85,19 @@ end) -- Jukebox crafting minetest.register_craft({ - output = 'mcl_jukebox:jukebox', + output = "mcl_jukebox:jukebox", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'group:wood', 'mcl_core:diamond', 'group:wood'}, - {'group:wood', 'group:wood', 'group:wood'}, + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "mcl_core:diamond", "group:wood"}, + {"group:wood", "group:wood", "group:wood"}, } }) -local play_record = function(pos, itemstack, player) +local function play_record(pos, itemstack, player) local name = itemstack:get_name() if mcl_jukebox.registered_records[name] then local cname = player:get_player_name() - if active_tracks[cname] ~= nil then + if active_tracks[cname] then minetest.sound_stop(active_tracks[cname]) active_tracks[cname] = nil end @@ -135,7 +137,7 @@ minetest.register_node("mcl_jukebox:jukebox", { local inv = meta:get_inventory() if not inv:is_empty("main") then -- Jukebox contains a disc: Stop music and remove disc - if active_tracks[cname] ~= nil then + if active_tracks[cname] then minetest.sound_stop(active_tracks[cname]) end local lx = pos.x @@ -146,11 +148,11 @@ minetest.register_node("mcl_jukebox:jukebox", { -- Rotate record to match with “slot” texture dropped_item:set_yaw(math.pi/2) inv:set_stack("main", 1, "") - if active_tracks[cname] ~= nil then + if active_tracks[cname] then minetest.sound_stop(active_tracks[cname]) active_tracks[cname] = nil end - if active_huds[cname] ~= nil then + if active_huds[cname] then clicker:hud_remove(active_huds[cname]) active_huds[cname] = nil end @@ -205,11 +207,11 @@ minetest.register_node("mcl_jukebox:jukebox", { local dropped_item = minetest.add_item(p, stack) -- Rotate record to match with “slot” texture dropped_item:set_yaw(math.pi/2) - if active_tracks[name] ~= nil then + if active_tracks[name] then minetest.sound_stop(active_tracks[name]) active_tracks[name] = nil end - if active_huds[name] ~= nil then + if active_huds[name] then digger:hud_remove(active_huds[name]) active_huds[name] = nil end diff --git a/mods/ITEMS/mcl_maps/colors.json b/mods/ITEMS/mcl_maps/colors.json new file mode 100644 index 00000000..0aa23f0f --- /dev/null +++ b/mods/ITEMS/mcl_maps/colors.json @@ -0,0 +1 @@ +{"player.png": [123, 74, 62], "player_back.png": [114, 68, 56], "mcl_skins_player_dummy.png": [125, 125, 125], "mcl_skins_player_1.png": [103, 100, 86], "mcl_skins_button.png": [121, 95, 85], "mcl_skins_character_1.png": [93, 90, 77], "mcl_hunger_bar_saturation.png": [255, 255, 0], "hbhunger_bar_health_poison.png": [148, 120, 24], "mcl_hunger_bar_exhaustion.png": [255, 255, 255], "mcl_hunger_icon_exhaustion.png": [213, 213, 213], "mcl_hunger_bgicon_exhaustion.png": [25, 25, 26], "mcl_hunger_icon_foodpoison.png": [109, 106, 40], "mcl_hunger_bgicon_saturation.png": [24, 24, 26], "hbhunger_bar.png": [200, 103, 0], "hbhunger_bgicon.png": [24, 24, 26], "hbhunger_icon_health_poison.png": [69, 98, 45], "mcl_hunger_bar_foodpoison.png": [116, 132, 88], "hbhunger_icon.png": [175, 132, 97], "mcl_hunger_icon_saturation.png": [157, 140, 64], "mcl_playerplus_end_sky.png": [14, 14, 14], "mobs_mc_llama_decor_purple.png": [98, 50, 98], "mobs_mc_spawn_icon_illusioner.png": [98, 111, 155], "mobs_mc_llama_gray.png": [195, 188, 175], "mobs_mc_spawn_icon_zombie.png": [64, 136, 112], "mobs_mc_llama_decor_blue.png": [50, 50, 249], "mobs_mc_spawn_icon_skeleton.png": [146, 146, 146], "mobs_mc_shulker_blue.png": [89, 100, 126], "mobs_mc_shulker_black.png": [78, 75, 76], "mobs_mc_wolf_collar.png": [186, 186, 186], "mobs_mc_spawn_icon_bat.png": [130, 63, 13], "mobs_mc_parrot_green.png": [47, 208, 62], "mobs_mc_llama_decor_magenta.png": [249, 50, 249], "mobs_mc_rabbit_black.png": [73, 64, 61], "mobs_mc_vindicator.png": [56, 56, 57], "mobs_mc_polarbear.png": [233, 220, 208], "mobs_mc_magmacube.png": [83, 40, 27], "mobs_mc_chicken.png": [198, 182, 176], "mobs_mc_ghast_firing.png": [198, 198, 198], "mobs_mc_spawn_icon_zombie_pigman.png": [202, 160, 135], "mobs_mc_husk.png": [98, 95, 76], "mobs_mc_villager_librarian.png": [176, 171, 163], "mobs_mc_villager_priest.png": [100, 64, 74], "mobs_mc_villager_smith.png": [76, 76, 63], "mobs_mc_horse_armor_gold.png": [143, 110, 59], "mobs_mc_spawn_icon_dragon.png": [98, 47, 89], "mobs_mc_spawn_icon_donkey.png": [152, 132, 100], "mobs_mc_squid.png": [37, 52, 68], "mobs_mc_villager_farmer.png": [81, 80, 67], "mobs_mc_spawn_icon_horse_skeleton.png": [245, 204, 202], "mobs_mc_horse_markings_blackdots.png": [24, 22, 22], "mobs_mc_zombie_farmer.png": [119, 99, 85], "mobs_mc_spawn_icon_vex.png": [145, 185, 185], "mobs_mc_parrot_blue.png": [43, 58, 148], "mobs_mc_spider_eyes.png": [174, 48, 48], "mobs_mc_zombie.png": [78, 110, 105], "mobs_mc_llama_decor_light_blue.png": [104, 168, 194], "mobs_mc_zombie_priest.png": [120, 104, 110], "mobs_mc_llama_decor_black.png": [50, 50, 50], "mobs_mc_horse_white.png": [190, 173, 154], "mobs_mc_spawn_icon_vindicator.png": [102, 103, 104], "mobs_mc_silverfish.png": [179, 164, 144], "mobs_mc_llama_decor_gray.png": [98, 98, 98], "mobs_mc_spawn_icon_guardian.png": [119, 156, 148], "mobs_mc_creeper.png": [98, 107, 71], "mobs_mc_shulker_purple.png": [135, 87, 99], "mobs_mc_spawn_icon_rabbit.png": [156, 126, 84], "mobs_mc_horse_armor_iron.png": [134, 123, 118], "mobs_mc_sheep.png": [182, 161, 149], "mobs_mc_parrot_grey.png": [33, 178, 173], "mobs_mc_wolf_icon_sit.png": [8, 88, 116], "mobs_mc_gold_horse_armor.png": [140, 106, 67], "mobs_mc_spawn_icon_witch.png": [98, 85, 68], "mobs_mc_shulker_green.png": [89, 122, 84], "mobs_mc_bat.png": [87, 63, 54], "mobs_mc_horse_chestnut.png": [126, 78, 58], "mobs_mc_shulker_yellow.png": [175, 128, 69], "mobs_mc_spawn_icon_creeper.png": [115, 125, 53], "mobs_mc_slime.png": [63, 133, 78], "mobs_mc_evoker.png": [44, 48, 43], "mobs_mc_horse_skeleton.png": [163, 156, 141], "mobs_mc_spawn_icon_blaze.png": [142, 76, 49], "mobs_mc_shulker_light_blue.png": [114, 140, 158], "mobs_mc_shulker_gray.png": [106, 104, 109], "mobs_mc_horse_darkbrown.png": [69, 47, 34], "mobs_mc_stray_overlay.png": [63, 59, 65], "mobs_mc_arrow_particle.png": [218, 171, 136], "mobs_mc_spawn_icon_cat.png": [120, 66, 10], "mobs_mc_stray.png": [155, 157, 161], "mobs_mc_trading_formspec_bg.png": [157, 157, 157], "mobs_mc_llama_chest.png": [70, 53, 36], "mobs_mc_spawn_icon_villager.png": [134, 124, 81], "mobs_mc_pig.png": [228, 175, 165], "mobs_mc_spawn_icon_mooshroom.png": [160, 56, 55], "mobs_mc_wolf_angry.png": [187, 179, 176], "mobs_mc_cat_black.png": [206, 181, 154], "mobs_mc_vex_charging.png": [142, 153, 153], "mobs_mc_llama.png": [207, 189, 155], "mobs_mc_mushroom_brown.png": [122, 81, 58], "mobs_mc_spawn_icon_shulker.png": [170, 117, 130], "mobs_mc_wither_half_health.png": [7, 58, 91], "mobs_mc_spawn_icon_guardian_elder.png": [174, 140, 113], "mobs_mc_enderman_eyes.png": [184, 211, 242], "mobs_mc_horse_creamy.png": [146, 111, 75], "mobs_mc_spawn_icon_zombie_villager.png": [95, 110, 68], "mobs_mc_vex.png": [128, 162, 162], "mobs_mc_iron_golem.png": [47, 44, 44], "mobs_mc_cat_ocelot.png": [163, 111, 52], "mobs_mc_llama_decor_green.png": [50, 98, 50], "mobs_mc_cow.png": [94, 68, 55], "mobs_mc_llama_decor_brown.png": [101, 75, 60], "mobs_mc_villager_butcher.png": [82, 83, 71], "mobs_mc_parrot_yellow_blue.png": [98, 187, 205], "mobs_mc_zombie_pigman.png": [164, 129, 117], "mobs_mc_spawn_icon_wolf.png": [231, 218, 207], "mobs_mc_zombie_villager.png": [112, 108, 90], "mobs_mc_sheep_fur.png": [203, 186, 174], "mobs_mc_spawn_icon_horse_zombie.png": [129, 143, 66], "mobs_mc_blaze.png": [84, 63, 50], "mcl_totems_totem.png": [185, 139, 52], "mobs_mc_rabbit_salt.png": [122, 99, 87], "mobs_mc_rabbit_white_splotched.png": [146, 139, 135], "mobs_mc_horse_brown.png": [115, 84, 61], "mobs_mc_ghast.png": [199, 199, 199], "mobs_mc_horse_markings_white.png": [165, 149, 132], "mobs_mc_horse_markings_whitefield.png": [193, 178, 162], "mobs_mc_spawn_icon_endermite.png": [138, 67, 74], "mobs_mc_shulker_magenta.png": [143, 97, 130], "mobs_mc_snowman.png": [211, 217, 221], "mobs_mc_zombie_smith.png": [71, 59, 54], "mobs_mc_spawn_icon_squid.png": [55, 58, 103], "mobs_mc_dragon_fireball.png": [89, 66, 79], "mobs_mc_horse_armor_diamond.png": [78, 110, 129], "mobs_mc_diamond_horse_armor.png": [67, 95, 112], "mobs_mc_rabbit_toast.png": [130, 123, 119], "mobs_mc_llama_white.png": [207, 199, 184], "mobs_mc_llama_creamy.png": [208, 190, 155], "mobs_mc_pig_saddle.png": [82, 63, 45], "mobs_mc_spawn_icon_cave_spider.png": [23, 43, 57], "mobs_mc_shulker_silver.png": [140, 138, 143], "mobs_mc_trading_formspec_disabled.png": [193, 26, 26], "mobs_mc_spider.png": [41, 38, 37], "mobs_mc_wither.png": [33, 33, 33], "mobs_mc_llama_decor_white.png": [249, 249, 249], "mobs_mc_witch.png": [80, 74, 67], "mobs_mc_wolf_icon_roam.png": [6, 124, 36], "mobs_mc_illusionist.png": [56, 68, 114], "mobs_mc_endermite.png": [55, 20, 65], "mobs_mc_spawn_icon_witherskeleton.png": [71, 71, 71], "mobs_mc_llama_decor_light_gray.png": [185, 185, 185], "mobs_mc_llama_decor_cyan.png": [18, 249, 249], "mobs_mc_skeleton.png": [124, 124, 124], "mobs_mc_spawn_icon_llama.png": [230, 221, 178], "mobs_mc_spawn_icon_chicken.png": [170, 160, 156], "mobs_mc_shulker_pink.png": [173, 127, 160], "mobs_mc_spawn_icon_spider.png": [53, 43, 43], "mobs_mc_shulker_red.png": [146, 77, 71], "mobs_mc_shulker_white.png": [184, 181, 186], "mobs_mc_spawn_icon_magmacube.png": [52, 33, 23], "mobs_mc_spawn_icon_ghast.png": [212, 212, 212], "mobs_mc_rabbit_brown.png": [112, 86, 73], "mobs_mc_spawn_icon_pig.png": [242, 200, 188], "mobs_mc_spawn_icon_horse.png": [44, 36, 25], "mobs_mc_cat_siamese.png": [161, 144, 133], "mobs_mc_mushroom_red.png": [176, 51, 49], "mobs_mc_shulker_brown.png": [94, 81, 70], "mobs_mc_guardian.png": [78, 116, 130], "mobs_mc_creeper_charge.png": [121, 219, 255], "mobs_mc_villager.png": [88, 91, 55], "mobs_mc_llama_decor_lime.png": [50, 249, 50], "mobs_mc_llama_brown.png": [136, 97, 52], "mobs_mc_parrot_red_blue.png": [171, 70, 37], "mobs_mc_spawn_icon_husk.png": [174, 174, 128], "mobs_mc_rabbit_gold.png": [151, 130, 96], "mobs_mc_spawn_icon_evoker.png": [92, 103, 86], "mobs_mc_iron_horse_armor.png": [133, 119, 114], "mobs_mc_llama_decor_red.png": [249, 50, 50], "mobs_mc_enderman.png": [3, 10, 10], "mobs_mc_mooshroom_brown.png": [93, 50, 28], "mobs_mc_llama_decor_pink.png": [249, 161, 175], "mobs_mc_enderman_block.png": [46, 42, 38], "mobs_mc_mooshroom.png": [90, 42, 41], "mobs_mc_cat_red.png": [221, 163, 120], "mobs_mc_spit.png": [221, 218, 246], "mobs_mc_shulkerbullet.png": [216, 190, 153], "mobs_mc_horse_markings_whitedots.png": [230, 220, 207], "mobs_mc_mule.png": [108, 75, 51], "mobs_mc_spawn_icon_iron_golem.png": [122, 72, 41], "mobs_mc_zombie_butcher.png": [107, 98, 87], "mobs_mc_llama_decor_yellow.png": [249, 249, 50], "mobs_mc_wolf_tame.png": [179, 159, 154], "mobs_mc_horse_gray.png": [78, 68, 62], "mobs_mc_shulker_lime.png": [106, 132, 88], "mobs_mc_rabbit_caerbannog.png": [186, 179, 174], "mobs_mc_zombie_librarian.png": [106, 104, 104], "mobs_mc_spawn_icon_silverfish.png": [199, 168, 128], "mobs_mc_spawn_icon_stray.png": [118, 116, 118], "mobs_mc_spawn_icon_polarbear.png": [237, 235, 212], "mobs_mc_guardian_elder.png": [141, 141, 125], "mobs_mc_spawn_icon_slime.png": [76, 130, 33], "mobs_mc_cave_spider.png": [14, 28, 38], "mobs_mc_spawn_icon_cow.png": [162, 118, 72], "mobs_mc_wolf.png": [182, 165, 159], "mobs_mc_wither_skeleton.png": [50, 50, 50], "mobs_mc_endergolem.png": [135, 87, 99], "mobs_mc_spawn_icon_mule.png": [115, 82, 47], "mobs_mc_llama_decor_orange.png": [249, 131, 50], "mobs_chicken_egg.png": [199, 157, 106], "mobs_mc_rabbit_white.png": [161, 153, 149], "mobs_mc_horse_black.png": [49, 42, 39], "mobs_mc_dragon.png": [79, 54, 67], "mobs_mc_spawn_icon_parrot.png": [202, 100, 54], "mobs_mc_spawn_icon_snowman.png": [216, 173, 147], "mobs_mc_donkey.png": [91, 78, 68], "mobs_mc_shulker_cyan.png": [89, 114, 128], "mobs_mc_spawn_icon_sheep.png": [209, 185, 175], "mobs_mc_TEMP_wither_projectile.png": [69, 69, 69], "mobs_mc_spawn_icon_enderman.png": [63, 82, 87], "mobs_mc_shulker_orange.png": [156, 90, 67], "mobs_mc_empty.png": [255, 255, 255], "mobs_mc_spawn_icon_wither.png": [102, 102, 102], "mcl_boats_spruce_boat.png": [72, 61, 51], "mcl_boats_jungle_boat.png": [102, 73, 58], "mcl_boats_texture_birch_boat.png": [131, 105, 83], "mcl_boats_texture_oak_boat.png": [103, 82, 65], "mcl_boats_birch_boat.png": [120, 95, 78], "mcl_boats_texture_jungle_boat.png": [109, 78, 60], "mcl_boats_oak_boat.png": [93, 76, 62], "mcl_boats_texture_acacia_boat.png": [136, 90, 64], "mcl_boats_texture_dark_oak_boat.png": [89, 76, 64], "mcl_boats_texture_spruce_boat.png": [74, 61, 50], "mcl_boats_acacia_boat.png": [124, 82, 59], "mcl_boats_dark_oak_boat.png": [89, 76, 64], "mobs_nametag.png": [138, 114, 89], "mobs_blood.png": [27, 27, 29], "mcl_minecarts_rail_golden_curved_powered.png": [89, 71, 57], "mcl_minecarts_rail_golden_crossing.png": [83, 70, 55], "mcl_minecarts_rail_detector_curved_powered.png": [81, 68, 64], "mcl_minecarts_rail_golden_t_junction_powered.png": [82, 69, 59], "mcl_minecarts_rail_golden_t_junction.png": [80, 70, 59], "mcl_minecarts_rail_detector.png": [85, 74, 67], "mcl_minecarts_rail_detector_crossing.png": [77, 69, 65], "default_rail_t_junction.png": [79, 68, 61], "mcl_minecarts_rail_activator_crossing_powered.png": [72, 55, 51], "mcl_minecarts_minecart_hopper.png": [45, 45, 45], "mcl_minecarts_minecart_furnace.png": [66, 65, 64], "mcl_minecarts_minecart_command_block.png": [64, 62, 61], "mcl_minecarts_rail_golden.png": [92, 77, 60], "mcl_minecarts_rail_activator_t_junction_powered.png": [76, 61, 55], "default_rail_curved.png": [76, 67, 60], "mcl_minecarts_rail_activator_t_junction.png": [72, 62, 56], "mcl_minecarts_rail_golden_crossing_powered.png": [86, 70, 54], "mcl_minecarts_rail_detector_crossing_powered.png": [78, 68, 64], "mcl_minecarts_rail_detector_curved.png": [77, 70, 66], "default_rail_crossing.png": [79, 68, 59], "mcl_minecarts_rail_detector_t_junction.png": [74, 66, 61], "mcl_minecarts_minecart.png": [72, 60, 51], "mcl_minecarts_rail_golden_curved.png": [85, 73, 58], "mcl_minecarts_rail_activator.png": [78, 64, 56], "mcl_minecarts_rail_activator_powered.png": [86, 62, 54], "mcl_minecarts_rail_detector_t_junction_powered.png": [76, 66, 61], "mcl_minecarts_minecart_normal.png": [47, 45, 43], "mcl_minecarts_minecart_tnt.png": [75, 52, 52], "mcl_minecarts_rail_detector_powered.png": [87, 74, 67], "mcl_minecarts_rail_golden_powered.png": [94, 77, 60], "mcl_minecarts_rail_activator_crossing.png": [65, 56, 52], "default_rail.png": [83, 70, 61], "mcl_minecarts_rail_activator_curved_powered.png": [75, 55, 52], "mcl_minecarts_rail_activator_curved.png": [66, 56, 53], "mcl_minecarts_minecart_chest.png": [51, 48, 46], "mobs_mc_gameconfig_enderman_cactus_background.png": [44, 71, 27], "mcl_paintings_paintings.png": [104, 99, 89], "mcl_paintings_painting.png": [139, 133, 119], "mcl_particles_lava.png": [250, 150, 64], "mcl_particles_instant_effect.png": [160, 160, 160], "mcl_particles_note.png": [41, 40, 39], "mcl_particles_bubble.png": [147, 174, 195], "mcl_particles_sponge1.png": [241, 238, 226], "mcl_particles_smoke_anim.png": [172, 172, 172], "mcl_particles_crit.png": [165, 165, 165], "mcl_particles_mob_death.png": [198, 198, 198], "mcl_particles_droplet_bottle.png": [203, 203, 203], "mcl_particles_sponge4.png": [241, 238, 226], "mcl_particles_effect.png": [184, 184, 184], "mcl_particles_teleport.png": [86, 22, 128], "mcl_particles_sponge5.png": [241, 238, 226], "mcl_particles_flame.png": [244, 149, 63], "mcl_particles_sponge3.png": [241, 238, 226], "mcl_particles_sponge2.png": [241, 238, 226], "mcl_particles_smoke.png": [174, 174, 174], "lightning_lightning_2.png": [255, 255, 255], "lightning_lightning_3.png": [217, 217, 217], "lightning_lightning_1.png": [223, 223, 223], "weather_pack_rain_raindrop_2.png": [33, 79, 142], "weather_pack_rain_raindrop_3.png": [59, 88, 128], "mcl_particles_nether_dust3.png": [143, 105, 102], "weather_pack_rain_raindrop_1.png": [97, 137, 179], "mcl_particles_nether_dust1.png": [143, 105, 102], "weather_pack_snow_snowflake1.png": [255, 255, 255], "mcl_particles_nether_dust2.png": [143, 105, 102], "weather_pack_snow_snowflake2.png": [255, 255, 255], "mcl_moon_moon_phases.png": [80, 106, 141], "hbarmor_bgicon.png": [27, 27, 29], "hbarmor_bar.png": [175, 172, 165], "hbarmor_icon.png": [135, 131, 126], "mcl_base_textures_background9.png": [179, 179, 179], "object_crosshair.png": [255, 255, 255], "bubble.png": [69, 138, 194], "crosshair.png": [255, 255, 255], "heart.png": [137, 47, 40], "mcl_base_textures_background.png": [179, 179, 179], "crack_anylength.png": [93, 93, 93], "mcl_base_textures_button9_pressed.png": [162, 162, 162], "mcl_base_textures_button9.png": [162, 162, 162], "smoke_puff.png": [255, 255, 255], "mineclone2_logo.png": [75, 74, 69], "mineclone2_icon.png": [58, 74, 44], "awards_template.png": [134, 134, 134], "awards_bg_mining.png": [73, 68, 51], "awards_progress_gray.png": [157, 157, 157], "awards_ui_icon.png": [190, 34, 34], "awards_unknown.png": [134, 134, 134], "awards_progress_green.png": [0, 155, 74], "awards_bg_default.png": [38, 38, 38], "hudbars_bar_breath.png": [159, 161, 255], "hudbars_icon_health.png": [137, 47, 40], "hudbars_bar_health.png": [168, 55, 47], "hudbars_bgicon_breath.png": [0, 0, 0], "hudbars_bgicon_health.png": [27, 27, 29], "hudbars_icon_breath.png": [69, 138, 194], "hudbars_bar_background.png": [71, 71, 71], "mcl_achievements_button.png": [158, 152, 67], "mcl_inventory_hotbar.png": [81, 81, 85], "crafting_inventory_creative_survival.png": [195, 195, 195], "crafting_creative_bg_dark.png": [157, 157, 157], "mcl_inventory_empty_armor_slot_shield.png": [25, 32, 34], "crafting_formspec_bg.png": [9, 9, 9], "mcl_inventory_empty_armor_slot_helmet.png": [25, 32, 34], "mcl_inventory_hotbar_selected.png": [113, 85, 40], "crafting_creative_inactive_down.png": [151, 151, 151], "crafting_creative_active_down.png": [196, 196, 196], "crafting_creative_prev.png": [254, 254, 254], "crafting_creative_marker.png": [0, 0, 0], "mcl_inventory_button9_pressed.png": [162, 162, 162], "crafting_creative_active.png": [202, 202, 202], "mcl_inventory_button9.png": [162, 162, 162], "mcl_inventory_empty_armor_slot_chestplate.png": [0, 0, 0], "mcl_inventory_empty_armor_slot_boots.png": [0, 0, 0], "crafting_creative_bg.png": [207, 207, 207], "crafting_creative_inactive.png": [157, 157, 157], "crafting_creative_next.png": [254, 254, 254], "mcl_inventory_empty_armor_slot_leggings.png": [25, 32, 34], "crafting_inventory_creative.png": [206, 206, 206], "crafting_creative_trash.png": [144, 113, 113], "mcl_formspec_itemslot.png": [157, 157, 157], "mcl_experience_bottle.png": [136, 174, 169], "experience_bar_background.png": [49, 46, 45], "experience_orb.png": [93, 174, 0], "experience_bar.png": [74, 102, 70], "mcl_bossbars_empty.png": [255, 255, 255], "mcl_bossbars.png": [76, 68, 75], "mcl_itemframes_item_frame.png": [123, 90, 63], "mcl_itemframes_itemframe_background.png": [136, 104, 75], "mcl_banners_stripe_middle.png": [255, 255, 255], "mcl_banners_skull.png": [255, 255, 255], "mcl_banners_bricks.png": [255, 255, 255], "mcl_banners_square_bottom_left.png": [255, 255, 255], "mcl_banners_gradient.png": [254, 254, 254], "mcl_banners_cross.png": [255, 255, 255], "mcl_banners_gradient_up.png": [254, 254, 254], "mcl_banners_item_overlay.png": [240, 240, 240], "mcl_banners_stripe_downright.png": [255, 255, 255], "mcl_banners_stripe_downleft.png": [255, 255, 255], "mcl_banners_fallback_wood.png": [102, 88, 74], "mcl_banners_base_inverted.png": [255, 255, 255], "mcl_banners_triangles_top.png": [255, 255, 255], "mcl_banners_banner_base.png": [215, 206, 193], "mcl_banners_curly_border.png": [254, 254, 254], "mcl_banners_thing.png": [253, 253, 253], "mcl_banners_small_stripes.png": [255, 255, 255], "mcl_banners_triangle_bottom.png": [254, 254, 254], "mcl_banners_stripe_right.png": [255, 255, 255], "mcl_banners_straight_cross.png": [255, 255, 255], "mcl_banners_triangle_top.png": [255, 255, 255], "mcl_banners_border.png": [255, 255, 255], "mcl_banners_diagonal_left.png": [255, 255, 255], "mcl_banners_diagonal_right.png": [255, 255, 255], "mcl_banners_base.png": [255, 255, 255], "mcl_banners_half_vertical.png": [255, 255, 255], "mcl_banners_circle.png": [254, 254, 254], "mcl_banners_triangles_bottom.png": [255, 255, 255], "mcl_banners_item_base.png": [103, 89, 75], "mcl_banners_stripe_left.png": [255, 255, 255], "mcl_banners_rhombus.png": [255, 255, 255], "mcl_banners_creeper.png": [255, 255, 255], "mcl_banners_flower.png": [254, 254, 254], "mcl_banners_stripe_bottom.png": [255, 255, 255], "mcl_banners_half_horizontal.png": [255, 255, 255], "mcl_banners_half_horizontal_bottom.png": [255, 255, 255], "mcl_banners_square_top_left.png": [255, 255, 255], "mcl_banners_square_top_right.png": [255, 255, 255], "mcl_banners_stripe_center.png": [255, 255, 255], "mcl_banners_diagonal_up_left.png": [255, 255, 255], "mcl_banners_stripe_top.png": [255, 255, 255], "mcl_banners_diagonal_up_right.png": [255, 255, 255], "mcl_banners_square_bottom_right.png": [255, 255, 255], "mcl_banners_half_vertical_right.png": [255, 255, 255], "mcl_doors_trapdoor_dark_oak.png": [81, 68, 56], "mcl_doors_trapdoor_acacia_side.png": [154, 102, 71], "doors_trapdoor_steel_side.png": [149, 140, 140], "mcl_doors_door_jungle_side_upper.png": [109, 75, 57], "mcl_doors_door_dark_oak_side_lower.png": [103, 90, 75], "mcl_doors_door_iron_lower.png": [157, 152, 151], "mcl_doors_door_acacia_upper.png": [152, 100, 69], "mcl_doors_door_jungle_side_lower.png": [107, 72, 55], "mcl_doors_door_wood_lower.png": [89, 70, 55], "doors_trapdoor_steel.png": [149, 140, 140], "mcl_doors_door_iron_side_upper.png": [155, 149, 148], "mcl_doors_door_acacia_side_upper.png": [133, 80, 53], "mcl_doors_door_jungle.png": [116, 83, 62], "mcl_doors_door_iron_side_lower.png": [157, 152, 151], "mcl_doors_door_birch_upper.png": [179, 158, 139], "mcl_doors_trapdoor_spruce_side.png": [73, 59, 47], "mcl_doors_door_iron_upper.png": [155, 149, 148], "mcl_doors_door_spruce_side_lower.png": [92, 79, 68], "mcl_doors_trapdoor_spruce.png": [71, 57, 46], "mcl_doors_trapdoor_birch_side.png": [147, 116, 89], "doors_trapdoor_side.png": [113, 86, 67], "mcl_doors_door_acacia_lower.png": [153, 101, 70], "mcl_doors_door_dark_oak_side_upper.png": [102, 89, 75], "mcl_doors_door_acacia_side_lower.png": [131, 78, 51], "mcl_doors_door_wood_upper.png": [92, 72, 57], "mcl_doors_trapdoor_birch.png": [173, 151, 132], "mcl_doors_door_dark_oak_upper.png": [83, 71, 59], "mcl_doors_door_acacia.png": [148, 98, 67], "mcl_doors_door_spruce.png": [67, 56, 47], "mcl_doors_door_spruce_lower.png": [71, 58, 48], "mcl_doors_door_birch_side_upper.png": [153, 121, 94], "mcl_doors_trapdoor_dark_oak_side.png": [85, 72, 60], "mcl_doors_door_wood_side_upper.png": [84, 65, 51], "mcl_doors_door_birch.png": [172, 147, 124], "mcl_doors_door_birch_lower.png": [165, 140, 119], "mcl_doors_trapdoor_jungle.png": [103, 70, 52], "doors_item_steel.png": [148, 144, 143], "doors_trapdoor.png": [98, 75, 59], "mcl_doors_door_jungle_lower.png": [116, 82, 61], "doors_item_wood.png": [88, 67, 53], "mcl_doors_door_jungle_upper.png": [113, 79, 59], "mcl_doors_door_spruce_upper.png": [71, 58, 47], "mcl_doors_door_dark_oak_lower.png": [84, 71, 59], "mcl_doors_door_dark_oak.png": [82, 69, 57], "mcl_doors_door_wood_side_lower.png": [132, 102, 81], "mcl_doors_trapdoor_jungle_side.png": [121, 87, 62], "mcl_doors_door_spruce_side_upper.png": [92, 79, 68], "mcl_doors_door_birch_side_lower.png": [152, 119, 92], "mcl_doors_trapdoor_acacia.png": [148, 96, 66], "mcl_fishing_clownfish_raw.png": [205, 127, 81], "mcl_fishing_fish_raw.png": [70, 112, 154], "mcl_fishing_salmon_raw.png": [112, 105, 102], "mcl_fishing_fish_cooked.png": [93, 84, 94], "mcl_fishing_bobber.png": [171, 117, 119], "mcl_fishing_pufferfish_raw.png": [219, 165, 77], "mcl_fishing_fishing_rod.png": [134, 116, 103], "mcl_fishing_salmon_cooked.png": [97, 91, 89], "mcl_stairs_diorite_smooth_slab.png": [156, 153, 151], "mcl_stairs_iron_block_slab.png": [166, 159, 159], "mcl_stairs_andesite_smooth_slab.png": [106, 113, 108], "mcl_stairs_gold_block_slab.png": [191, 146, 56], "mcl_stairs_granite_smooth_slab.png": [150, 121, 109], "mcl_stairs_lapis_block_slab.png": [49, 89, 158], "mcl_fireworks_rocket.png": [155, 84, 71], "mcl_bows_arrow_inv.png": [144, 129, 121], "mcl_bows_arrow_overlay.png": [193, 191, 186], "mcl_bows_bow_1.png": [112, 95, 79], "mcl_bows_bow_0.png": [111, 94, 79], "mcl_bows_bow_2.png": [115, 98, 82], "mcl_bows_bow.png": [114, 95, 78], "mcl_bows_arrow.png": [133, 116, 108], "mcl_bows_arrow_front.png": [178, 175, 168], "mcl_bows_arrow_back.png": [218, 216, 213], "mcl_ocean_dead_bubble_coral.png": [118, 108, 126], "mcl_ocean_tube_coral.png": [57, 88, 209], "mcl_ocean_sea_pickle_2_anim.png": [95, 122, 51], "mcl_ocean_dead_horn_coral_fan.png": [150, 143, 123], "mcl_ocean_dead_bubble_coral_block.png": [114, 105, 122], "mcl_ocean_sea_pickle_3_off.png": [68, 99, 36], "mcl_ocean_dead_horn_coral_block.png": [152, 146, 125], "mcl_ocean_bubble_coral_block.png": [143, 76, 195], "mcl_ocean_horn_coral.png": [233, 195, 69], "mcl_ocean_dead_tube_coral_block.png": [99, 104, 127], "mcl_ocean_sea_pickle_item.png": [93, 120, 50], "mcl_ocean_kelp_item.png": [42, 105, 55], "mcl_ocean_dried_kelp_side.png": [71, 80, 67], "mcl_ocean_dead_tube_coral.png": [99, 105, 128], "mcl_ocean_fire_coral_block.png": [198, 74, 62], "mcl_ocean_bubble_coral.png": [149, 77, 200], "mcl_ocean_prismarine_bricks.png": [104, 112, 115], "mcl_ocean_brain_coral.png": [206, 87, 153], "mcl_ocean_dried_kelp_top.png": [56, 71, 57], "mcl_ocean_brain_coral_block.png": [200, 85, 148], "mcl_ocean_prismarine_dark.png": [77, 89, 97], "mcl_ocean_dead_fire_coral_block.png": [127, 102, 100], "mcl_ocean_prismarine_shard.png": [122, 144, 135], "mcl_ocean_sea_pickle_2_off.png": [70, 100, 36], "mcl_ocean_sea_pickle_4_anim.png": [85, 113, 46], "mcl_ocean_dead_brain_coral.png": [134, 117, 127], "mcl_ocean_tube_coral_fan.png": [59, 85, 203], "mcl_ocean_sea_pickle_4_off.png": [68, 98, 36], "mcl_ocean_sea_pickle_1_anim.png": [106, 132, 57], "mcl_ocean_fire_coral.png": [208, 78, 65], "mcl_ocean_sea_pickle_3_anim.png": [89, 116, 48], "mcl_ocean_dead_fire_coral_fan.png": [140, 113, 110], "mcl_ocean_prismarine_crystals.png": [182, 193, 190], "mcl_ocean_prismarine_anim.png": [104, 123, 122], "mcl_ocean_horn_coral_fan.png": [230, 189, 68], "mcl_ocean_dead_tube_coral_fan.png": [98, 103, 125], "mcl_ocean_sea_pickle_1_off.png": [72, 103, 37], "mcl_ocean_dead_horn_coral.png": [154, 148, 127], "mcl_ocean_dead_fire_coral.png": [133, 107, 105], "mcl_ocean_bubble_coral_fan.png": [141, 75, 192], "mcl_ocean_horn_coral_block.png": [232, 193, 69], "mcl_ocean_brain_coral_fan.png": [206, 87, 154], "mcl_ocean_sea_lantern.png": [133, 144, 145], "mcl_ocean_seagrass.png": [48, 125, 60], "mcl_ocean_dead_brain_coral_fan.png": [134, 117, 127], "mcl_ocean_dried_kelp.png": [36, 57, 40], "mcl_ocean_dead_bubble_coral_fan.png": [113, 104, 120], "mcl_ocean_dried_kelp_bottom.png": [56, 71, 57], "mcl_ocean_kelp_plant.png": [42, 105, 55], "mcl_ocean_tube_coral_block.png": [58, 88, 207], "mcl_ocean_dead_brain_coral_block.png": [130, 114, 123], "mcl_ocean_fire_coral_fan.png": [205, 77, 64], "mcl_portals_endframe_bottom.png": [109, 99, 87], "mcl_portals_particle3.png": [146, 0, 201], "mcl_portals_particle2.png": [146, 0, 201], "mcl_portals_endframe_top.png": [95, 85, 74], "mcl_portals_particle4.png": [146, 0, 201], "mcl_portals_endframe_eye.png": [135, 36, 18], "mcl_portals_end_portal.png": [14, 14, 14], "mcl_particles_nether_portal.png": [206, 0, 206], "mcl_portals_particle5.png": [189, 11, 213], "mcl_portals_endframe_side.png": [110, 99, 86], "mcl_portals_particle1.png": [173, 28, 229], "mcl_portals_portal.png": [74, 24, 172], "mcl_particles_nether_portal_t.png": [159, 0, 223], "cake_side.png": [201, 170, 155], "cake_inner.png": [185, 129, 99], "cake_bottom.png": [160, 86, 51], "cake_top.png": [241, 228, 226], "cake.png": [216, 187, 176], "mcl_cocoas_cocoa_top_stage_2.png": [138, 68, 52], "mcl_cocoas_cocoa_stage_1.png": [172, 121, 69], "mcl_cocoas_cocoa_stage_2.png": [132, 65, 50], "mcl_cocoas_cocoa_stage_0.png": [65, 77, 39], "mcl_fences_fence_red_nether_brick.png": [68, 17, 0], "mcl_fences_fence_gate_red_nether_brick.png": [64, 15, 0], "mcl_fences_fence_gate_nether_brick.png": [50, 25, 26], "mcl_mobitems_spider_eye.png": [154, 69, 60], "mcl_mobitems_leather.png": [105, 75, 45], "mcl_mobitems_feather.png": [206, 185, 183], "mcl_mobitems_string.png": [202, 186, 166], "mcl_mobitems_rabbit_foot.png": [124, 107, 97], "mcl_mobitems_saddle.png": [93, 72, 50], "mcl_mobitems_bone.png": [182, 162, 139], "mcl_mobitems_shulker_shell.png": [118, 68, 83], "mcl_mobitems_blaze_rod.png": [143, 64, 28], "mcl_mobitems_beef_raw.png": [147, 63, 54], "mcl_mobitems_rabbit_stew.png": [127, 98, 79], "mcl_mobitems_rotten_flesh.png": [110, 68, 45], "mcl_mobitems_chicken_raw.png": [217, 178, 149], "mcl_mobitems_ghast_tear.png": [148, 160, 166], "mcl_mobitems_porkchop_raw.png": [160, 72, 69], "mcl_mobitems_rabbit_hide.png": [108, 85, 73], "mcl_mobitems_slimeball.png": [75, 134, 82], "mcl_mobitems_magma_cream.png": [102, 54, 34], "default_gunpowder.png": [48, 41, 36], "mcl_mobitems_chicken_cooked.png": [187, 145, 106], "mcl_mobitems_beef_cooked.png": [112, 70, 49], "mcl_mobitems_rabbit_cooked.png": [188, 155, 131], "mcl_mobitems_blaze_powder.png": [86, 50, 34], "mcl_mobitems_rabbit_raw.png": [217, 177, 157], "mcl_mobitems_carrot_on_a_stick.png": [133, 113, 93], "mcl_mobitems_mutton_cooked.png": [144, 104, 77], "mcl_mobitems_nether_star.png": [234, 189, 123], "mcl_mobitems_porkchop_cooked.png": [116, 72, 48], "mcl_mobitems_mutton_raw.png": [175, 77, 77], "mcl_mobitems_bucket_milk.png": [180, 175, 166], "mcl_farming_wheat_stage_0.png": [53, 101, 46], "farming_carrot.png": [147, 106, 63], "farming_potato_poison.png": [121, 93, 55], "farming_cookie.png": [144, 100, 61], "mcl_farming_melon_seeds.png": [100, 72, 61], "mcl_farming_potatoes_stage_1.png": [69, 113, 61], "mcl_farming_melon_stem_disconnected.png": [96, 96, 96], "farming_carrot_4.png": [93, 105, 58], "mcl_farming_wheat_stage_5.png": [101, 142, 66], "farming_tool_woodhoe.png": [120, 101, 86], "mcl_farming_potatoes_stage_0.png": [73, 119, 65], "farming_carrot_1.png": [75, 112, 61], "farming_carrot_3.png": [70, 107, 57], "farming_melon.png": [153, 84, 62], "mcl_farming_pumpkin_seeds.png": [132, 120, 87], "farming_wheat_harvested.png": [178, 134, 80], "farming_pumpkin_side.png": [186, 100, 42], "mcl_farming_pumpkin_face.png": [181, 94, 40], "mcl_farming_wheat_stage_4.png": [86, 129, 65], "mcl_farming_farmland_wet.png": [69, 55, 46], "mcl_farming_beetroot_0.png": [56, 122, 75], "mcl_farming_pumpkin_stem_connected.png": [94, 94, 94], "mcl_farming_farmland_dry.png": [101, 80, 68], "farming_tool_diamondhoe.png": [101, 104, 104], "mcl_farming_beetroot_1.png": [54, 118, 72], "mcl_farming_beetroot_2.png": [54, 119, 73], "mcl_farming_wheat_stage_7.png": [165, 116, 75], "mcl_farming_beetroot.png": [113, 69, 66], "mcl_farming_wheat_stage_6.png": [145, 145, 69], "mcl_farming_wheat_stage_3.png": [64, 113, 52], "mcl_farming_pumpkin_stem_disconnected.png": [96, 96, 96], "mcl_farming_hayblock_top.png": [154, 116, 81], "farming_pumpkin_face_light.png": [189, 100, 45], "farming_potato_baked.png": [118, 84, 45], "farming_melon_side.png": [68, 95, 37], "farming_potato.png": [107, 74, 39], "mcl_farming_wheat_stage_1.png": [49, 97, 45], "farming_pumpkin_top.png": [172, 87, 40], "farming_bread.png": [177, 133, 94], "mcl_farming_beetroot_soup.png": [120, 70, 63], "farming_melon_top.png": [58, 80, 33], "mcl_farming_potatoes_stage_3.png": [82, 106, 57], "farming_tool_stonehoe.png": [133, 122, 111], "mcl_farming_beetroot_seeds.png": [107, 104, 88], "farming_tool_goldhoe.png": [162, 131, 70], "farming_carrot_gold.png": [140, 122, 48], "farming_carrot_2.png": [72, 108, 58], "farming_pumpkin_face.png": [161, 79, 37], "mcl_farming_melon_stem_connected.png": [94, 94, 94], "mcl_farming_pumpkin_pie.png": [172, 98, 45], "mcl_farming_pumpkin_face_preview.png": [166, 81, 38], "mcl_farming_wheat_stage_2.png": [49, 97, 45], "farming_tool_steelhoe.png": [123, 112, 102], "mcl_farming_potatoes_stage_2.png": [72, 116, 62], "mcl_farming_beetroot_3.png": [73, 105, 71], "mcl_farming_wheat_seeds.png": [102, 87, 55], "mcl_farming_hayblock_side.png": [135, 99, 71], "mcl_end_purpur_block.png": [161, 111, 175], "mcl_end_chorus_flower_dead.png": [82, 79, 118], "mcl_end_end_stone.png": [221, 214, 130], "mcl_end_endframe_side.png": [110, 99, 86], "mcl_end_purpur_pillar.png": [157, 108, 171], "mcl_end_chorus_fruit.png": [87, 89, 121], "mcl_end_endframe_eye.png": [135, 36, 18], "mcl_end_chorus_fruit_popped.png": [70, 67, 110], "mcl_end_end_rod_top.png": [123, 75, 97], "mcl_end_endframe_top.png": [95, 85, 74], "mcl_end_purpur_pillar_top.png": [159, 110, 173], "mcl_end_chorus_flower.png": [92, 92, 125], "mcl_end_crystal_item.png": [170, 140, 162], "mcl_end_end_bricks.png": [194, 187, 123], "mcl_end_dragon_egg.png": [55, 34, 32], "mcl_end_ender_eye.png": [130, 33, 17], "mcl_end_chorus_plant.png": [78, 73, 115], "mcl_end_end_rod_bottom.png": [122, 74, 96], "mcl_end_crystal_beam.png": [251, 251, 251], "mcl_end_end_rod_side.png": [242, 202, 177], "mcl_clock_clock_18.png": [152, 123, 81], "mcl_clock_clock_03.png": [160, 129, 88], "mcl_clock_clock_49.png": [155, 122, 79], "mcl_clock_clock_34.png": [140, 115, 76], "mcl_clock_clock_01.png": [161, 129, 88], "mcl_clock_clock_32.png": [141, 116, 77], "mcl_clock_clock_27.png": [142, 117, 78], "mcl_clock_clock_42.png": [147, 119, 79], "mcl_clock_clock_25.png": [145, 119, 78], "mcl_clock_clock_56.png": [160, 126, 81], "mcl_clock_clock_22.png": [146, 119, 79], "mcl_clock_clock_31.png": [141, 116, 76], "mcl_clock_clock_57.png": [161, 127, 83], "mcl_clock_clock_58.png": [157, 127, 86], "mcl_clock_clock_39.png": [146, 119, 79], "mcl_clock_clock_59.png": [160, 128, 86], "mcl_clock_clock_16.png": [157, 125, 80], "mcl_clock_clock_38.png": [141, 117, 78], "mcl_clock_clock_53.png": [158, 124, 80], "mcl_clock_clock_43.png": [149, 121, 80], "mcl_clock_clock_09.png": [161, 127, 81], "mcl_clock_clock_33.png": [141, 116, 76], "mcl_clock_clock_07.png": [162, 128, 83], "mcl_clock_clock_23.png": [148, 121, 80], "mcl_clock_clock_51.png": [156, 123, 80], "mcl_clock_clock_10.png": [158, 127, 85], "mcl_clock_clock_55.png": [160, 126, 81], "mcl_clock_clock_46.png": [152, 122, 81], "mcl_clock_clock_26.png": [142, 117, 79], "mcl_clock_clock_06.png": [157, 127, 86], "mcl_clock_clock_00.png": [162, 129, 87], "mcl_clock_clock_28.png": [141, 116, 77], "mcl_clock_clock_44.png": [150, 120, 79], "mcl_clock_clock_08.png": [160, 127, 81], "mcl_clock_clock_19.png": [152, 122, 80], "mcl_clock_clock_12.png": [159, 127, 83], "mcl_clock_clock_45.png": [153, 123, 81], "mcl_clock_clock_24.png": [147, 120, 80], "mcl_clock_clock_15.png": [157, 125, 81], "mcl_clock_clock_20.png": [150, 121, 79], "mcl_clock_clock_61.png": [160, 129, 88], "mcl_clock_clock_02.png": [159, 129, 89], "mcl_clock_clock_40.png": [147, 120, 79], "mcl_clock_clock_37.png": [143, 118, 79], "mcl_clock_clock_48.png": [155, 123, 79], "mcl_clock_clock_13.png": [159, 126, 82], "mcl_clock_clock_17.png": [156, 125, 81], "mcl_clock_clock_52.png": [156, 123, 80], "mcl_clock_clock_54.png": [156, 125, 84], "mcl_clock_clock_04.png": [159, 128, 87], "mcl_clock_clock_47.png": [154, 122, 80], "mcl_clock_clock_62.png": [159, 129, 89], "mcl_clock_clock_41.png": [147, 120, 79], "mcl_clock_clock_35.png": [140, 115, 76], "mcl_clock_clock_60.png": [159, 128, 87], "mcl_clock_clock_50.png": [155, 123, 80], "mcl_clock_clock_29.png": [142, 117, 78], "mcl_clock_clock_21.png": [150, 122, 81], "mcl_clock_clock_30.png": [140, 115, 76], "mcl_clock_clock_14.png": [157, 125, 81], "mcl_clock_clock_05.png": [160, 128, 85], "mcl_clock_clock_36.png": [141, 116, 77], "mcl_clock_clock_63.png": [161, 129, 88], "mcl_clock_clock_11.png": [160, 127, 82], "mcl_compass_compass_02.png": [116, 107, 104], "mcl_compass_compass_06.png": [117, 107, 104], "mcl_compass_compass_04.png": [117, 106, 104], "mcl_compass_compass_19.png": [116, 106, 103], "mcl_compass_compass_16.png": [114, 106, 104], "mcl_compass_compass_26.png": [117, 107, 104], "mcl_compass_compass_25.png": [117, 107, 105], "mcl_compass_compass_24.png": [117, 107, 105], "mcl_compass_compass_17.png": [115, 106, 104], "mcl_compass_compass_23.png": [117, 107, 105], "mcl_compass_compass_01.png": [115, 107, 104], "mcl_compass_compass_28.png": [116, 107, 104], "mcl_compass_compass_05.png": [117, 106, 104], "mcl_compass_compass_09.png": [117, 107, 104], "mcl_compass_compass_10.png": [117, 107, 105], "mcl_compass_compass_14.png": [116, 107, 105], "mcl_compass_compass_18.png": [117, 107, 104], "mcl_compass_compass_13.png": [117, 106, 104], "mcl_compass_compass_08.png": [117, 107, 104], "mcl_compass_compass_21.png": [117, 107, 104], "mcl_compass_compass_27.png": [117, 106, 104], "mcl_compass_compass_30.png": [116, 107, 104], "mcl_compass_compass_15.png": [115, 106, 104], "mcl_compass_compass_29.png": [115, 106, 104], "mcl_compass_compass_03.png": [116, 106, 104], "mcl_compass_compass_07.png": [117, 107, 104], "mcl_compass_compass_22.png": [117, 107, 105], "mcl_compass_compass_12.png": [117, 106, 104], "mcl_compass_compass_00.png": [114, 107, 104], "mcl_compass_compass_20.png": [116, 106, 104], "mcl_compass_compass_31.png": [115, 107, 104], "mcl_compass_compass_11.png": [117, 106, 104], "mcl_jukebox_record_wait.png": [39, 42, 55], "mcl_jukebox_record_cat.png": [40, 45, 51], "mcl_jukebox_record_mellohi.png": [46, 44, 59], "mcl_jukebox_record_13.png": [51, 47, 51], "mcl_jukebox_record_ward.png": [39, 43, 51], "mcl_jukebox_record_chirp.png": [49, 40, 50], "mcl_jukebox_record_blocks.png": [47, 37, 49], "mcl_jukebox_record_11.png": [41, 40, 52], "mcl_jukebox_record_mall.png": [42, 41, 62], "mcl_jukebox_top.png": [72, 56, 44], "mcl_jukebox_record_strad.png": [45, 45, 57], "mcl_jukebox_record_far.png": [47, 48, 52], "mcl_jukebox_side.png": [94, 74, 57], "mcl_jukebox_record_stal.png": [39, 38, 49], "mcl_fences_fence_acacia.png": [152, 99, 68], "mcl_fences_fence_gate_mask.png": [255, 126, 126], "mcl_fences_fence_gate_spruce.png": [85, 69, 56], "mcl_fences_fence_big_oak.png": [83, 71, 59], "mcl_fences_fence_spruce.png": [84, 67, 54], "mcl_fences_fence_gate_birch.png": [153, 121, 94], "mcl_fences_fence_gate_acacia.png": [155, 102, 70], "mcl_fences_fence_gate_big_oak.png": [85, 73, 61], "mcl_fences_fence_oak.png": [108, 83, 64], "mcl_fences_fence_gate_oak.png": [111, 85, 66], "mcl_fences_fence_jungle.png": [115, 80, 60], "mcl_fences_fence_nether_brick.png": [49, 24, 24], "mcl_fences_fence_birch.png": [151, 119, 93], "mcl_fences_fence_gate_jungle.png": [117, 82, 61], "mcl_fences_fence_mask.png": [255, 126, 126], "mcl_core_leaves_birch.png": [28, 57, 28], "default_mossycobble.png": [100, 105, 94], "default_flint.png": [70, 67, 64], "mcl_core_bowl.png": [78, 61, 47], "mcl_core_bone_block_top.png": [220, 201, 170], "default_acacia_tree.png": [105, 91, 74], "default_steel_block.png": [159, 151, 151], "mcl_core_stonebrick_mossy.png": [81, 101, 76], "default_diamond_block.png": [92, 160, 200], "default_leaves.png": [39, 79, 38], "mcl_core_web.png": [202, 189, 167], "mcl_core_reeds.png": [57, 100, 52], "default_gold_ingot.png": [179, 133, 47], "mcl_core_grass_path_side.png": [113, 89, 62], "mcl_core_red_sand.png": [224, 137, 111], "default_apple.png": [137, 57, 44], "mcl_core_log_birch_top.png": [155, 130, 112], "default_coal_block.png": [51, 49, 51], "mcl_core_andesite_smooth.png": [107, 113, 109], "mcl_core_apple_golden.png": [176, 138, 51], "mcl_core_diorite.png": [153, 149, 146], "mcl_core_granite_smooth.png": [150, 121, 110], "mcl_core_bedrock.png": [91, 77, 66], "mcl_core_planks_spruce.png": [81, 65, 54], "mcl_core_sapling_big_oak.png": [69, 92, 80], "mcl_core_emerald_ore.png": [115, 122, 103], "mcl_core_sandstone_smooth.png": [202, 155, 121], "mcl_core_glass_light_blue.png": [101, 153, 215], "default_brick.png": [139, 87, 75], "mcl_core_redstone_ore.png": [128, 91, 88], "mcl_core_cactus_top.png": [77, 99, 49], "mcl_core_frosted_ice_1.png": [147, 198, 227], "mcl_core_sapling_spruce.png": [55, 72, 53], "mcl_core_stripped_acacia_top.png": [149, 92, 58], "mcl_core_log_spruce_top.png": [97, 71, 57], "mcl_core_glass_lime.png": [126, 203, 24], "mcl_core_lapis_ore.png": [111, 113, 125], "default_junglesapling.png": [64, 88, 39], "default_clay_brick.png": [127, 57, 48], "default_gold_block.png": [192, 147, 59], "default_water_source_animated.png": [37, 98, 129], "mcl_core_glass_yellow.png": [228, 228, 50], "default_acacia_sapling.png": [109, 92, 59], "mcl_core_stripped_acacia_side.png": [155, 96, 61], "mcl_core_sandstone_carved.png": [199, 152, 119], "mcl_core_glass_blue.png": [50, 75, 178], "mcl_core_red_sandstone_normal.png": [198, 120, 104], "mcl_core_glass_gray.png": [75, 75, 75], "mcl_core_leaves_spruce.png": [38, 74, 47], "mcl_core_glass_pink.png": [241, 126, 164], "mcl_core_lapis_block.png": [50, 92, 162], "mcl_core_glass_purple.png": [126, 62, 178], "mcl_core_iron_nugget.png": [156, 151, 145], "default_papyrus.png": [82, 114, 57], "default_dry_grass.png": [100, 94, 54], "mcl_core_stripped_dark_oak_top.png": [91, 78, 68], "mcl_core_glass_silver.png": [153, 153, 153], "mcl_core_andesite.png": [104, 110, 107], "mcl_core_frosted_ice_3.png": [165, 209, 233], "mcl_core_sugar.png": [215, 215, 215], "default_acacia_wood.png": [152, 100, 69], "mcl_core_glass_black.png": [24, 24, 24], "mcl_core_iron_ore.png": [134, 123, 117], "mcl_core_stripped_birch_side.png": [163, 130, 104], "default_clay.png": [124, 124, 124], "mcl_core_stripped_jungle_side.png": [140, 98, 76], "mcl_core_glass_red.png": [153, 50, 50], "mcl_core_grass_block_top.png": [141, 130, 113], "mcl_core_planks_birch.png": [145, 113, 89], "mcl_core_glass_white.png": [254, 254, 254], "mcl_core_stripped_oak_side.png": [119, 94, 71], "mcl_core_glass_cyan.png": [75, 126, 153], "mcl_core_cactus_side.png": [88, 110, 56], "default_ladder.png": [83, 64, 50], "default_dry_grass_side.png": [91, 93, 52], "mcl_core_stripped_jungle_top.png": [143, 101, 78], "mcl_core_ice_packed.png": [165, 211, 231], "mcl_core_frosted_ice_2.png": [153, 202, 229], "default_dry_shrub.png": [118, 88, 69], "mcl_core_red_sandstone_carved.png": [202, 122, 104], "default_tree.png": [95, 75, 57], "default_clay_lump.png": [111, 111, 111], "mcl_core_red_sandstone_top.png": [212, 126, 108], "mcl_core_dirt_podzol_side.png": [101, 79, 63], "mcl_core_red_sandstone_smooth.png": [207, 124, 106], "default_jungletree_top.png": [125, 87, 67], "mcl_core_coal_ore.png": [109, 101, 99], "default_jungleleaves.png": [29, 84, 30], "mcl_core_vine.png": [21, 61, 21], "default_snow.png": [221, 229, 234], "mcl_core_leaves_big_oak.png": [21, 69, 28], "mcl_core_void.png": [59, 59, 59], "default_tree_top.png": [135, 104, 74], "mcl_core_gold_ore.png": [132, 119, 103], "default_steel_ingot.png": [142, 137, 131], "default_sapling.png": [62, 90, 45], "mcl_core_log_birch.png": [194, 184, 174], "mcl_core_stripped_spruce_top.png": [111, 81, 64], "default_water_flowing_animated.png": [38, 101, 129], "mcl_core_emerald_block.png": [44, 138, 39], "default_jungletree.png": [86, 58, 45], "mcl_core_grass_side_snowed.png": [162, 154, 150], "default_stone_brick.png": [97, 89, 86], "default_lava_flowing_animated.png": [177, 42, 16], "mcl_core_stripped_spruce_side.png": [104, 78, 63], "default_coal_lump.png": [41, 39, 41], "default_sand.png": [220, 170, 127], "mcl_core_glass_green.png": [101, 126, 50], "mcl_core_glass_orange.png": [215, 126, 50], "default_acacia_tree_top.png": [130, 84, 55], "mcl_core_stripped_oak_top.png": [139, 108, 78], "mcl_core_grass_block_side_overlay.png": [153, 142, 123], "default_lava_source_animated.png": [180, 45, 17], "mcl_core_cactus_bottom.png": [169, 168, 116], "mcl_core_sandstone_bottom.png": [202, 155, 121], "default_paper.png": [213, 184, 154], "mcl_core_diamond_ore.png": [122, 124, 126], "default_ice.png": [145, 197, 226], "mcl_core_dirt_podzol_top.png": [85, 63, 42], "mcl_core_slime.png": [93, 157, 86], "mcl_core_gold_nugget.png": [213, 169, 74], "default_stick.png": [88, 70, 57], "mcl_core_emerald.png": [59, 160, 52], "default_diamond.png": [109, 179, 217], "mcl_core_mycelium_top.png": [108, 89, 117], "mcl_core_bone_block_side.png": [226, 207, 174], "mcl_core_diorite_smooth.png": [157, 154, 152], "default_obsidian.png": [13, 9, 25], "mcl_core_planks_big_oak.png": [87, 74, 62], "mcl_core_log_spruce.png": [66, 51, 44], "mcl_core_glass_magenta.png": [178, 75, 215], "mcl_core_granite.png": [153, 121, 110], "mcl_core_log_big_oak_top.png": [83, 70, 62], "default_cobble.png": [113, 106, 104], "mcl_core_red_sandstone_bottom.png": [207, 124, 106], "mcl_core_barrier.png": [138, 46, 38], "mcl_core_stripped_dark_oak_side.png": [86, 73, 63], "mcl_core_mycelium_side.png": [107, 84, 87], "mcl_core_stonebrick_cracked.png": [94, 87, 83], "mcl_core_charcoal.png": [40, 35, 32], "mcl_core_glass_brown.png": [101, 75, 50], "mcl_core_stonebrick_carved.png": [97, 90, 85], "default_wood.png": [113, 87, 67], "default_dirt.png": [108, 83, 70], "mcl_core_log_big_oak.png": [74, 62, 55], "default_junglewood.png": [113, 78, 59], "mcl_core_frosted_ice_0.png": [140, 193, 224], "mcl_core_sandstone_normal.png": [195, 149, 117], "default_gravel.png": [112, 105, 99], "mcl_core_sandstone_top.png": [201, 154, 121], "default_glass.png": [213, 223, 235], "default_stone.png": [130, 122, 118], "mcl_core_sapling_birch.png": [78, 110, 74], "mcl_core_coarse_dirt.png": [117, 92, 76], "default_acacia_leaves.png": [110, 89, 45], "mcl_core_stripped_birch_top.png": [157, 126, 102], "mcl_core_grass_path_top.png": [125, 101, 50], "mcl_throwing_ender_pearl.png": [78, 19, 26], "mcl_throwing_egg.png": [199, 157, 106], "mcl_throwing_snowball.png": [191, 200, 203], "mcl_flowers_tulip_red.png": [82, 57, 43], "mcl_flowers_double_plant_rose_top.png": [81, 69, 45], "mcl_flowers_double_plant_sunflower_front.png": [203, 157, 61], "mcl_flowers_tulip_white.png": [106, 122, 95], "mcl_flowers_double_plant_grass_top.png": [156, 145, 125], "mcl_flowers_azure_bluet.png": [97, 114, 98], "mcl_flowers_oxeye_daisy.png": [130, 139, 110], "mcl_flowers_poppy.png": [96, 59, 43], "mcl_flowers_double_plant_paeonia_top.png": [90, 84, 81], "mcl_flowers_double_plant_rose_bottom.png": [78, 63, 41], "mcl_flowers_tallgrass.png": [151, 141, 122], "mcl_flowers_double_plant_sunflower_bottom.png": [45, 76, 40], "mcl_flowers_fern.png": [143, 132, 115], "flowers_tulip.png": [106, 84, 51], "mcl_flowers_double_plant_syringa_bottom.png": [63, 77, 60], "mcl_flowers_double_plant_fern_bottom.png": [140, 130, 113], "flowers_dandelion_yellow.png": [111, 111, 55], "mcl_flowers_double_plant_paeonia_bottom.png": [82, 83, 73], "mcl_flowers_double_plant_sunflower_back.png": [174, 146, 57], "mcl_flowers_allium.png": [120, 116, 144], "flowers_waterlily.png": [28, 81, 29], "mcl_flowers_tulip_pink.png": [100, 99, 90], "mcl_flowers_double_plant_sunflower_top.png": [48, 81, 44], "mcl_flowers_double_plant_syringa_top.png": [95, 90, 98], "mcl_flowers_double_plant_grass_bottom.png": [151, 140, 121], "mcl_flowers_double_plant_grass_inv.png": [48, 95, 43], "mcl_flowers_fern_inv.png": [43, 86, 39], "mcl_flowers_double_plant_fern_top.png": [148, 138, 119], "mcl_flowers_tallgrass_inv.png": [47, 92, 41], "mcl_flowers_double_plant_fern_inv.png": [45, 89, 40], "mcl_flowers_blue_orchid.png": [46, 91, 86], "mcl_armor_leggings_iron.png": [132, 128, 123], "mcl_armor_inv_leggings_iron.png": [130, 125, 120], "mcl_armor_chestplate_chain_preview.png": [124, 98, 90], "mcl_armor_inv_helmet_gold.png": [178, 134, 51], "mcl_armor_leggings_chain.png": [64, 66, 69], "mcl_armor_helmet_chain_preview.png": [154, 150, 143], "mcl_armor_chestplate_diamond_preview.png": [102, 140, 160], "mcl_armor_inv_boots_iron.png": [134, 129, 124], "mcl_armor_boots_gold_preview.png": [178, 133, 42], "mcl_armor_leggings_diamond_preview.png": [80, 118, 138], "mcl_armor_inv_chestplate_chain.png": [128, 105, 96], "mcl_armor_helmet_diamond_preview.png": [101, 134, 152], "mcl_armor_boots_leather_preview.png": [129, 119, 101], "mcl_armor_inv_chestplate_gold.png": [171, 128, 55], "mcl_armor_inv_helmet_diamond.png": [109, 130, 142], "mcl_armor_leggings_leather_preview.png": [141, 134, 114], "mcl_armor_boots_leather.png": [122, 111, 93], "mcl_armor_inv_chestplate_diamond.png": [106, 146, 168], "mcl_armor_helmet_diamond.png": [70, 85, 93], "mcl_armor_chestplate_iron_preview.png": [143, 134, 123], "mcl_armor_inv_chestplate_leather.png": [143, 136, 118], "mcl_armor_boots_diamond.png": [87, 132, 157], "mcl_armor_leggings_diamond.png": [78, 102, 115], "mcl_armor_leggings_gold_preview.png": [185, 156, 108], "mcl_armor_chestplate_gold.png": [157, 117, 55], "mcl_armor_inv_helmet_chain.png": [140, 137, 132], "mcl_armor_boots_chain_preview.png": [78, 78, 79], "mcl_armor_inv_leggings_chain.png": [81, 81, 82], "mcl_armor_inv_helmet_iron.png": [143, 138, 133], "mcl_armor_helmet_leather.png": [130, 121, 102], "mcl_armor_chestplate_diamond.png": [110, 157, 183], "mcl_armor_leggings_leather.png": [119, 108, 91], "mcl_armor_leggings_iron_preview.png": [127, 122, 117], "mcl_armor_inv_boots_gold.png": [187, 142, 46], "mcl_armor_chestplate_leather.png": [139, 132, 112], "mcl_armor_boots_iron.png": [118, 113, 109], "mcl_armor_elytra.png": [75, 121, 147], "mcl_armor_helmet_chain.png": [127, 124, 121], "mcl_armor_helmet_gold_preview.png": [181, 138, 54], "mcl_armor_boots_iron_preview.png": [118, 113, 108], "mcl_armor_helmet_iron.png": [153, 149, 144], "mcl_armor_inv_boots_leather.png": [130, 121, 103], "mcl_armor_leggings_chain_preview.png": [54, 56, 61], "mcl_armor_helmet_iron_preview.png": [143, 138, 132], "mcl_armor_helmet_leather_preview.png": [119, 109, 91], "mcl_armor_chestplate_leather_preview.png": [144, 138, 118], "mcl_armor_leggings_gold.png": [182, 158, 126], "mcl_armor_inv_leggings_gold.png": [175, 145, 97], "mcl_armor_chestplate_iron.png": [130, 120, 112], "mcl_armor_inv_elytra.png": [76, 122, 148], "mcl_armor_boots_chain.png": [88, 88, 88], "mcl_armor_helmet_gold.png": [178, 136, 56], "mcl_armor_inv_boots_diamond.png": [75, 121, 147], "mcl_armor_inv_chestplate_iron.png": [135, 125, 115], "mcl_armor_inv_leggings_diamond.png": [75, 93, 103], "mcl_armor_inv_leggings_leather.png": [126, 116, 98], "mcl_armor_inv_helmet_leather.png": [140, 132, 114], "mcl_armor_inv_boots_chain.png": [69, 69, 72], "mcl_armor_chestplate_gold_preview.png": [169, 127, 56], "mcl_armor_chestplate_chain.png": [119, 98, 93], "mcl_armor_boots_gold.png": [160, 118, 42], "mcl_armor_boots_diamond_preview.png": [89, 141, 169], "mcl_walls_cobble_wall_top.png": [120, 114, 112], "mcl_walls_cobble_mossy_wall_top.png": [53, 97, 61], "mcl_walls_cobble_wall_side.png": [109, 103, 101], "mcl_walls_cobble_mossy_wall_side.png": [86, 98, 83], "mcl_hoppers_item.png": [44, 44, 44], "mcl_hoppers_hopper_top.png": [43, 43, 43], "mcl_hoppers_hopper_outside.png": [44, 43, 43], "mcl_hoppers_hopper_inside.png": [50, 50, 50], "mcl_stairs_stone_slab_top.png": [127, 118, 114], "mcl_stairs_stone_slab_side.png": [127, 117, 113], "mcl_stairs_turntexture.png": [255, 0, 255], "mcl_brewing_bottle_bg.png": [204, 204, 204], "mcl_brewing_bubble_sprite.png": [167, 167, 167], "mcl_brewing_side.png": [175, 156, 160], "mcl_brewing_inventory.png": [168, 168, 168], "mcl_brewing_bubbles_active.png": [186, 186, 186], "mcl_brewing_fuel_bg.png": [200, 200, 200], "mcl_brewing_potion_bg.png": [204, 204, 204], "mcl_brewing_bubbles.png": [154, 154, 154], "mcl_brewing_top.png": [139, 130, 126], "mcl_brewing_base.png": [130, 122, 118], "mcl_brewing_burner.png": [183, 183, 183], "mcl_brewing_burner_active.png": [212, 161, 132], "xpanes_top_glass_cyan.png": [76, 127, 153], "xpanes_top_glass_brown.png": [102, 76, 51], "xpanes_top_glass_magenta.png": [178, 75, 215], "xpanes_top_glass_light_blue.png": [102, 153, 216], "xpanes_top_glass_blue.png": [51, 76, 178], "xpanes_top_glass_gray.png": [76, 76, 76], "xpanes_top_glass_silver.png": [153, 153, 153], "xpanes_top_iron.png": [155, 146, 146], "xpanes_top_glass_black.png": [25, 25, 25], "xpanes_top_glass_white.png": [255, 255, 255], "xpanes_top_glass_lime.png": [127, 204, 25], "xpanes_top_glass_orange.png": [216, 127, 51], "xpanes_top_glass_purple.png": [127, 63, 178], "xpanes_top_glass_red.png": [153, 51, 51], "xpanes_top_glass_natural.png": [222, 222, 239], "xpanes_top_glass_green.png": [102, 127, 51], "xpanes_top_glass_pink.png": [241, 126, 164], "xpanes_pane_iron.png": [160, 152, 152], "xpanes_top_glass_yellow.png": [229, 229, 51], "hardened_clay_stained_pink.png": [164, 79, 76], "mcl_colorblocks_glazed_terracotta_yellow.png": [232, 199, 99], "mcl_colorblocks_glazed_terracotta_orange.png": [170, 146, 81], "mcl_colorblocks_concrete_powder_lime.png": [125, 186, 42], "mcl_colorblocks_concrete_brown.png": [98, 60, 32], "mcl_colorblocks_concrete_magenta.png": [171, 49, 162], "mcl_colorblocks_glazed_terracotta_magenta.png": [210, 108, 215], "mcl_colorblocks_concrete_silver.png": [128, 129, 118], "mcl_colorblocks_glazed_terracotta_grey.png": [90, 90, 90], "mcl_colorblocks_concrete_powder_blue.png": [72, 75, 169], "mcl_colorblocks_concrete_yellow.png": [241, 177, 21], "mcl_colorblocks_concrete_red.png": [146, 34, 34], "mcl_colorblocks_glazed_terracotta_lime.png": [152, 211, 72], "mcl_colorblocks_concrete_black.png": [8, 10, 15], "mcl_colorblocks_glazed_terracotta_silver.png": [134, 151, 151], "hardened_clay_stained_white.png": [213, 197, 184], "mcl_colorblocks_glazed_terracotta_green.png": [111, 135, 50], "mcl_colorblocks_glazed_terracotta_blue.png": [34, 65, 117], "mcl_colorblocks_concrete_powder_red.png": [172, 57, 52], "mcl_colorblocks_concrete_powder_cyan.png": [38, 150, 159], "hardened_clay_stained_purple.png": [81, 71, 123], "hardened_clay_stained_brown.png": [96, 69, 61], "hardened_clay_stained_grey.png": [110, 92, 85], "mcl_colorblocks_concrete_lime.png": [96, 171, 25], "hardened_clay_stained_blue.png": [68, 91, 143], "mcl_colorblocks_concrete_powder_white.png": [224, 225, 225], "hardened_clay_stained_yellow.png": [177, 128, 51], "hardened_clay_stained_light_blue.png": [91, 128, 171], "hardened_clay.png": [143, 104, 87], "mcl_colorblocks_concrete_cyan.png": [21, 123, 140], "mcl_colorblocks_glazed_terracotta_brown.png": [108, 88, 64], "mcl_colorblocks_concrete_grey.png": [56, 59, 64], "mcl_colorblocks_concrete_powder_magenta.png": [196, 94, 189], "mcl_colorblocks_concrete_powder_black.png": [22, 26, 30], "mcl_colorblocks_concrete_pink.png": [213, 103, 144], "mcl_colorblocks_concrete_powder_orange.png": [227, 141, 38], "mcl_colorblocks_glazed_terracotta_cyan.png": [90, 131, 136], "mcl_colorblocks_glazed_terracotta_red.png": [184, 67, 53], "mcl_colorblocks_concrete_green.png": [75, 94, 37], "mcl_colorblocks_concrete_blue.png": [46, 48, 147], "mcl_colorblocks_glazed_terracotta_light_blue.png": [99, 162, 204], "hardened_clay_stained_orange.png": [156, 95, 69], "mcl_colorblocks_concrete_powder_silver.png": [160, 160, 155], "mcl_colorblocks_concrete_powder_pink.png": [224, 148, 176], "hardened_clay_stained_silver.png": [149, 129, 117], "hardened_clay_stained_red.png": [159, 81, 66], "hardened_clay_stained_magenta.png": [150, 80, 85], "mcl_colorblocks_glazed_terracotta_black.png": [38, 22, 22], "mcl_colorblocks_concrete_white.png": [208, 214, 215], "hardened_clay_stained_green.png": [74, 101, 63], "hardened_clay_stained_lime.png": [105, 134, 73], "mcl_colorblocks_concrete_powder_green.png": [104, 127, 45], "mcl_colorblocks_concrete_light_blue.png": [37, 140, 200], "mcl_colorblocks_concrete_powder_brown.png": [128, 86, 54], "mcl_colorblocks_concrete_purple.png": [103, 32, 159], "hardened_clay_stained_cyan.png": [71, 107, 123], "mcl_colorblocks_concrete_powder_purple.png": [138, 58, 180], "mcl_colorblocks_concrete_powder_yellow.png": [230, 198, 54], "mcl_colorblocks_concrete_powder_light_blue.png": [75, 181, 212], "mcl_colorblocks_glazed_terracotta_pink.png": [251, 138, 170], "mcl_colorblocks_glazed_terracotta_purple.png": [112, 49, 152], "mcl_colorblocks_concrete_orange.png": [226, 101, 1], "mcl_colorblocks_concrete_powder_grey.png": [91, 98, 103], "hardened_clay_stained_black.png": [69, 52, 46], "mcl_colorblocks_glazed_terracotta_white.png": [188, 211, 202], "fire_basic_flame_animated.png": [206, 98, 34], "mcl_burning_hud_flame_animated.png": [206, 98, 34], "mcl_fire_fire_charge.png": [95, 58, 41], "mcl_burning_entity_flame_animated.png": [206, 98, 34], "mcl_fire_flint_and_steel.png": [96, 95, 93], "fire_basic_flame.png": [207, 100, 36], "dye_red.png": [113, 74, 47], "dye_yellow.png": [123, 91, 49], "dye_violet.png": [107, 76, 57], "dye_dark_green.png": [99, 81, 47], "mcl_dye_blue.png": [58, 101, 173], "dye_cyan.png": [104, 89, 60], "mcl_dye_lime.png": [107, 91, 53], "dye_pink.png": [120, 81, 61], "mcl_dye_light_blue.png": [103, 88, 70], "dye_dark_grey.png": [108, 81, 52], "mcl_dye_white.png": [205, 193, 166], "dye_grey.png": [113, 86, 58], "dye_magenta.png": [111, 79, 59], "dye_orange.png": [122, 85, 48], "mcl_dye_brown.png": [104, 75, 56], "mcl_dye_black.png": [56, 56, 64], "default_river_water_flowing_animated.png": [38, 123, 130], "default_river_water_source_animated.png": [37, 120, 130], "3d_armor_stand_item.png": [134, 114, 98], "mob_spawner.png": [40, 40, 40], "mcl_nether_quartz_chiseled_side.png": [194, 186, 183], "mcl_nether_quartz_pillar_top.png": [195, 188, 185], "mcl_nether_nether_wart.png": [190, 79, 75], "mcl_nether_nether_wart_stage_1.png": [86, 54, 51], "mcl_nether_quartz_ore.png": [133, 64, 53], "mcl_nether_soul_sand.png": [90, 70, 51], "mcl_nether_nether_wart_block.png": [175, 76, 73], "mcl_nether_nether_wart_stage_0.png": [53, 41, 38], "mcl_nether_quartz_block_bottom.png": [198, 191, 187], "mcl_nether_quartz_block_top.png": [198, 190, 187], "mcl_nether_quartz.png": [152, 149, 147], "mcl_nether_quartz_pillar_side.png": [195, 188, 184], "mcl_nether_netherbrick.png": [58, 24, 20], "mcl_nether_glowstone.png": [202, 154, 96], "mcl_nether_netherrack.png": [130, 50, 39], "mcl_nether_red_nether_brick.png": [69, 17, 5], "mcl_nether_quartz_chiseled_top.png": [197, 189, 186], "mcl_nether_glowstone_dust.png": [209, 137, 67], "mcl_nether_nether_wart_stage_2.png": [106, 57, 53], "mcl_nether_quartz_block_side.png": [198, 190, 187], "mcl_nether_nether_brick.png": [49, 23, 24], "mcl_nether_magma.png": [85, 33, 27], "mcl_cauldrons_cauldron_inner.png": [24, 24, 24], "mcl_cauldrons_cauldron_top.png": [54, 54, 54], "mcl_cauldrons_cauldron_bottom.png": [50, 37, 38], "mcl_cauldrons_cauldron.png": [47, 47, 47], "mcl_cauldrons_cauldron_side.png": [43, 43, 43], "mcl_beds_bed_side_bottom_magenta.png": [127, 48, 89], "mcl_beds_bed_blue.png": [73, 78, 105], "mcl_beds_bed_side_top_r_black.png": [99, 86, 75], "mcl_beds_bed_side_bottom_r_magenta.png": [132, 46, 94], "mcl_beds_bed_side_top_brown.png": [98, 76, 59], "mcl_beds_bed_lime.png": [96, 135, 66], "mcl_beds_bed_side_top_green.png": [98, 76, 59], "mcl_beds_bed_light_blue.png": [100, 107, 142], "mcl_beds_bed_pink.png": [184, 105, 115], "mcl_beds_bed_side_bottom_black.png": [66, 56, 47], "mcl_beds_bed_top_bottom_green.png": [57, 110, 29], "mcl_beds_bed_side_top_blue.png": [98, 76, 59], "mcl_beds_bed_top_top_pink.png": [217, 138, 147], "mcl_beds_bed_side_bottom_light_blue.png": [90, 94, 129], "mcl_beds_bed_side_bottom_blue.png": [63, 65, 90], "mcl_beds_bed_top_top_red.png": [173, 90, 83], "mcl_beds_bed_side_top_grey.png": [98, 76, 59], "mcl_beds_bed_top_top_white.png": [198, 190, 183], "mcl_beds_bed_top_top_black.png": [107, 100, 92], "mcl_beds_bed_top_bottom_brown.png": [101, 69, 38], "mcl_beds_bed_top_bottom_pink.png": [232, 105, 135], "mcl_beds_bed_side_bottom_r_pink.png": [183, 95, 106], "mcl_beds_bed_side_bottom_r_green.png": [73, 97, 42], "mcl_beds_bed_side_bottom_r_grey.png": [86, 77, 69], "mcl_beds_bed_side_top_r_white.png": [158, 145, 134], "mcl_beds_bed_side_bottom_orange.png": [143, 84, 28], "mcl_beds_bed_side_bottom_purple.png": [105, 36, 112], "mcl_beds_bed_side_bottom_r_light_blue.png": [90, 97, 136], "mcl_beds_bed_side_top_r_magenta.png": [140, 81, 103], "mcl_beds_bed_side_bottom_r_yellow.png": [150, 131, 25], "mcl_beds_bed_side_top_r_pink.png": [176, 111, 113], "mcl_beds_bed_top_top_blue.png": [105, 112, 137], "mcl_beds_bed_side_bottom_green.png": [74, 94, 43], "mcl_beds_bed_side_bottom_r_blue.png": [61, 66, 95], "mcl_beds_bed_top_top_grey.png": [129, 121, 113], "mcl_beds_bed_black.png": [76, 68, 61], "mcl_beds_bed_top_top_silver.png": [159, 151, 143], "mcl_beds_bed_white.png": [173, 165, 158], "mcl_beds_bed_top_top_cyan.png": [105, 144, 135], "mcl_beds_bed_top_bottom_orange.png": [184, 91, 0], "mcl_beds_bed_side_top_silver.png": [98, 76, 59], "mcl_beds_bed_top_top_brown.png": [143, 118, 93], "mcl_beds_bed_side_top_r_light_blue.png": [115, 111, 132], "mcl_beds_bed_side_bottom_r_lime.png": [86, 129, 53], "mcl_beds_bed_red.png": [139, 58, 51], "mcl_beds_bed_top_bottom_lime.png": [79, 163, 47], "mcl_beds_bed_side_top_r_brown.png": [121, 97, 75], "mcl_beds_bed_side_bottom_r_silver.png": [119, 109, 102], "mcl_beds_bed_yellow.png": [154, 138, 41], "mcl_beds_bed_side_top_yellow.png": [98, 76, 59], "mcl_beds_bed_top_bottom_black.png": [37, 37, 37], "mcl_beds_bed_brown.png": [110, 85, 61], "mcl_beds_bed_side_top_orange.png": [98, 76, 59], "mcl_beds_bed_side_top_red.png": [98, 76, 59], "mcl_beds_bed_top_top_purple.png": [148, 79, 161], "mcl_beds_bed_side_bottom_pink.png": [177, 93, 102], "mcl_beds_bed_side_top_r_grey.png": [112, 99, 88], "mcl_beds_bed_side_top_r_blue.png": [97, 91, 104], "mcl_beds_bed_side_top_purple.png": [98, 76, 59], "mcl_beds_bed_side_top_cyan.png": [98, 76, 59], "mcl_beds_bed_top_bottom_blue.png": [32, 60, 119], "mcl_beds_bed_side_bottom_yellow.png": [143, 125, 28], "mcl_beds_bed_side_top_black.png": [98, 76, 59], "mcl_beds_bed_top_top_orange.png": [188, 130, 72], "mcl_beds_bed_top_bottom_silver.png": [129, 129, 129], "mcl_beds_bed_top_top_green.png": [117, 140, 88], "mcl_beds_bed_cyan.png": [73, 111, 103], "mcl_beds_bed_top_bottom_red.png": [157, 20, 20], "mcl_beds_bed_top_bottom_purple.png": [111, 0, 163], "mcl_beds_bed_side_top_r_silver.png": [133, 120, 109], "mcl_beds_bed_side_bottom_grey.png": [86, 76, 67], "mcl_beds_bed_grey.png": [96, 88, 81], "mcl_beds_bed_side_top_r_yellow.png": [151, 132, 62], "mcl_beds_bed_side_top_r_green.png": [103, 111, 72], "mcl_beds_bed_side_bottom_brown.png": [100, 73, 48], "mcl_beds_bed_magenta.png": [138, 60, 104], "mcl_beds_bed_side_bottom_r_red.png": [134, 44, 37], "mcl_beds_bed_side_bottom_r_brown.png": [101, 73, 47], "mcl_beds_bed_side_top_lime.png": [98, 76, 59], "mcl_beds_bed_side_top_light_blue.png": [98, 76, 59], "mcl_beds_bed_side_bottom_red.png": [129, 47, 38], "mcl_beds_bed_bottom_top.png": [48, 38, 29], "mcl_beds_bed_top_bottom_grey.png": [76, 76, 76], "mcl_beds_bed_side_bottom_r_orange.png": [150, 86, 25], "mcl_beds_bed_side_bottom_r_black.png": [64, 54, 47], "mcl_beds_bed_top_bottom_cyan.png": [32, 119, 114], "mcl_beds_bed_side_bottom_silver.png": [116, 106, 97], "mcl_beds_bed_side_top_magenta.png": [98, 76, 59], "mcl_beds_bed_top_bottom_white.png": [201, 201, 201], "mcl_beds_bed_side_top_r_orange.png": [151, 105, 62], "mcl_beds_bed_top_bottom_magenta.png": [154, 23, 118], "mcl_beds_bed_side_top_r_lime.png": [110, 131, 80], "mcl_beds_bed_top_top_magenta.png": [172, 92, 137], "mcl_beds_bed_bottom_bottom.png": [48, 38, 29], "mcl_beds_bed_side_top_r_purple.png": [125, 73, 119], "mcl_beds_bed_side_top_r_cyan.png": [97, 113, 103], "mcl_beds_bed_side_top_white.png": [98, 76, 59], "mcl_beds_bed_side_bottom_r_cyan.png": [61, 101, 93], "mcl_beds_bed_side_bottom_cyan.png": [63, 97, 89], "mcl_beds_bed_side_bottom_white.png": [161, 151, 142], "mcl_beds_bed_top_bottom_yellow.png": [184, 169, 0], "mcl_beds_bed_top_bottom_light_blue.png": [82, 113, 182], "mcl_beds_bed_top_top_lime.png": [130, 169, 98], "mcl_beds_bed_silver.png": [109, 100, 93], "mcl_beds_bed_purple.png": [115, 47, 128], "mcl_beds_bed_side_top_r_red.png": [141, 80, 69], "mcl_beds_bed_top_top_light_blue.png": [132, 141, 174], "mcl_beds_bed_side_bottom_r_purple.png": [107, 32, 120], "mcl_beds_bed_side_bottom_r_white.png": [161, 151, 144], "mcl_beds_bed_orange.png": [154, 96, 41], "mcl_beds_bed_top_bottom_gray.png": [57, 57, 57], "mcl_beds_bed_side_bottom_lime.png": [85, 122, 53], "mcl_beds_bed_green.png": [85, 107, 56], "mcl_beds_bed_top_top_yellow.png": [188, 172, 72], "mcl_beds_bed_side_top_pink.png": [98, 76, 59], "mcl_sponges_sponge_wet_river_water.png": [157, 141, 104], "mcl_sponges_sponge.png": [210, 177, 118], "mcl_sponges_sponge_wet.png": [156, 134, 92], "farming_mushroom_red.png": [169, 59, 58], "mcl_mushrooms_mushroom_block_inside.png": [218, 175, 136], "mcl_mushrooms_mushroom_block_skin_brown.png": [131, 86, 68], "mcl_mushrooms_mushroom_block_skin_stem.png": [204, 183, 149], "mcl_mushrooms_mushroom_block_skin_red.png": [137, 39, 25], "farming_mushroom_brown.png": [121, 81, 59], "farming_mushroom_stew.png": [134, 97, 67], "default_tool_goldsword.png": [194, 154, 70], "default_tool_steelsword.png": [134, 130, 125], "default_tool_woodsword.png": [100, 82, 68], "default_tool_goldshovel.png": [167, 133, 64], "default_tool_steelpick.png": [137, 128, 119], "default_tool_woodshovel.png": [108, 90, 76], "default_tool_goldpick.png": [172, 139, 73], "default_tool_woodaxe.png": [110, 92, 77], "default_tool_diamondsword.png": [105, 133, 149], "default_tool_steelshovel.png": [125, 115, 107], "default_tool_stonesword.png": [133, 125, 118], "default_tool_woodpick.png": [110, 91, 76], "default_tool_shears.png": [139, 132, 124], "default_tool_goldaxe.png": [160, 128, 66], "default_tool_stoneshovel.png": [126, 116, 107], "default_tool_diamondaxe.png": [103, 110, 113], "default_tool_diamondshovel.png": [106, 125, 134], "default_tool_steelaxe.png": [129, 119, 110], "default_tool_stoneaxe.png": [126, 115, 104], "default_tool_diamondpick.png": [92, 105, 111], "default_tool_stonepick.png": [126, 114, 104], "mcl_chests_ender_chest_right.png": [73, 67, 64], "mcl_chests_chest_trapped_right.png": [98, 78, 62], "default_chest_front.png": [85, 70, 58], "mcl_chests_blue_shulker_box_top.png": [67, 85, 119], "mcl_chests_chest_left.png": [99, 78, 63], "mcl_chests_dark_green_shulker_box_top.png": [67, 111, 70], "mcl_chests_chest_back.png": [92, 75, 61], "mcl_chests_ender_chest_bottom.png": [61, 55, 55], "mcl_chests_ender.png": [70, 62, 58], "mcl_chests_brown_shulker_box_top.png": [73, 63, 55], "mcl_chests_chest_trapped_back.png": [92, 75, 61], "mcl_chests_chest_trapped_side_big.png": [96, 77, 62], "mcl_chests_magenta_shulker_box_top.png": [128, 81, 124], "mcl_chests_ender_chest_back.png": [72, 66, 64], "mcl_chests_chest_trapped_bottom.png": [118, 91, 70], "mcl_chests_chest_trapped_front.png": [86, 68, 57], "default_chest_side_big.png": [96, 77, 62], "mcl_chests_green_shulker_box_top.png": [88, 122, 75], "mcl_chests_pink_shulker_box_top.png": [163, 116, 158], "mcl_chests_trapped.png": [95, 76, 61], "mcl_chests_blank.png": [255, 255, 255], "mcl_chests_normal_double.png": [98, 78, 62], "mcl_chests_chest_trapped_top.png": [88, 73, 61], "mcl_chests_normal.png": [95, 76, 61], "default_chest_front_big.png": [93, 75, 61], "mcl_chests_ender_chest_front.png": [76, 69, 65], "mcl_chests_white_shulker_box_top.png": [176, 178, 187], "mcl_chests_cyan_shulker_box_top.png": [67, 101, 121], "mcl_chests_chest_trapped_top_big.png": [100, 80, 65], "default_chest_top_big.png": [100, 80, 65], "mcl_chests_grey_shulker_box_top.png": [126, 129, 138], "mcl_chests_red_shulker_box_top.png": [132, 58, 57], "mcl_chests_trapped_double.png": [98, 78, 62], "mcl_chests_violet_shulker_box_top.png": [120, 71, 88], "mcl_chests_chest_trapped_front_big.png": [94, 75, 61], "mcl_chests_lightblue_shulker_box_top.png": [96, 130, 155], "mcl_chests_dark_grey_shulker_box_top.png": [87, 90, 99], "mcl_chests_black_shulker_box_top.png": [56, 57, 62], "mcl_chests_chest_right.png": [98, 78, 62], "mcl_chests_yellow_shulker_box_top.png": [165, 116, 53], "mcl_chests_chest_bottom.png": [118, 91, 70], "default_chest_top.png": [88, 73, 61], "mcl_chests_ender_chest_top.png": [70, 64, 61], "mcl_chests_ender_chest_left.png": [73, 67, 64], "mcl_chests_chest_trapped_left.png": [99, 78, 63], "mcl_chests_orange_shulker_box_top.png": [143, 74, 51], "screwdriver.png": [132, 119, 108], "_un.png": [0, 0, 0], "_at.png": [0, 0, 0], "_s_.png": [0, 0, 0], "_sz.png": [0, 0, 0], "_q.png": [0, 0, 0], "_1.png": [0, 0, 0], "_h_.png": [0, 0, 0], "_o_tilde.png": [0, 0, 0], "_q_.png": [0, 0, 0], "_ae.png": [0, 0, 0], "_e_circumflex_.png": [0, 0, 0], "_ex.png": [0, 0, 0], "_e_.png": [0, 0, 0], "_qo.png": [0, 0, 0], "_z_.png": [0, 0, 0], "_ps.png": [0, 0, 0], "_pound.png": [0, 0, 0], "_div.png": [0, 0, 0], "_l_.png": [0, 0, 0], "_pilcrow.png": [0, 0, 0], "_3_sup.png": [0, 0, 0], "_e_acute.png": [0, 0, 0], "_9.png": [0, 0, 0], "_e_grave_.png": [0, 0, 0], "_u_acute.png": [0, 0, 0], "_a_sup.png": [0, 0, 0], "_sr.png": [0, 0, 0], "_v.png": [0, 0, 0], "_ue_.png": [0, 0, 0], "_t_.png": [0, 0, 0], "_cl.png": [0, 0, 0], "_n_tilde_.png": [0, 0, 0], "_p_.png": [0, 0, 0], "_c.png": [0, 0, 0], "_a.png": [0, 0, 0], "_a_circumflex_.png": [0, 0, 0], "_8.png": [0, 0, 0], "_s.png": [0, 0, 0], "_o_.png": [0, 0, 0], "_1_4.png": [0, 0, 0], "_e_grave.png": [0, 0, 0], "_o_dash.png": [0, 0, 0], "_5.png": [0, 0, 0], "_d_dash_.png": [0, 0, 0], "_i_grave.png": [0, 0, 0], "_vb.png": [0, 0, 0], "_sp.png": [255, 255, 255], "_a_acute_.png": [0, 0, 0], "_as.png": [0, 0, 0], "_y_acute.png": [0, 0, 0], "_3_4.png": [0, 0, 0], "_6.png": [0, 0, 0], "_7.png": [0, 0, 0], "_tl.png": [0, 0, 0], "_t.png": [0, 0, 0], "_y.png": [0, 0, 0], "_ca.png": [0, 0, 0], "_e.png": [0, 0, 0], "_hs.png": [0, 0, 0], "_copyright.png": [0, 0, 0], "_l.png": [0, 0, 0], "_h.png": [0, 0, 0], "_u_circumflex_.png": [0, 0, 0], "_i_acute_.png": [0, 0, 0], "_ha.png": [0, 0, 0], "_y_diaresis.png": [0, 0, 0], "_gt.png": [0, 0, 0], "_b.png": [0, 0, 0], "_degree.png": [0, 0, 0], "_a_tilde_.png": [0, 0, 0], "_u_.png": [0, 0, 0], "_o_sup.png": [0, 0, 0], "_m_.png": [0, 0, 0], "_c_.png": [0, 0, 0], "_cr.png": [0, 0, 0], "_3.png": [0, 0, 0], "_currency.png": [0, 0, 0], "_f.png": [0, 0, 0], "_cedille.png": [0, 0, 0], "_u_grave_.png": [0, 0, 0], "_dt.png": [0, 0, 0], "_am.png": [0, 0, 0], "_c_cedille_.png": [0, 0, 0], "_u_acute_.png": [0, 0, 0], "_bl.png": [0, 0, 0], "_registered.png": [0, 0, 0], "_i_acute.png": [0, 0, 0], "_lt.png": [0, 0, 0], "_e_acute_.png": [0, 0, 0], "_paragraph.png": [0, 0, 0], "_i_grave_.png": [0, 0, 0], "_o.png": [0, 0, 0], "_1_sup.png": [0, 0, 0], "mcl_signs_sign.png": [114, 89, 69], "_yen.png": [0, 0, 0], "_b_.png": [0, 0, 0], "_macron.png": [0, 0, 0], "_qu_inv.png": [0, 0, 0], "_o_dash_.png": [0, 0, 0], "_guill_right.png": [0, 0, 0], "_p.png": [0, 0, 0], "_thorn_.png": [0, 0, 0], "_2_sup.png": [0, 0, 0], "_pr.png": [0, 0, 0], "default_sign.png": [145, 115, 88], "_times_dot.png": [0, 0, 0], "_acute.png": [0, 0, 0], "_g_.png": [0, 0, 0], "_o_acute_.png": [0, 0, 0], "_a_tilde.png": [0, 0, 0], "_j.png": [0, 0, 0], "_k.png": [0, 0, 0], "_co.png": [0, 0, 0], "_dv.png": [0, 0, 0], "_o_circumflex.png": [0, 0, 0], "_a_ring.png": [0, 0, 0], "_br.png": [0, 0, 0], "_d.png": [0, 0, 0], "_ap.png": [0, 0, 0], "_sl.png": [0, 0, 0], "_mn.png": [0, 0, 0], "_m.png": [0, 0, 0], "_ae_lig.png": [0, 0, 0], "_thorn.png": [0, 0, 0], "_2.png": [0, 0, 0], "_gr.png": [0, 0, 0], "_i.png": [0, 0, 0], "_y_acute_.png": [0, 0, 0], "_diaresis.png": [0, 0, 0], "_oe.png": [0, 0, 0], "_mu.png": [0, 0, 0], "_guill_left.png": [0, 0, 0], "_times_cross.png": [0, 0, 0], "_ae_.png": [0, 0, 0], "_w.png": [0, 0, 0], "_u.png": [0, 0, 0], "_broken_bar.png": [0, 0, 0], "_4.png": [0, 0, 0], "_plus_minus.png": [0, 0, 0], "_1_2.png": [0, 0, 0], "_u_circumflex.png": [0, 0, 0], "_w_.png": [0, 0, 0], "_x_.png": [0, 0, 0], "_e_circumflex.png": [0, 0, 0], "_g.png": [0, 0, 0], "_o_tilde_.png": [0, 0, 0], "_ae_lig_.png": [0, 0, 0], "_v_.png": [0, 0, 0], "_dl.png": [0, 0, 0], "_a_grave.png": [0, 0, 0], "_re.png": [0, 0, 0], "_a_acute.png": [0, 0, 0], "_qu.png": [0, 0, 0], "_oe_.png": [0, 0, 0], "_n_tilde.png": [0, 0, 0], "_eq.png": [0, 0, 0], "_d_.png": [0, 0, 0], "_sm.png": [0, 0, 0], "_y_.png": [0, 0, 0], "_not.png": [0, 0, 0], "_n.png": [0, 0, 0], "_j_.png": [0, 0, 0], "_k_.png": [0, 0, 0], "_0.png": [0, 0, 0], "_o_grave_.png": [0, 0, 0], "_r_.png": [0, 0, 0], "_r.png": [0, 0, 0], "_u_grave.png": [0, 0, 0], "_ee_.png": [0, 0, 0], "_c_cedille.png": [0, 0, 0], "_ex_inv.png": [0, 0, 0], "_cm.png": [0, 0, 0], "_o_grave.png": [0, 0, 0], "_x.png": [0, 0, 0], "_i_.png": [0, 0, 0], "_n_.png": [0, 0, 0], "_rc.png": [0, 0, 0], "_a_.png": [0, 0, 0], "_a_grave_.png": [0, 0, 0], "_ee.png": [0, 0, 0], "_o_acute.png": [0, 0, 0], "_a_ring_.png": [0, 0, 0], "_i_circumflex_.png": [0, 0, 0], "_cent.png": [0, 0, 0], "_d_dash.png": [0, 0, 0], "_f_.png": [0, 0, 0], "_o_circumflex_.png": [0, 0, 0], "_ue.png": [0, 0, 0], "_a_circumflex.png": [0, 0, 0], "_i_circumflex.png": [0, 0, 0], "_z.png": [0, 0, 0], "gui_furnace_arrow_fg.png": [239, 239, 239], "default_furnace_front.png": [105, 95, 91], "default_furnace_fire_bg.png": [139, 139, 139], "default_furnace_top.png": [148, 138, 133], "default_furnace_fire_fg.png": [179, 115, 70], "default_furnace_side.png": [117, 107, 102], "gui_furnace_arrow_bg.png": [139, 139, 139], "default_furnace_front_active.png": [119, 95, 85], "default_furnace_bottom.png": [148, 138, 133], "default_torch_on_floor.png": [115, 82, 59], "default_torch_on_floor_animated.png": [116, 84, 61], "default_tnt_bottom.png": [161, 54, 58], "mcl_tnt_blink.png": [255, 255, 255], "default_tnt_top.png": [125, 54, 57], "default_tnt_side.png": [178, 105, 98], "mcl_heads_skeleton.png": [125, 125, 125], "mcl_heads_skeleton_node.png": [124, 124, 124], "mcl_heads_creeper_node.png": [98, 107, 71], "mcl_heads_zombie.png": [66, 104, 69], "mcl_heads_creeper.png": [92, 110, 68], "mcl_heads_steve_node.png": [115, 70, 58], "mcl_heads_skeleton_preview.png": [128, 127, 127], "mcl_heads_steve_preview.png": [117, 83, 66], "mcl_heads_zombie_node.png": [78, 110, 105], "mcl_heads_steve.png": [108, 76, 59], "mcl_heads_wither_skeleton_node.png": [50, 50, 50], "mcl_heads_zombie_preview.png": [66, 103, 68], "mcl_heads_creeper_preview.png": [88, 110, 65], "mcl_heads_wither_skeleton.png": [50, 50, 50], "mcl_heads_wither_skeleton_preview.png": [50, 50, 50], "mcl_flowerpots_cactus.png": [109, 83, 52], "mcl_flowerpots_flowerpot_inventory.png": [121, 54, 45], "mcl_flowerpots_flowerpot.png": [120, 55, 47], "bucket_lava.png": [166, 127, 113], "bucket_river_water.png": [139, 152, 155], "bucket_water.png": [139, 147, 155], "bucket.png": [147, 143, 139], "mcl_anvils_anvil_top_damaged_1.png": [48, 48, 48], "mcl_anvils_anvil_top_damaged_2.png": [46, 46, 46], "mcl_anvils_anvil_top_damaged_0.png": [50, 50, 50], "mcl_anvils_anvil_side.png": [45, 45, 45], "mcl_anvils_inventory.png": [157, 157, 157], "mcl_anvils_anvil_base.png": [40, 40, 40], "mcl_maps_map_filled.png": [213, 176, 148], "mcl_maps_map_empty.png": [217, 187, 157], "mcl_maps_map_filled_markings.png": [183, 183, 183], "mcl_dispensers_dispenser_front_vertical.png": [115, 104, 99], "mcl_dispensers_dispenser_front_horizontal.png": [105, 96, 92], "jeija_wall_lever.png": [95, 80, 69], "mesecons_delayer_front_locked_off.png": [97, 85, 77], "mesecons_delayer_locked_on.png": [114, 100, 95], "mesecons_delayer_sides_locked_off.png": [95, 80, 73], "mesecons_delayer_sides_on.png": [106, 71, 63], "mesecons_delayer_item.png": [100, 87, 82], "mesecons_delayer_end_locked_off.png": [97, 85, 77], "mesecons_delayer_end_locked_on.png": [101, 85, 78], "mesecons_delayer_ends_off.png": [99, 86, 80], "mesecons_delayer_front_locked_on.png": [101, 85, 77], "mesecons_delayer_ends_on.png": [105, 87, 81], "mesecons_delayer_sides_locked_on.png": [104, 81, 74], "mesecons_delayer_locked_off.png": [110, 99, 95], "mesecons_delayer_sides_off.png": [90, 69, 61], "mesecons_delayer_off.png": [112, 100, 96], "mesecons_delayer_on.png": [116, 101, 97], "redstone_redstone_dust_line0.png": [168, 168, 168], "redstone_redstone_dust.png": [81, 0, 0], "redstone_redstone_dust_dot.png": [168, 168, 168], "redstone_redstone_dust_line1.png": [173, 173, 173], "jeija_commandblock_off.png": [110, 99, 96], "jeija_commandblock_on.png": [110, 99, 96], "redstone_redstone_block.png": [128, 8, 9], "jeija_torches_on.png": [102, 68, 56], "jeija_torches_off.png": [90, 66, 54], "mesecons_button_wield_mask.png": [255, 126, 126], "mcl_droppers_dropper_front_vertical.png": [118, 108, 103], "mcl_droppers_dropper_front_horizontal.png": [110, 101, 96], "mesecons_noteblock.png": [104, 81, 63], "jeija_solar_panel_inverted.png": [100, 107, 117], "jeija_solar_panel.png": [124, 113, 101], "jeija_solar_panel_side.png": [60, 47, 36], "mcl_observers_observer_top.png": [139, 128, 123], "mcl_observers_observer_front.png": [95, 80, 84], "mcl_observers_observer_back_lit.png": [75, 67, 65], "mcl_observers_observer_back.png": [72, 67, 64], "mcl_observers_observer_side.png": [111, 103, 99], "mesecons_piston_pusher_front_sticky.png": [97, 81, 63], "mesecons_piston_pusher_top.png": [106, 83, 65], "mesecons_piston_back.png": [110, 101, 98], "mesecons_piston_on_front.png": [111, 101, 98], "mesecons_piston_pusher_back.png": [106, 83, 65], "mesecons_piston_bottom.png": [120, 107, 100], "mesecons_piston_pusher_right.png": [106, 83, 65], "mesecons_piston_pusher_bottom.png": [106, 83, 65], "mesecons_piston_pusher_front.png": [106, 83, 65], "mesecons_piston_pusher_left.png": [106, 83, 65], "jeija_lightstone_gray_on.png": [97, 56, 37], "jeija_lightstone_gray_off.png": [64, 49, 43], "mcl_comparators_sides_on.png": [105, 87, 81], "mcl_comparators_comp.png": [61, 20, 20], "mcl_comparators_on.png": [116, 102, 98], "mcl_comparators_sides_comp.png": [99, 88, 83], "mcl_comparators_off.png": [113, 102, 98], "mcl_comparators_ends_comp.png": [99, 88, 83], "mcl_comparators_ends_sub.png": [105, 88, 83], "mcl_comparators_ends_off.png": [96, 80, 74], "mcl_comparators_ends_on.png": [105, 81, 75], "mcl_comparators_sub.png": [112, 25, 25], "mcl_comparators_item.png": [98, 83, 79], "mcl_comparators_sides_off.png": [99, 86, 80], "mcl_comparators_sides_sub.png": [105, 88, 83], "default_book.png": [103, 67, 44], "default_bookshelf.png": [84, 67, 54], "mcl_books_book_written.png": [110, 74, 44], "mcl_books_book_bg.png": [203, 180, 151], "mcl_books_button9_pressed.png": [145, 112, 86], "mcl_books_button9.png": [145, 112, 86], "mcl_books_book_writable.png": [151, 122, 108], "mcl_books_bookshelf_top.png": [109, 84, 65], "wool_dark_grey.png": [96, 87, 87], "wool_grey.png": [143, 134, 134], "wool_magenta.png": [140, 85, 125], "wool_black.png": [45, 42, 42], "wool_orange.png": [188, 106, 45], "wool_blue.png": [43, 73, 125], "wool_yellow.png": [201, 163, 69], "wool_pink.png": [171, 91, 108], "wool_dark_green.png": [53, 91, 51], "wool_brown.png": [86, 57, 43], "wool_red.png": [132, 42, 45], "mcl_wool_light_blue.png": [91, 130, 180], "wool_cyan.png": [30, 94, 113], "mcl_wool_lime.png": [107, 151, 76], "wool_white.png": [212, 199, 182], "wool_violet.png": [77, 57, 102], "mcl_potions_melon_speckled.png": [170, 97, 62], "mcl_potions_effect_swift.png": [106, 96, 85], "mcl_potions_spider_eye_fermented.png": [143, 97, 62], "mcl_potions_splash_bottle.png": [168, 156, 183], "mcl_potions_effect_water_breathing.png": [59, 69, 100], "mcl_potions_effect_leaping.png": [100, 91, 86], "mcl_potions_effect_weak.png": [127, 126, 126], "mcl_potions_dragon_breath.png": [171, 137, 163], "mcl_potions_effect_food_poisoning.png": [112, 123, 89], "hudbars_icon_regenerate.png": [195, 77, 114], "mcl_potions_effect_fire_proof.png": [112, 68, 68], "mcl_potions_splash_overlay.png": [202, 202, 202], "mcl_potions_effect_invisible.png": [96, 103, 95], "hbhunger_icon_regen_poison.png": [147, 111, 115], "mcl_potions_effect_slow.png": [78, 81, 85], "mcl_potions_lingering_bottle.png": [181, 159, 192], "mcl_potions_potion_overlay.png": [201, 201, 201], "mcl_potions_effect_regenerating.png": [133, 90, 83], "mcl_potions_arrow_inv.png": [171, 165, 160], "mcl_potions_effect_night_vision.png": [86, 99, 74], "mcl_potions_potion_bottle.png": [156, 172, 203], "mcl_potions_effect_poisoned.png": [78, 110, 80], "mcl_potions_effect_strong.png": [100, 82, 97], "crafting_workbench_front.png": [120, 93, 72], "gui_crafting_arrow.png": [139, 139, 139], "crafting_workbench_side.png": [120, 93, 72], "crafting_workbench_top.png": [152, 121, 93], "mcl_enchanting_glyph_11.png": [209, 209, 231], "mcl_enchanting_glyph_14.png": [209, 209, 231], "mcl_enchanting_glyph_6.png": [209, 209, 231], "mcl_enchanting_glyph_8.png": [209, 209, 231], "mcl_enchanting_glyph_9.png": [209, 209, 231], "mcl_enchanting_glyph_3.png": [209, 209, 231], "mcl_enchanting_number_1_off.png": [255, 255, 255], "mcl_enchanting_number_3_off.png": [255, 255, 255], "mcl_enchanting_number_3.png": [151, 47, 40], "mcl_enchanting_book_open.png": [153, 123, 99], "mcl_enchanting_button_off.png": [255, 255, 255], "mcl_enchanting_glyph_2.png": [209, 209, 231], "mcl_enchanting_glyph_1.png": [209, 209, 231], "mcl_enchanting_button.png": [255, 255, 255], "mcl_enchanting_table_side.png": [66, 58, 55], "mcl_enchanting_book_closed.png": [112, 78, 55], "mcl_enchanting_table_bottom.png": [58, 51, 52], "mcl_enchanting_glyph_15.png": [209, 209, 231], "mcl_enchanting_number_2_off.png": [255, 255, 255], "mcl_enchanting_glyph_5.png": [209, 209, 231], "mcl_enchanting_number_1.png": [149, 45, 39], "mcl_enchanting_glyph_7.png": [209, 209, 231], "mcl_enchanting_table_top.png": [88, 86, 84], "mcl_enchanting_number_2.png": [149, 46, 39], "mcl_enchanting_glyph_16.png": [209, 209, 231], "mcl_enchanting_button_hovered.png": [255, 255, 255], "mcl_enchanting_book_enchanted.png": [122, 69, 46], "mcl_enchanting_glyph_4.png": [209, 209, 231], "mcl_enchanting_glyph_10.png": [209, 209, 231], "mcl_enchanting_glyph_13.png": [209, 209, 231], "mcl_enchanting_glyph_17.png": [209, 209, 231], "mcl_enchanting_glyph_18.png": [209, 209, 231], "mcl_enchanting_lapis_background.png": [255, 255, 255], "mcl_enchanting_button_background.png": [229, 202, 171], "mcl_enchanting_glyph_12.png": [209, 209, 231], "doc_basics_gameplay_mtg_2.png": [151, 168, 207], "doc_basics_liquids_renewable_1.png": [139, 146, 159], "doc_basics_players_sam.png": [95, 133, 106], "doc_basics_players_flat.png": [127, 155, 130], "doc_basics_craft_shapeless_2.png": [52, 52, 48], "doc_basics_build.png": [84, 84, 55], "doc_basics_pointing.png": [66, 104, 32], "doc_basics_nodes.png": [108, 104, 94], "doc_basics_craft_groups_2.png": [65, 58, 52], "doc_basics_craft_groups_1.png": [57, 57, 58], "doc_basics_inventory.png": [47, 47, 45], "doc_basics_minimap_radar.png": [73, 164, 128], "doc_basics_sneak.png": [70, 69, 69], "doc_basics_camera_behind.png": [108, 144, 135], "doc_basics_craft_repair.png": [47, 46, 45], "doc_basics_hotbar_relations.png": [85, 84, 69], "doc_basics_gameplay_lott.png": [119, 122, 112], "doc_basics_tools_mining.png": [64, 62, 59], "doc_basics_players_lott.png": [180, 193, 224], "doc_basics_gameplay_outback.png": [146, 114, 109], "doc_basics_gameplay_pixture.png": [94, 120, 57], "doc_basics_craft_grid.png": [46, 46, 46], "doc_basics_craft_groups_3.png": [61, 58, 55], "doc_basics_camera_front.png": [99, 133, 110], "doc_basics_minimap_map.png": [149, 169, 183], "doc_basics_gameplay_mtg_1.png": [136, 117, 86], "doc_basics_gameplay_xtraores_xtension.png": [95, 15, 86], "doc_basics_light_torch.png": [25, 43, 14], "doc_basics_minimap_round.png": [160, 175, 189], "doc_basics_light_test.png": [133, 113, 69], "doc_basics_liquids_nonrenewable.png": [64, 87, 87], "doc_basics_gameplay_hades.png": [81, 70, 62], "doc_basics_gameplay_moontest.png": [75, 74, 79], "doc_basics_liquids_range.png": [146, 166, 179], "doc_basics_inventory_detail.png": [43, 41, 39], "doc_basics_camera_ego.png": [111, 147, 139], "doc_basics_tools.png": [46, 45, 42], "doc_basics_liquids_renewable_2.png": [136, 148, 166], "doc_basics_items_dropped.png": [195, 185, 147], "doc_basics_liquids_types.png": [146, 164, 171], "doc_basics_gameplay_carbone_ng.png": [121, 118, 89], "doc_basics_craft_shaped.png": [55, 52, 50], "doc_basics_hotbar.png": [141, 175, 226], "doc_basics_craft_shapeless_1.png": [52, 52, 48], "doc_button_icon_lores.png": [19, 143, 183], "doc_awards_icon_generic.png": [14, 125, 162], "inventory_plus_doc_inventory_plus.png": [19, 143, 183], "doc_button_icon_hires.png": [30, 149, 188], "doc_identifier_identifier.png": [172, 151, 139], "doc_identifier_identifier_liquid.png": [125, 147, 190], "craftguide_clear_icon.png": [254, 254, 254], "craftguide_book.png": [84, 117, 39], "mcl_craftguide_fuel.png": [187, 121, 75], "craftguide_prev_icon.png": [255, 255, 255], "craftguide_zoomout_icon.png": [255, 255, 255], "craftguide_search_icon.png": [254, 254, 254], "craftguide_arrow.png": [139, 139, 139], "craftguide_zoomin_icon.png": [255, 255, 255], "craftguide_shapeless.png": [130, 130, 130], "craftguide_next_icon.png": [255, 255, 255]} \ No newline at end of file diff --git a/mods/ITEMS/mcl_maps/init.lua b/mods/ITEMS/mcl_maps/init.lua index 58a0a3a1..d2ff951a 100644 --- a/mods/ITEMS/mcl_maps/init.lua +++ b/mods/ITEMS/mcl_maps/init.lua @@ -1,89 +1,251 @@ -local S = minetest.get_translator("mcl_maps") +mcl_maps = {} --- Turn empty map into filled map by rightclick -local make_filled_map = function(itemstack, placer, pointed_thing) - local new_map = ItemStack("mcl_maps:filled_map") - itemstack:take_item() - if itemstack:is_empty() then - return new_map - else - local inv = placer:get_inventory() - if inv:room_for_item("main", new_map) then - inv:add_item("main", new_map) - else - minetest.add_item(placer:get_pos(), new_map) +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + +local math = math +local vector = vector +local table = table +local pairs = pairs + +local pos_to_string = minetest.pos_to_string +local string_to_pos = minetest.string_to_pos +local get_item_group = minetest.get_item_group +local dynamic_add_media = minetest.dynamic_add_media +local get_connected_players = minetest.get_connected_players + +local storage = minetest.get_mod_storage() +local worldpath = minetest.get_worldpath() +local map_textures_path = worldpath .. "/mcl_maps/" +--local last_finished_id = storage:get_int("next_id") - 1 + +minetest.mkdir(map_textures_path) + +local function load_json_file(name) + local file = assert(io.open(modpath .. "/" .. name .. ".json", "r")) + local data = minetest.parse_json(file:read()) + file:close() + return data +end + +local texture_colors = load_json_file("colors") +local palettes = load_json_file("palettes") + +local color_cache = {} + +local creating_maps = {} +local loaded_maps = {} + +local c_air = minetest.get_content_id("air") + +function mcl_maps.create_map(pos) + local minp = vector.multiply(vector.floor(vector.divide(pos, 128)), 128) + local maxp = vector.add(minp, vector.new(127, 127, 127)) + + local itemstack = ItemStack("mcl_maps:filled_map") + local meta = itemstack:get_meta() + local next_id = storage:get_int("next_id") + storage:set_int("next_id", next_id + 1) + local id = tostring(next_id) + meta:set_string("mcl_maps:id", id) + meta:set_string("mcl_maps:minp", pos_to_string(minp)) + meta:set_string("mcl_maps:maxp", pos_to_string(maxp)) + tt.reload_itemstack_description(itemstack) + + creating_maps[id] = true + minetest.emerge_area(minp, maxp, function(blockpos, action, calls_remaining) + if calls_remaining > 0 then + return + end + local vm = minetest.get_voxel_manip() + local emin, emax = vm:read_from_map(minp, maxp) + local data = vm:get_data() + local param2data = vm:get_param2_data() + local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) + local pixels = {} + local last_heightmap + for x = 1, 128 do + local map_x = minp.x - 1 + x + local heightmap = {} + for z = 1, 128 do + local map_z = minp.z - 1 + z + local color, height + for map_y = maxp.y, minp.y, -1 do + local index = area:index(map_x, map_y, map_z) + local c_id = data[index] + if c_id ~= c_air then + color = color_cache[c_id] + if color == nil then + local nodename = minetest.get_name_from_content_id(c_id) + local def = minetest.registered_nodes[nodename] + if def then + local texture + if def.palette then + texture = def.palette + elseif def.tiles then + texture = def.tiles[1] + if type(texture) == "table" then + texture = texture.name + end + end + if texture then + texture = texture:match("([^=^%^]-([^.]+))$"):split("^")[1] + end + if def.palette then + local palette = palettes[texture] + color = palette and {palette = palette} + else + color = texture_colors[texture] + end + end + end + + if color and color.palette then + color = color.palette[param2data[index] + 1] + else + color_cache[c_id] = color or false + end + + if color and last_heightmap then + local last_height = last_heightmap[z] + if last_height < map_y then + color = { + math.min(255, color[1] + 16), + math.min(255, color[2] + 16), + math.min(255, color[3] + 16), + } + elseif last_height > map_y then + color = { + math.max(0, color[1] - 16), + math.max(0, color[2] - 16), + math.max(0, color[3] - 16), + } + end + end + height = map_y + break + end + end + heightmap[z] = height or minp.y + pixels[z] = pixels[z] or {} + pixels[z][x] = color or {0, 0, 0} + end + last_heightmap = heightmap + end + tga_encoder.image(pixels):save(map_textures_path .. "mcl_maps_map_texture_" .. id .. ".tga") + creating_maps[id] = nil + end) + return itemstack +end + +function mcl_maps.load_map(id) + if id == "" or creating_maps[id] then + return + end + + local texture = "mcl_maps_map_texture_" .. id .. ".tga" + + if not loaded_maps[id] then + loaded_maps[id] = true + dynamic_add_media(map_textures_path .. texture, function() end) + end + + return texture +end + +function mcl_maps.load_map_item(itemstack) + return mcl_maps.load_map(itemstack:get_meta():get_string("mcl_maps:id")) +end + +local function fill_map(itemstack, placer, pointed_thing) + local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) + if new_stack then + return new_stack + end + + if minetest.settings:get_bool("enable_real_maps", true) then + local new_map = mcl_maps.create_map(placer:get_pos()) + itemstack:take_item() + if itemstack:is_empty() then + return new_map + else + local inv = placer:get_inventory() + if inv:room_for_item("main", new_map) then + inv:add_item("main", new_map) + else + minetest.add_item(placer:get_pos(), new_map) + end + return itemstack end - return itemstack end end minetest.register_craftitem("mcl_maps:empty_map", { description = S("Empty Map"), _doc_items_longdesc = S("Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used."), - _doc_items_usagehelp = S("Rightclick to start using the map (which can't be stacked anymore)."), + _doc_items_usagehelp = S("Rightclick to create a filled map (which can't be stacked anymore)."), inventory_image = "mcl_maps_map_empty.png", - groups = { not_in_creative_inventory = 1 }, - on_place = make_filled_map, - on_secondary_use = make_filled_map, + on_place = fill_map, + on_secondary_use = fill_map, stack_max = 64, }) -mcl_wip.register_wip_item("mcl_maps:empty_map") - -local function has_item_in_hotbar(player, item) - -- Requirement: player carries the tool in the hotbar - local inv = player:get_inventory() - local hotbar = player:hud_get_hotbar_itemcount() - for i=1, hotbar do - if inv:get_stack("main", i):get_name() == item then - return true - end - end - return false -end - --- Checks if player is still allowed to display the minimap -local function update_minimap(player) - local creative = minetest.is_creative_enabled(player:get_player_name()) - if creative then - player:hud_set_flags({minimap=true, minimap_radar = true}) - else - if has_item_in_hotbar(player, "mcl_maps:filled_map") then - player:hud_set_flags({minimap = true, minimap_radar = false}) - else - player:hud_set_flags({minimap = false, minimap_radar = false}) - end - end -end - --- Remind player how to use the minimap correctly -local function use_minimap(itemstack, player, pointed_thing) - if player and player:is_player() then - update_minimap(player) - minetest.chat_send_player(player:get_player_name(), S("Use the minimap key to show the map.")) - end -end - --- Enables minimap if carried in hotbar. --- If this item is NOT in the hotbar, the minimap is unavailable --- Note: This is not at all like Minecraft right now. Minetest's minimap is pretty overpowered, it --- has a very greatly zoomed-out version and even a radar mode -minetest.register_craftitem("mcl_maps:filled_map", { +local filled_def = { description = S("Map"), - _tt_help = S("Enables minimap"), - _doc_items_longdesc = S("Maps show your surroundings as you explore the world."), - _doc_items_usagehelp = S("Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).").."\n".. - S("In Creative Mode, you don't need this item; the minimap is always available."), - groups = { tool = 1 }, + _tt_help = S("Shows a map image."), + _doc_items_longdesc = S("When created, the map saves the nearby area as an image that can be viewed any time by holding the map."), + _doc_items_usagehelp = S("Hold the map in your hand. This will display a map on your screen."), inventory_image = "mcl_maps_map_filled.png^(mcl_maps_map_filled_markings.png^[colorize:#000000)", - stack_max = 1, + stack_max = 64, + groups = {not_in_creative_inventory = 1, filled_map = 1, tool = 1}, +} - on_use = use_minimap, - on_secondary_use = use_minimap, -}) +minetest.register_craftitem("mcl_maps:filled_map", filled_def) + +local filled_wield_def = table.copy(filled_def) +filled_wield_def.use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false +filled_wield_def.visual_scale = 1 +filled_wield_def.wield_scale = {x = 1, y = 1, z = 1} +filled_wield_def.paramtype = "light" +filled_wield_def.drawtype = "mesh" +filled_wield_def.node_placement_prediction = "" +filled_wield_def.range = minetest.registered_items[""].range +filled_wield_def.on_place = mcl_util.call_on_rightclick + +for _, texture in pairs(mcl_skins.list) do + local def = table.copy(filled_wield_def) + def.tiles = {texture .. ".png"} + def.mesh = "mcl_meshhand.b3d" + def._mcl_hand_id = texture + minetest.register_node("mcl_maps:filled_map_" .. texture, def) + + local female_def = table.copy(def) + female_def.mesh = "mcl_meshhand_female.b3d" + female_def._mcl_hand_id = texture .. "_female" + minetest.register_node("mcl_maps:filled_map_" .. texture .. "_female", female_def) +end + +local old_add_item = minetest.add_item +function minetest.add_item(pos, stack) + stack = ItemStack(stack) + if get_item_group(stack:get_name(), "filled_map") > 0 then + stack:set_name("mcl_maps:filled_map") + end + return old_add_item(pos, stack) +end + +tt.register_priority_snippet(function(itemstring, _, itemstack) + if itemstack and get_item_group(itemstring, "filled_map") > 0 then + local id = itemstack:get_meta():get_string("mcl_maps:id") + if id ~= "" then + return "#" .. id, mcl_colors.GRAY + end + end +end) minetest.register_craft({ - output = "mcl_maps:filled_map", + output = "mcl_maps:empty_map", recipe = { { "mcl_core:paper", "mcl_core:paper", "mcl_core:paper" }, { "mcl_core:paper", "group:compass", "mcl_core:paper" }, @@ -91,20 +253,104 @@ minetest.register_craft({ } }) +minetest.register_craft({ + type = "shapeless", + output = "mcl_maps:filled_map 2", + recipe = {"group:filled_map", "mcl_maps:empty_map"}, +}) + +local function on_craft(itemstack, player, old_craft_grid, craft_inv) + if itemstack:get_name() == "mcl_maps:filled_map" then + for _, stack in pairs(old_craft_grid) do + if get_item_group(stack:get_name(), "filled_map") > 0 then + itemstack:get_meta():from_table(stack:get_meta():to_table()) + return itemstack + end + end + end +end + +minetest.register_on_craft(on_craft) +minetest.register_craft_predict(on_craft) + +local maps = {} +local huds = {} + minetest.register_on_joinplayer(function(player) - update_minimap(player) + local map_def = { + hud_elem_type = "image", + text = "blank.png", + position = {x = 0.75, y = 0.8}, + alignment = {x = 0, y = -1}, + offset = {x = 0, y = 0}, + scale = {x = 2, y = 2}, + } + local marker_def = table.copy(map_def) + marker_def.alignment = {x = 0, y = 0} + huds[player] = { + map = player:hud_add(map_def), + marker = player:hud_add(marker_def), + } end) -local updatetimer = 0 -if not minetest.is_creative_enabled("") then - minetest.register_globalstep(function(dtime) - updatetimer = updatetimer + dtime - if updatetimer > 0.1 then - local players = minetest.get_connected_players() - for i=1, #players do - update_minimap(players[i]) +minetest.register_on_leaveplayer(function(player) + maps[player] = nil + huds[player] = nil +end) + +minetest.register_globalstep(function(dtime) + for _, player in pairs(get_connected_players()) do + local wield = player:get_wielded_item() + local texture = mcl_maps.load_map_item(wield) + local hud = huds[player] + if texture then + local wield_def = wield:get_definition() + local hand_def = player:get_inventory():get_stack("hand", 1):get_definition() + + if hand_def and wield_def and hand_def._mcl_hand_id ~= wield_def._mcl_hand_id then + wield:set_name("mcl_maps:filled_map_" .. hand_def._mcl_hand_id) + player:set_wielded_item(wield) end - updatetimer = updatetimer - dtime + + if texture ~= maps[player] then + player:hud_change(hud.map, "text", "[combine:140x140:0,0=mcl_maps_map_background.png:6,6=" .. texture) + maps[player] = texture + end + + local pos = vector.round(player:get_pos()) + local meta = wield:get_meta() + local minp = string_to_pos(meta:get_string("mcl_maps:minp")) + local maxp = string_to_pos(meta:get_string("mcl_maps:maxp")) + + local marker = "mcl_maps_player_arrow.png" + + if pos.x < minp.x then + marker = "mcl_maps_player_dot.png" + pos.x = minp.x + elseif pos.x > maxp.x then + marker = "mcl_maps_player_dot.png" + pos.x = maxp.x + end + + if pos.z < minp.z then + marker = "mcl_maps_player_dot.png" + pos.z = minp.z + elseif pos.z > maxp.z then + marker = "mcl_maps_player_dot.png" + pos.z = maxp.z + end + + if marker == "mcl_maps_player_arrow.png" then + local yaw = (math.floor(player:get_look_horizontal() * 180 / math.pi / 90 + 0.5) % 4) * 90 + marker = marker .. "^[transformR" .. yaw + end + + player:hud_change(hud.marker, "text", marker) + player:hud_change(hud.marker, "offset", {x = (6 - 140 / 2 + pos.x - minp.x) * 2, y = (6 - 140 + maxp.z - pos.z) * 2}) + elseif maps[player] then + player:hud_change(hud.map, "text", "blank.png") + player:hud_change(hud.marker, "text", "blank.png") + maps[player] = nil end - end) -end + end +end) diff --git a/mods/ITEMS/mcl_maps/locale/mcl_maps.de.tr b/mods/ITEMS/mcl_maps/locale/mcl_maps.de.tr index 6d1836b4..d7762e51 100644 --- a/mods/ITEMS/mcl_maps/locale/mcl_maps.de.tr +++ b/mods/ITEMS/mcl_maps/locale/mcl_maps.de.tr @@ -1,10 +1,8 @@ # textdomain: mcl_maps Empty Map=Leere Karte Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Leere Karten sind als Karten nicht nützlich, aber sie können gestapelt werden und zu benutzbaren Karten umgewandelt werden. -Rightclick to start using the map (which can't be stacked anymore).=Rechtsklick, um zu beginnen, die Karte zu benutzen. Sie kann dann nicht mehr gestapelt werden. +Rightclick to create a filled map (which can't be stacked anymore).=Rechtsklick, um die Karte zu füllen. Sie kann dann nicht mehr gestapelt werden. Map=Karte -Maps show your surroundings as you explore the world.=Karten zeigen Ihre Umgebung, während Sie die Welt erkunden. -Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=Halten Sie die Karte in einen beliebigen Platz in der Schnellleiste. Damit können Sie jetzt die Übersichtskarte aktivieren, indem Sie die Taste zum Umschalten der Karte drücken (siehe Tastenbelegung). -In Creative Mode, you don't need this item; the minimap is always available.=Im Kreativmodus brauchen Sie diesen Gegenstand nicht; die Übersichtskarte ist immer verfügbar. -Enables minimap=Aktiviert Übersichtskarte -Use the minimap key to show the map.=Taste „Karte an/aus“ benutzen, um die Karte zu betrachten. +Shows a map image.=Zeigt ein Kartenbild. +When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Beim Erstellen speichert die Karte die Gegend in der Nähe als ein Bild, dass jederzeit durch halten der Karte angesehen werden kann. +Hold the map in your hand. This will display a map on your screen.=Halten Sie die Karte in Ihrer Hand. Eine Karte wird auf Ihrem Bildschirm angezeigt werden. diff --git a/mods/ITEMS/mcl_maps/locale/mcl_maps.es.tr b/mods/ITEMS/mcl_maps/locale/mcl_maps.es.tr index 513eab13..cec96b17 100644 --- a/mods/ITEMS/mcl_maps/locale/mcl_maps.es.tr +++ b/mods/ITEMS/mcl_maps/locale/mcl_maps.es.tr @@ -3,6 +3,3 @@ Empty Map=Mapa vacio Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Los mapas vacíos no son útiles como mapas, pero se pueden apilar y convertir en mapas que se pueden usar. Rightclick to start using the map (which can't be stacked anymore).=Haga clic derecho para comenzar a usar el mapa (que ya no se puede apilar). Map=Mapa -Maps show your surroundings as you explore the world.=Los mapas muestran tu entorno mientras exploras el mundo. -Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=Mantenga el mapa en cualquiera de las ranuras de la barra de acceso directo. Esto le permite acceder al minimapa presionando la tecla del minimapa (consulte la configuración de los controles). -In Creative Mode, you don't need this item; the minimap is always available.=En el modo creativo, no necesita este elemento; El minimapa siempre está disponible. diff --git a/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr b/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr index 6feb253a..9ef7cd5c 100644 --- a/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr +++ b/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr @@ -3,8 +3,3 @@ 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). Map=Carte -Maps show your surroundings as you explore the world.=Les cartes montrent votre environnement lorsque vous explorez le monde. -Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=Tenez la carte dans l'un des emplacements de la barre de raccourci. Cela vous permet d'accéder à la mini-carte en appuyant sur la touche de la mini-carte (voir les paramètres des commandes). -In Creative Mode, you don't need this item; the minimap is always available.=En mode créatif, vous n'avez pas besoin de cet élément; la minicarte est toujours disponible. -Enables minimap=Active la minicarte -Use the minimap key to show the map.=Utilisez la touche mini-carte pour afficher la carte. diff --git a/mods/ITEMS/mcl_maps/locale/mcl_maps.ru.tr b/mods/ITEMS/mcl_maps/locale/mcl_maps.ru.tr index 70243a16..6c34007a 100644 --- a/mods/ITEMS/mcl_maps/locale/mcl_maps.ru.tr +++ b/mods/ITEMS/mcl_maps/locale/mcl_maps.ru.tr @@ -3,8 +3,3 @@ Empty Map=Пустая карта Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Пустые карты не могут использоваться в качестве карт, но могут складываться в стопки, а также могут быть превращены в полноценные карты. Rightclick to start using the map (which can't be stacked anymore).=Кликните правой, чтобы начать использовать карту (её больше нельзя будет уложить в стопку). Map=Карта -Maps show your surroundings as you explore the world.=Карты показывают ваше окружение, когда вы изучаете мир. -Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=Поместите карту в один из отсеков панели быстрого доступа. Это позволит вам вызывать миникарту нажатием клавиши [Миникарта] (см. настройки управления). -In Creative Mode, you don't need this item; the minimap is always available.=Этот предмет не нужен в творческом режиме; там миникарта всегда доступна и так. -Enables minimap=Включает миникарту -Use the minimap key to show the map.=Используйте клавишу [Миникарта] для отображения карты. diff --git a/mods/ITEMS/mcl_maps/locale/template.txt b/mods/ITEMS/mcl_maps/locale/template.txt index 061ed45e..27298d2e 100644 --- a/mods/ITEMS/mcl_maps/locale/template.txt +++ b/mods/ITEMS/mcl_maps/locale/template.txt @@ -1,10 +1,8 @@ # textdomain: mcl_maps Empty Map= Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.= -Rightclick to start using the map (which can't be stacked anymore).= +Rightclick to create a filled map (which can't be stacked anymore).= Map= -Maps show your surroundings as you explore the world.= -Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).= -In Creative Mode, you don't need this item; the minimap is always available.= -Enables minimap= -Use the minimap key to show the map.= +Shows a map image.= +When created, the map saves the nearby area as an image that can be viewed any time by holding the map.= +Hold the map in your hand. This will display a map on your screen.= diff --git a/mods/ITEMS/mcl_maps/mod.conf b/mods/ITEMS/mcl_maps/mod.conf index 5615dc2b..e1f06896 100644 --- a/mods/ITEMS/mcl_maps/mod.conf +++ b/mods/ITEMS/mcl_maps/mod.conf @@ -1,2 +1,2 @@ name = mcl_maps -depends = mcl_wip +depends = mcl_core, mcl_flowers, tga_encoder, tt, mcl_colors, mcl_skins, mcl_util diff --git a/mods/ITEMS/mcl_maps/palettes.json b/mods/ITEMS/mcl_maps/palettes.json new file mode 100644 index 00000000..958882a1 --- /dev/null +++ b/mods/ITEMS/mcl_maps/palettes.json @@ -0,0 +1 @@ +{"mcl_core_palette_grass.png": [[109, 196, 117], [159, 193, 114], [118, 177, 120], [118, 177, 120], [107, 186, 107], [118, 177, 120], [92, 182, 119], [92, 182, 119], [92, 182, 119], [92, 182, 119], [118, 177, 120], [109, 196, 117], [35, 175, 105], [94, 190, 107], [94, 190, 107], [94, 190, 107], [94, 190, 107], [159, 193, 114], [76, 176, 84], [164, 150, 110], [164, 150, 110], [164, 150, 110], [164, 150, 110], [159, 193, 114], [93, 181, 76], [93, 181, 76], [93, 181, 76], [93, 181, 76], [76, 118, 60], [94, 190, 107], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117]]} \ No newline at end of file diff --git a/mods/ITEMS/mcl_maps/textures/mcl_maps_map_background.png b/mods/ITEMS/mcl_maps/textures/mcl_maps_map_background.png new file mode 100644 index 00000000..9eeb0ea5 Binary files /dev/null and b/mods/ITEMS/mcl_maps/textures/mcl_maps_map_background.png differ diff --git a/mods/ITEMS/mcl_maps/textures/mcl_maps_player_arrow.png b/mods/ITEMS/mcl_maps/textures/mcl_maps_player_arrow.png new file mode 100644 index 00000000..3f58f676 Binary files /dev/null and b/mods/ITEMS/mcl_maps/textures/mcl_maps_player_arrow.png differ diff --git a/mods/ITEMS/mcl_maps/textures/mcl_maps_player_dot.png b/mods/ITEMS/mcl_maps/textures/mcl_maps_player_dot.png new file mode 100644 index 00000000..391197c4 Binary files /dev/null and b/mods/ITEMS/mcl_maps/textures/mcl_maps_player_dot.png differ diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index 1b792972..a7b04d3d 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_mobitems") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_craftitem("mcl_mobitems:rotten_flesh", { description = S("Rotten Flesh"), @@ -135,7 +135,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", { }) -- Reset food poisoning and status effects -local drink_milk = function(itemstack, player, pointed_thing) +local function drink_milk(itemstack, player, pointed_thing) local bucket = minetest.do_item_eat(0, "mcl_buckets:bucket_empty", itemstack, player, pointed_thing) -- Check if we were allowed to drink this (eat delay check) if mcl_hunger.active and (bucket:get_name() ~= "mcl_mobitems:milk_bucket" or minetest.is_creative_enabled(player:get_player_name())) then @@ -426,7 +426,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_mobitems:slimeball 9', + output = "mcl_mobitems:slimeball 9", recipe = {{"mcl_core:slimeblock"}}, }) diff --git a/mods/ITEMS/mcl_mobitems/locale/mcl_mobitems.de.tr b/mods/ITEMS/mcl_mobitems/locale/mcl_mobitems.de.tr index d47b811f..2fd938f2 100644 --- a/mods/ITEMS/mcl_mobitems/locale/mcl_mobitems.de.tr +++ b/mods/ITEMS/mcl_mobitems/locale/mcl_mobitems.de.tr @@ -61,7 +61,7 @@ This item is mainly used for crafting.=Dieser Gegenstand wird hauptsächlich in Magma Cream=Magmacreme Magma cream is a crafting component.=Magmacreme ist eine Fertigungskomponente. Ghast Tear=Ghast-Träne -Place this item in an item frame as decoration.=Platzieren Sie diesen Gegenstand in einem Rahmel als Deko. +Place this item in an item frame as decoration.=Platzieren Sie diesen Gegenstand in einem Rahmen als Deko. Nether Star=Nether-Stern A nether star is dropped when the Wither dies. Place it in an item frame to show the world how hardcore you are! Or just as decoration.=Ein Netherstern wird abgeworfen, wenn der Wither stirbt. Platzieren Sie ihn in einen Rahmen, um der Welt zu zeigen, wie großartig Sie sind! diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index d9539564..6c5d7f6e 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -1,11 +1,14 @@ -local S = minetest.get_translator("mcl_mobspawners") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math +local table = table mcl_mobspawners = {} local default_mob = "mobs_mc:pig" -- Mob spawner -local spawner_default = default_mob.." 0 15 4 15" +--local spawner_default = default_mob.." 0 15 4 15" local function get_mob_textures(mob) local list = minetest.registered_entities[mob].texture_list @@ -19,7 +22,7 @@ end local function find_doll(pos) for _,obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do if not obj:is_player() then - if obj ~= nil and obj:get_luaentity().name == "mcl_mobspawners:doll" then + if obj and obj:get_luaentity().name == "mcl_mobspawners:doll" then return obj end end @@ -54,6 +57,7 @@ local spawn_count_overrides = { local function set_doll_properties(doll, mob) local mobinfo = minetest.registered_entities[mob] + if not mobinfo then return end local xs, ys if doll_size_overrides[mob] then xs = doll_size_overrides[mob].x @@ -132,7 +136,7 @@ end -- Spawn mobs around pos -- NOTE: The node is timer-based, rather than ABM-based. -local spawn_mobs = function(pos, elapsed) +local function spawn_mobs(pos, elapsed) -- get meta local meta = minetest.get_meta(pos) @@ -159,7 +163,7 @@ local spawn_mobs = function(pos, elapsed) -- check objects inside 8×8 area around spawner local objs = minetest.get_objects_inside_radius(pos, 8) local count = 0 - local ent = nil + local ent local timer = minetest.get_node_timer(pos) diff --git a/mods/ITEMS/mcl_monster_eggs/init.lua b/mods/ITEMS/mcl_monster_eggs/init.lua index 55875159..59ab7287 100644 --- a/mods/ITEMS/mcl_monster_eggs/init.lua +++ b/mods/ITEMS/mcl_monster_eggs/init.lua @@ -1,16 +1,16 @@ -- Monster eggs! -- Blocks which spawn silverfish when destroyed. -local S = minetest.get_translator("mcl_monster_eggs") +local S = minetest.get_translator(minetest.get_current_modname()) -local spawn_silverfish = function(pos, oldnode, oldmetadata, digger) +local function spawn_silverfish(pos, oldnode, oldmetadata, digger) if not minetest.is_creative_enabled("") then minetest.add_entity(pos, "mobs_mc:silverfish") end end -- Template function for registering monster egg blocks -local register_block = function(subname, description, tiles, is_ground_content) +local function register_block(subname, description, tiles, is_ground_content) if is_ground_content == nil then is_ground_content = false end @@ -19,12 +19,14 @@ local register_block = function(subname, description, tiles, is_ground_content) tiles = tiles, is_ground_content = is_ground_content, groups = {dig_immediate = 3, spawns_silverfish = 1, deco_block = 1}, - drop = '', - is_ground_content = false, + drop = "", sounds = mcl_sounds.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, _tt_help = S("Hides a silverfish"), - _doc_items_longdesc = S("An infested block is a block from which a silverfish will pop out when it is broken. It looks identical to its normal counterpart."), + _doc_items_longdesc = S([[ + An infested block is a block from which a silverfish will pop out when it is broken. + It looks identical to its normal counterpart. + ]]), _mcl_hardness = 0, _mcl_blast_resistance = 0.5, }) diff --git a/mods/ITEMS/mcl_mushrooms/huge.lua b/mods/ITEMS/mcl_mushrooms/huge.lua index 12b00db8..617f1281 100644 --- a/mods/ITEMS/mcl_mushrooms/huge.lua +++ b/mods/ITEMS/mcl_mushrooms/huge.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mcl_mushrooms") +local S = minetest.get_translator(minetest.get_current_modname()) + +local vector = vector local template = { groups = {handy=1,axey=1, building_block = 1, material_wood = 1, flammable = -1 }, @@ -12,16 +14,16 @@ local template = { local red = table.copy(template) red.drop = { items = { - { items = {'mcl_mushrooms:mushroom_red 1'}, rarity = 2 }, - { items = {'mcl_mushrooms:mushroom_red 1'}, rarity = 2 }, + { items = {"mcl_mushrooms:mushroom_red"}, rarity = 2 }, + { items = {"mcl_mushrooms:mushroom_red"}, rarity = 2 }, } } local brown= table.copy(template) brown.drop = { items = { - { items = {'mcl_mushrooms:mushroom_brown 1'}, rarity = 2 }, - { items = {'mcl_mushrooms:mushroom_brown 1'}, rarity = 2 }, + { items = {"mcl_mushrooms:mushroom_brown"}, rarity = 2 }, + { items = {"mcl_mushrooms:mushroom_brown"}, rarity = 2 }, } } @@ -40,7 +42,7 @@ local function to_binary(num) return binary end -local register_mushroom = function(color, species_id, template, d_cap, d_stem, d_stem_all, longdesc_cap, longdesc_stem) +local function register_mushroom(color, species_id, template, d_cap, d_stem, d_stem_all, longdesc_cap, longdesc_stem) -- Stem texture on all sides local stem_full = table.copy(template) @@ -73,7 +75,7 @@ local register_mushroom = function(color, species_id, template, d_cap, d_stem, d block._doc_items_usagehelp = S("By placing huge mushroom blocks of the same species next to each other, the sides that touch each other will turn into pores permanently.") block.tiles = { "mcl_mushrooms_mushroom_block_skin_"..color..".png" } - block.on_construct = function(pos) + function block.on_construct(pos) local sides = { { { x= 0, y= 1, z= 0 }, 2 }, { { x= 0, y=-1, z= 0 }, 1 }, @@ -85,7 +87,7 @@ local register_mushroom = function(color, species_id, template, d_cap, d_stem, d -- Replace the side of a mushroom node. Returns the new node. -- Or nil, if unchanged. - local replace_side = function(pos, node, side) + local function replace_side(pos, node, side) local bin = string.sub(node.name, -6) if string.sub(bin, side, side) == "1" then local new_bin diff --git a/mods/ITEMS/mcl_mushrooms/small.lua b/mods/ITEMS/mcl_mushrooms/small.lua index 8105386f..c6d7edcd 100644 --- a/mods/ITEMS/mcl_mushrooms/small.lua +++ b/mods/ITEMS/mcl_mushrooms/small.lua @@ -1,10 +1,9 @@ -local S = minetest.get_translator("mcl_mushrooms") +local S = minetest.get_translator(minetest.get_current_modname()) local on_place = mcl_util.generate_on_place_plant_function(function(place_pos, place_node) local soil_node = minetest.get_node_or_nil({x=place_pos.x, y=place_pos.y-1, z=place_pos.z}) if not soil_node then return false end local snn = soil_node.name -- soil node name - local sd = minetest.registered_nodes[snn] -- soil definition -- Placement rules: -- * Always allowed on podzol or mycelimu @@ -88,7 +87,7 @@ minetest.register_craftitem("mcl_mushrooms:mushroom_stew", { minetest.register_craft({ type = "shapeless", output = "mcl_mushrooms:mushroom_stew", - recipe = {'mcl_core:bowl', 'mcl_mushrooms:mushroom_brown', 'mcl_mushrooms:mushroom_red'} + recipe = {"mcl_core:bowl", "mcl_mushrooms:mushroom_brown", "mcl_mushrooms:mushroom_red"} }) --[[ Mushroom spread and death diff --git a/mods/ITEMS/mcl_nether/init.lua b/mods/ITEMS/mcl_nether/init.lua index 46705476..c5afe66a 100644 --- a/mods/ITEMS/mcl_nether/init.lua +++ b/mods/ITEMS/mcl_nether/init.lua @@ -1,7 +1,6 @@ -local S = minetest.get_translator("mcl_nether") +local S = minetest.get_translator(minetest.get_current_modname()) -local mod_death_messages = minetest.get_modpath("mcl_death_messages") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local mod_screwdriver = minetest.get_modpath("screwdriver") local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way @@ -17,9 +16,9 @@ minetest.register_node("mcl_nether:glowstone", { drop = { max_items = 1, items = { - {items = {'mcl_nether:glowstone_dust 4'},rarity = 3}, - {items = {'mcl_nether:glowstone_dust 3'},rarity = 3}, - {items = {'mcl_nether:glowstone_dust 2'}}, + {items = {"mcl_nether:glowstone_dust 4"}, rarity = 3}, + {items = {"mcl_nether:glowstone_dust 3"}, rarity = 3}, + {items = {"mcl_nether:glowstone_dust 2"}}, } }, paramtype = "light", @@ -44,7 +43,7 @@ minetest.register_node("mcl_nether:quartz_ore", { tiles = {"mcl_nether_quartz_ore.png"}, is_ground_content = true, groups = {pickaxey=1, building_block=1, material_stone=1, xp=3}, - drop = 'mcl_nether:quartz', + drop = "mcl_nether:quartz", sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 3, _mcl_hardness = 3, @@ -54,13 +53,14 @@ minetest.register_node("mcl_nether:quartz_ore", { -- For eternal fire on top of netherrack and magma blocks -- (this code does not require a dependency on mcl_fire) -local eternal_after_destruct = function(pos, oldnode) +local function eternal_after_destruct(pos, oldnode) pos.y = pos.y + 1 if minetest.get_node(pos).name == "mcl_fire:eternal_fire" then minetest.remove_node(pos) end end -local eternal_on_ignite = function(player, pointed_thing) + +local function eternal_on_ignite(player, pointed_thing) local pos = pointed_thing.under local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} local fn = minetest.get_node(flame_pos) @@ -111,10 +111,7 @@ minetest.register_node("mcl_nether:magma", { end -- Hurt players standing on top of this block if player:get_hp() > 0 then - if mod_death_messages then - mcl_death_messages.player_damage(player, S("@1 stood too long on a magma block.", player:get_player_name())) - end - player:set_hp(player:get_hp() - 1, { type = "punch", from = "mod" }) + mcl_util.deal_damage(player, 1, {type = "hot_floor"}) end end, _mcl_blast_resistance = 0.5, @@ -269,34 +266,34 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_nether:quartz_block', + output = "mcl_nether:quartz_block", recipe = { - {'mcl_nether:quartz', 'mcl_nether:quartz'}, - {'mcl_nether:quartz', 'mcl_nether:quartz'}, + {"mcl_nether:quartz", "mcl_nether:quartz"}, + {"mcl_nether:quartz", "mcl_nether:quartz"}, } }) minetest.register_craft({ - output = 'mcl_nether:quartz_pillar 2', + output = "mcl_nether:quartz_pillar 2", recipe = { - {'mcl_nether:quartz_block'}, - {'mcl_nether:quartz_block'}, + {"mcl_nether:quartz_block"}, + {"mcl_nether:quartz_block"}, } }) minetest.register_craft({ output = "mcl_nether:glowstone", recipe = { - {'mcl_nether:glowstone_dust', 'mcl_nether:glowstone_dust'}, - {'mcl_nether:glowstone_dust', 'mcl_nether:glowstone_dust'}, + {"mcl_nether:glowstone_dust", "mcl_nether:glowstone_dust"}, + {"mcl_nether:glowstone_dust", "mcl_nether:glowstone_dust"}, } }) minetest.register_craft({ output = "mcl_nether:magma", recipe = { - {'mcl_mobitems:magma_cream', 'mcl_mobitems:magma_cream'}, - {'mcl_mobitems:magma_cream', 'mcl_mobitems:magma_cream'}, + {"mcl_mobitems:magma_cream", "mcl_mobitems:magma_cream"}, + {"mcl_mobitems:magma_cream", "mcl_mobitems:magma_cream"}, } }) @@ -310,32 +307,32 @@ minetest.register_craft({ minetest.register_craft({ output = "mcl_nether:nether_brick", recipe = { - {'mcl_nether:netherbrick', 'mcl_nether:netherbrick'}, - {'mcl_nether:netherbrick', 'mcl_nether:netherbrick'}, + {"mcl_nether:netherbrick", "mcl_nether:netherbrick"}, + {"mcl_nether:netherbrick", "mcl_nether:netherbrick"}, } }) minetest.register_craft({ output = "mcl_nether:red_nether_brick", recipe = { - {'mcl_nether:nether_wart_item', 'mcl_nether:netherbrick'}, - {'mcl_nether:netherbrick', 'mcl_nether:nether_wart_item'}, + {"mcl_nether:nether_wart_item", "mcl_nether:netherbrick"}, + {"mcl_nether:netherbrick", "mcl_nether:nether_wart_item"}, } }) minetest.register_craft({ output = "mcl_nether:red_nether_brick", recipe = { - {'mcl_nether:netherbrick', 'mcl_nether:nether_wart_item'}, - {'mcl_nether:nether_wart_item', 'mcl_nether:netherbrick'}, + {"mcl_nether:netherbrick", "mcl_nether:nether_wart_item"}, + {"mcl_nether:nether_wart_item", "mcl_nether:netherbrick"}, } }) minetest.register_craft({ output = "mcl_nether:nether_wart_block", recipe = { - {'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item'}, - {'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item'}, - {'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item'}, + {"mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item"}, + {"mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item"}, + {"mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item"}, } }) diff --git a/mods/ITEMS/mcl_nether/lava.lua b/mods/ITEMS/mcl_nether/lava.lua index da85b8e3..035a5032 100644 --- a/mods/ITEMS/mcl_nether/lava.lua +++ b/mods/ITEMS/mcl_nether/lava.lua @@ -1,12 +1,6 @@ -- Lava in the Nether -local S = minetest.get_translator("mcl_nether") -local N = function(s) return s end - -local msg = { - N("@1 has become one with the lava."), - N("@1 has been consumed by the lava."), -} +local S = minetest.get_translator(minetest.get_current_modname()) -- TODO: Increase flow speed. This could be done by reducing viscosity, -- but this would also allow players to swim faster in lava. @@ -20,7 +14,6 @@ lava_src_def._doc_items_usagehelp = nil lava_src_def.liquid_range = 7 lava_src_def.liquid_alternative_source = "mcl_nether:nether_lava_source" lava_src_def.liquid_alternative_flowing = "mcl_nether:nether_lava_flowing" -lava_src_def._mcl_node_death_message = msg, minetest.register_node("mcl_nether:nether_lava_source", lava_src_def) local lava_flow_def = table.copy(minetest.registered_nodes["mcl_core:lava_flowing"]) @@ -29,7 +22,6 @@ lava_flow_def._doc_items_create_entry = false lava_flow_def.liquid_range = 7 lava_flow_def.liquid_alternative_flowing = "mcl_nether:nether_lava_flowing" lava_flow_def.liquid_alternative_source = "mcl_nether:nether_lava_source" -lava_flow_def._mcl_node_death_message = msg, minetest.register_node("mcl_nether:nether_lava_flowing", lava_flow_def) -- Add entry aliases for the Help diff --git a/mods/ITEMS/mcl_nether/locale/mcl_nether.de.tr b/mods/ITEMS/mcl_nether/locale/mcl_nether.de.tr index bfa62488..f81f381e 100644 --- a/mods/ITEMS/mcl_nether/locale/mcl_nether.de.tr +++ b/mods/ITEMS/mcl_nether/locale/mcl_nether.de.tr @@ -38,5 +38,3 @@ Place this item on soul sand to plant it and watch it grow.=Platzieren Sie den G Burns your feet=Verbrennt Ihre Füße Grows on soul sand=Wächst auf Seelensand Reduces walking speed=Reduziert das Schritttempo -@1 has become one with the lava.=@1 wurde eins mit der Lava. -@1 has been consumed by the lava.=@1 wurde von der Lava verzehrt. diff --git a/mods/ITEMS/mcl_nether/locale/mcl_nether.fr.tr b/mods/ITEMS/mcl_nether/locale/mcl_nether.fr.tr index 11a04637..3e358335 100644 --- a/mods/ITEMS/mcl_nether/locale/mcl_nether.fr.tr +++ b/mods/ITEMS/mcl_nether/locale/mcl_nether.fr.tr @@ -37,6 +37,4 @@ Nether warts are plants home to the Nether. They can be planted on soul sand and Place this item on soul sand to plant it and watch it grow.=Placez cet article sur du sable d'âme pour le planter et regardez-le grandir. Burns your feet=Vous brûle les pieds Grows on soul sand=Pousse sur le sable de l'âme -Reduces walking speed=Réduit la vitesse de marche -@1 has become one with the lava.=@1 est devenu un avec la lave. -@1 has been consumed by the lava.=@1 a été consumé par la lave. \ No newline at end of file +Reduces walking speed=Réduit la vitesse de marche \ No newline at end of file diff --git a/mods/ITEMS/mcl_nether/locale/mcl_nether.ru.tr b/mods/ITEMS/mcl_nether/locale/mcl_nether.ru.tr index 2cfdd370..f546d16c 100644 --- a/mods/ITEMS/mcl_nether/locale/mcl_nether.ru.tr +++ b/mods/ITEMS/mcl_nether/locale/mcl_nether.ru.tr @@ -38,5 +38,3 @@ Place this item on soul sand to plant it and watch it grow.=Поместите Burns your feet=Обжигает ваши ноги Grows on soul sand=Растёт на песке душ Reduces walking speed=Уменьшает скорость ходьбы -@1 has become one with the lava.=@1 породнился(лась) с лавой. -@1 has been consumed by the lava.=@1 был(а) поглощен(а) лавой. diff --git a/mods/ITEMS/mcl_nether/locale/template.txt b/mods/ITEMS/mcl_nether/locale/template.txt index 7b505216..0e69ad52 100644 --- a/mods/ITEMS/mcl_nether/locale/template.txt +++ b/mods/ITEMS/mcl_nether/locale/template.txt @@ -37,6 +37,4 @@ Nether warts are plants home to the Nether. They can be planted on soul sand and Place this item on soul sand to plant it and watch it grow.= Burns your feet= Grows on soul sand= -Reduces walking speed= -@1 has become one with the lava.= -@1 has been consumed by the lava.= +Reduces walking speed= \ No newline at end of file diff --git a/mods/ITEMS/mcl_nether/mod.conf b/mods/ITEMS/mcl_nether/mod.conf index 8bef6c6c..f5ffa61a 100644 --- a/mods/ITEMS/mcl_nether/mod.conf +++ b/mods/ITEMS/mcl_nether/mod.conf @@ -1,3 +1,3 @@ name = mcl_nether depends = mcl_core, mcl_sounds, mcl_util, walkover, doc_items, mcl_colors -optional_depends = mcl_death_messages, doc, screwdriver +optional_depends = doc, screwdriver diff --git a/mods/ITEMS/mcl_nether/nether_wart.lua b/mods/ITEMS/mcl_nether/nether_wart.lua index 681abe09..41b23f66 100644 --- a/mods/ITEMS/mcl_nether/nether_wart.lua +++ b/mods/ITEMS/mcl_nether/nether_wart.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mcl_nether") +local S = minetest.get_translator(minetest.get_current_modname()) + +local table = table minetest.register_node("mcl_nether:nether_wart_0", { description = S("Premature Nether Wart (Stage 1)"), @@ -127,7 +129,7 @@ minetest.register_craftitem("mcl_nether:nether_wart_item", { -- Check for correct soil type local chk = minetest.get_item_group(minetest.get_node(soilpos).name, "soil_nether_wart") - if chk ~= 0 and chk ~= nil then + if chk and chk ~= 0 then -- Check if node above soil node allows placement if minetest.registered_items[minetest.get_node(placepos).name].buildable_to then -- Place nether wart diff --git a/mods/ITEMS/mcl_ocean/corals.lua b/mods/ITEMS/mcl_ocean/corals.lua index f3de5968..338929a1 100644 --- a/mods/ITEMS/mcl_ocean/corals.lua +++ b/mods/ITEMS/mcl_ocean/corals.lua @@ -1,5 +1,5 @@ -local S = minetest.get_translator("mcl_ocean") -local mod_doc = minetest.get_modpath("doc") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) +local mod_doc = minetest.get_modpath("doc") local corals = { { "tube", S("Tube Coral Block"), S("Dead Tube Coral Block"), S("Tube Coral"), S("Dead Tube Coral"), S("Tube Coral Fan"), S("Dead Tube Coral Fan") }, @@ -265,7 +265,6 @@ minetest.register_abm({ if minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "mcl_core:water_source" then -- Find dead form (it's the same as the node's drop) local def = minetest.registered_nodes[node.name] - local dead if def then node.name = def.drop else diff --git a/mods/ITEMS/mcl_ocean/kelp.lua b/mods/ITEMS/mcl_ocean/kelp.lua index 9670943d..422f475a 100644 --- a/mods/ITEMS/mcl_ocean/kelp.lua +++ b/mods/ITEMS/mcl_ocean/kelp.lua @@ -7,8 +7,8 @@ -- TODO: In MC, you can't actually destroy kelp by bucket'ing water in the middle. -- However, because of the plantlike_rooted hack, we'll just allow it for now. -local S = minetest.get_translator("mcl_ocean") -local mod_doc = minetest.get_modpath("doc") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) +local mod_doc = minetest.get_modpath("doc") -------------------------------------------------------------------------------- -- local-ify runtime functions @@ -37,14 +37,9 @@ local mt_record_protection_violation = minetest.record_protection_violation local mt_is_creative_enabled = minetest.is_creative_enabled local mt_sound_play = minetest.sound_play -local math_min = math.min -local math_max = math.max -local math_ceil = math.ceil -local math_floor = math.floor -local math_random = math.random -local string_format = string.format -local table_copy = table.copy -local table_insert = table.insert +local math = math +--local string = string +local table = table -- DEBUG: functions -- local log = minetest.log @@ -122,7 +117,7 @@ function kelp.is_downward_flowing(pos, node, pos_above, node_above, __is_above__ -- Function params: (pos[, node]) or (node, pos_above) or (node, node_above) local node = node or mt_get_node(pos) - local result = (math_floor(node.param2 / 8) % 2) == 1 + local result = (math.floor(node.param2 / 8) % 2) == 1 if not (result or __is_above__) then -- If not, also check node above. -- (this is needed due a weird quirk in the definition of "downwards flowing" @@ -182,14 +177,14 @@ end -- Roll whether to grow kelp or not. function kelp.roll_growth(numerator, denominator) -- Optional params: numerator, denominator - return math_random(denominator or kelp.ROLL_GROWTH_DENOMINATOR) <= (numerator or kelp.ROLL_GROWTH_NUMERATOR) + return math.random(denominator or kelp.ROLL_GROWTH_DENOMINATOR) <= (numerator or kelp.ROLL_GROWTH_NUMERATOR) end -- Roll initial age for kelp. function kelp.roll_init_age(min, max) -- Optional params - return math_random(min or kelp.MIN_AGE, (max or kelp.MAX_AGE)-1) + return math.random(min or kelp.MIN_AGE, (max or kelp.MAX_AGE)-1) end @@ -197,7 +192,7 @@ end -- For the special case where the max param2 is reached, interpret that as the -- 16th kelp stem. function kelp.get_height(param2) - return math_floor(param2 / 16) + math_floor(param2 % 16 / 8) + return math.floor(param2 / 16) + math.floor(param2 % 16 / 8) end @@ -232,7 +227,7 @@ end -- Obtain next param2. function kelp.next_param2(param2) -- param2 max value is 255, so adding to 256 causes overflow. - return math_min(param2+16 - param2 % 16, 255); + return math.min(param2+16 - param2 % 16, 255); end @@ -242,8 +237,8 @@ function kelp.store_meta() for _ in pairs(kelp.age_queue_pos) do count = count + 1 end - -- chatlog(string_format("Storing age metadata: %d in queue", #kelp.age_queue)) - -- chatlog(string_format("Storing age metadata: %d valid in queue", count)) + -- chatlog(string.format("Storing age metadata: %d in queue", #kelp.age_queue)) + -- chatlog(string.format("Storing age metadata: %d valid in queue", count)) for i=1,#kelp.age_queue do local pos_hash = kelp.age_queue[i] local pos = kelp.age_queue_pos[pos_hash] @@ -265,7 +260,7 @@ function kelp.store_age(age, pos, pos_hash) kelp.age_pool[pos_hash] = age if not kelp.age_queue_pos[pos_hash] then - table_insert(kelp.age_queue, pos_hash) + table.insert(kelp.age_queue, pos_hash) kelp.age_queue_pos[pos_hash] = pos return true, pos_hash end @@ -427,7 +422,7 @@ end function kelp.surface_after_dig_node(pos, node) - return mt_set_node(pos, {name=registred_nodes[node.name].node_dig_prediction}) + return mt_set_node(pos, {name=minetest.registered_nodes[node.name].node_dig_prediction}) end @@ -713,7 +708,7 @@ function kelp.register_kelp_surface(surface, surface_deftemplate, surface_docs) doc.add_entry_alias("nodes", surface_docs.entry_id_orig, "nodes", surfacename) end - local sounds = table_copy(def.sounds) + local sounds = table.copy(def.sounds) sounds.dig = kelp.leaf_sounds.dig sounds.dug = kelp.leaf_sounds.dug sounds.place = kelp.leaf_sounds.place @@ -732,9 +727,9 @@ end -- Kelp surfaces nodes --------------------------------------------------------- -- Dirt must be registered first, for the docs -kelp.register_kelp_surface(kelp.surfaces[1], table_copy(kelp.surface_deftemplate), kelp.surface_docs) +kelp.register_kelp_surface(kelp.surfaces[1], table.copy(kelp.surface_deftemplate), kelp.surface_docs) for i=2, #kelp.surfaces do - kelp.register_kelp_surface(kelp.surfaces[i], table_copy(kelp.surface_deftemplate), kelp.surface_docs) + kelp.register_kelp_surface(kelp.surfaces[i], table.copy(kelp.surface_deftemplate), kelp.surface_docs) end -- Kelp item ------------------------------------------------------------------- @@ -764,12 +759,11 @@ minetest.register_craftitem("mcl_ocean:dried_kelp", { groups = { food = 2, eatable = 1 }, on_place = minetest.item_eat(1), on_secondary_use = minetest.item_eat(1), - groups = { food = 2, eatable = 1 }, _mcl_saturation = 0.6, }) -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local mod_screwdriver = minetest.get_modpath("screwdriver") local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way diff --git a/mods/ITEMS/mcl_ocean/prismarine.lua b/mods/ITEMS/mcl_ocean/prismarine.lua index 647e87fe..e38b3e0a 100644 --- a/mods/ITEMS/mcl_ocean/prismarine.lua +++ b/mods/ITEMS/mcl_ocean/prismarine.lua @@ -1,6 +1,6 @@ -- Nodes -local S = minetest.get_translator("mcl_ocean") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_node("mcl_ocean:sea_lantern", { description = S("Sea Lantern"), @@ -12,8 +12,8 @@ minetest.register_node("mcl_ocean:sea_lantern", { drop = { max_items = 1, items = { - { items = {'mcl_ocean:prismarine_crystals 3'}, rarity = 2 }, - { items = {'mcl_ocean:prismarine_crystals 2'}} + { items = {"mcl_ocean:prismarine_crystals 3"}, rarity = 2 }, + { items = {"mcl_ocean:prismarine_crystals 2"}} } }, tiles = {{name="mcl_ocean_sea_lantern.png", animation={type="vertical_frames", aspect_w=32, aspect_h=32, length=1.25}}}, @@ -89,37 +89,37 @@ minetest.register_craftitem("mcl_ocean:prismarine_shard", { -- Crafting minetest.register_craft({ - output = 'mcl_ocean:sea_lantern', + output = "mcl_ocean:sea_lantern", recipe = { - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_crystals'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_shard'}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_crystals", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_crystals", "mcl_ocean:prismarine_crystals", "mcl_ocean:prismarine_crystals"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_crystals", "mcl_ocean:prismarine_shard"}, } }) minetest.register_craft({ - output = 'mcl_ocean:prismarine', + output = "mcl_ocean:prismarine", recipe = { - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, } }) minetest.register_craft({ - output = 'mcl_ocean:prismarine_brick', + output = "mcl_ocean:prismarine_brick", recipe = { - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, } }) minetest.register_craft({ - output = 'mcl_ocean:prismarine_dark', + output = "mcl_ocean:prismarine_dark", recipe = { - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_dye:black', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_dye:black", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, } }) diff --git a/mods/ITEMS/mcl_ocean/sea_pickle.lua b/mods/ITEMS/mcl_ocean/sea_pickle.lua index 45b934a9..d215fd3b 100644 --- a/mods/ITEMS/mcl_ocean/sea_pickle.lua +++ b/mods/ITEMS/mcl_ocean/sea_pickle.lua @@ -1,5 +1,6 @@ -local S = minetest.get_translator("mcl_ocean") -local mod_doc = minetest.get_modpath("doc") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_doc = minetest.get_modpath("doc") local function sea_pickle_on_place(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" or not placer then @@ -12,7 +13,7 @@ local function sea_pickle_on_place(itemstack, placer, pointed_thing) local node_under = minetest.get_node(pos_under) local node_above = minetest.get_node(pos_above) local def_under = minetest.registered_nodes[node_under.name] - local def_above = minetest.registered_nodes[node_above.name] + --local def_above = minetest.registered_nodes[node_above.name] if def_under and def_under.on_rightclick and not placer:get_player_control().sneak then return def_under.on_rightclick(pos_under, node_under, diff --git a/mods/ITEMS/mcl_ocean/seagrass.lua b/mods/ITEMS/mcl_ocean/seagrass.lua index 49220513..5fd38277 100644 --- a/mods/ITEMS/mcl_ocean/seagrass.lua +++ b/mods/ITEMS/mcl_ocean/seagrass.lua @@ -1,5 +1,6 @@ -local S = minetest.get_translator("mcl_ocean") -local mod_doc = minetest.get_modpath("doc") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_doc = minetest.get_modpath("doc") -- List of supported surfaces for seagrass local surfaces = { @@ -105,7 +106,7 @@ for s=1, #surfaces do doc_longdesc = S("Seagrass grows inside water on top of dirt, sand or gravel.") desc = S("Seagrass") doc_create = true - doc_img = "mcl_ocean_seagrass.png" + doc_img = "mcl_ocean_seagrass.png^[verticalframe:12:0" else doc_create = false end @@ -113,7 +114,7 @@ for s=1, #surfaces do _doc_items_entry_name = desc, _doc_items_longdesc = doc_longdesc, _doc_items_create_entry = doc_create, - _doc_items_image = "mcl_ocean_seagrass.png^[verticalframe:12:0", + _doc_items_image = doc_img, drawtype = "plantlike_rooted", paramtype = "light", paramtype2 = "meshoptions", diff --git a/mods/ITEMS/mcl_portals/init.lua b/mods/ITEMS/mcl_portals/init.lua index 080051ff..972e9347 100644 --- a/mods/ITEMS/mcl_portals/init.lua +++ b/mods/ITEMS/mcl_portals/init.lua @@ -4,13 +4,15 @@ mcl_portals = { storage = minetest.get_mod_storage(), } +local modpath = minetest.get_modpath(minetest.get_current_modname()) + -- Nether portal: -- Obsidian frame, activated by flint and steel -dofile(minetest.get_modpath("mcl_portals").."/portal_nether.lua") +dofile(modpath.."/portal_nether.lua") -- End portal (W.I.P): -- Red nether brick block frame, activated by an eye of ender -dofile(minetest.get_modpath("mcl_portals").."/portal_end.lua") +dofile(modpath.."/portal_end.lua") -dofile(minetest.get_modpath("mcl_portals").."/portal_gateway.lua") +dofile(modpath.."/portal_gateway.lua") diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index 192f5001..085205cf 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -1,12 +1,16 @@ -local S = minetest.get_translator("mcl_portals") +local S = minetest.get_translator(minetest.get_current_modname()) + +local table = table +local vector = vector +local math = math -- Parameters -local SPAWN_MIN = mcl_vars.mg_end_min+70 -local SPAWN_MAX = mcl_vars.mg_end_min+98 +--local SPAWN_MIN = mcl_vars.mg_end_min+70 +--local SPAWN_MAX = mcl_vars.mg_end_min+98 -local mg_name = minetest.get_mapgen_setting("mg_name") +--local mg_name = minetest.get_mapgen_setting("mg_name") -local destroy_portal = function(pos) +local function destroy_portal(pos) local neighbors = { { x=1, y=0, z=0 }, { x=-1, y=0, z=0 }, @@ -196,7 +200,6 @@ function mcl_portals.end_teleport(obj, pos) end end - local platform build_end_portal_destination(platform_pos) check_and_build_end_portal_destination(platform_pos) diff --git a/mods/ITEMS/mcl_portals/portal_gateway.lua b/mods/ITEMS/mcl_portals/portal_gateway.lua index c738da1a..ca15a61d 100644 --- a/mods/ITEMS/mcl_portals/portal_gateway.lua +++ b/mods/ITEMS/mcl_portals/portal_gateway.lua @@ -1,6 +1,8 @@ -local S = minetest.get_translator("mcl_portals") +local S = minetest.get_translator(minetest.get_current_modname()) local storage = mcl_portals.storage +local vector = vector + local gateway_positions = { {x = 96, y = -26925, z = 0}, {x = 91, y = -26925, z = 29}, @@ -24,9 +26,10 @@ local gateway_positions = { {x = 91, y = -26925, z = -29}, } +local path_gateway_portal = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts" + local function spawn_gateway_portal(pos, dest_str) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts" - return mcl_structures.place_schematic(vector.add(pos, vector.new(-1, -2, -1)), path, "0", nil, true, nil, dest_str and function() + return mcl_structures.place_schematic(vector.add(pos, vector.new(-1, -2, -1)), path_gateway_portal, "0", nil, true, nil, dest_str and function() minetest.get_meta(pos):set_string("mcl_portals:gateway_destination", dest_str) end) end diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 1d9fe2ef..3f15a134 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_portals") +local S = minetest.get_translator(minetest.get_current_modname()) local SCAN_2_MAP_CHUNKS = true -- slower but helps to find more suitable places @@ -27,9 +27,8 @@ local DELAY = 3 -- seconds before teleporting in Nether portal in Survival mo local DISTANCE_MAX = 128 local PORTAL = "mcl_portals:portal" local OBSIDIAN = "mcl_core:obsidian" -local O_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max_official, 2048) -local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_max - H_MIN -local O_DY, N_DY = O_Y_MAX - O_Y_MIN + 1, N_Y_MAX - N_Y_MIN + 1 +local O_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max, 2048) +local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_min - H_MIN -- Alpha and particles local node_particles_allowed = minetest.settings:get("mcl_node_particles") or "none" @@ -78,6 +77,8 @@ local pos_to_string = minetest.pos_to_string local is_area_protected = minetest.is_area_protected local get_us_time = minetest.get_us_time +local dimension_to_teleport = { nether = "overworld", overworld = "nether" } + local limits = { nether = { pmin = {x=LIM_MIN, y = N_Y_MIN, z = LIM_MIN}, @@ -136,8 +137,20 @@ local function find_exit(p, dx, dy, dz) if not p or not p.y or not p.z or not p.x then return end local dx, dy, dz = dx or DISTANCE_MAX, dy or DISTANCE_MAX, dz or DISTANCE_MAX if dx < 1 or dy < 1 or dz < 1 then return false end - local x, y, z = floor(p.x), floor(p.y), floor(p.z) - local x1, y1, z1, x2, y2, z2 = x-dx+1, y-dy+1, z-dz+1, x+dx-1, y+dy-1, z+dz-1 + + --y values aren't used + local x = floor(p.x) + --local y = floor(p.y) + local z = floor(p.z) + + local x1 = x-dx+1 + --local y1 = y-dy+1 + local z1 = z-dz+1 + + local x2 = x+dx-1 + --local y2 = y+dy-1 + local z2 = z+dz-1 + local k1x, k2x = floor(x1/256), floor(x2/256) local k1z, k2z = floor(z1/256), floor(z2/256) @@ -181,10 +194,10 @@ local function get_target(p) x, o1 = ping_pong(x, TRAVEL_X, LIM_MIN, LIM_MAX) z, o2 = ping_pong(z, TRAVEL_Z, LIM_MIN, LIM_MAX) y = floor(y * TRAVEL_Y + (o1+o2) / 16 * LIM_MAX) - y = min(max(y + mcl_vars.mg_overworld_min, mcl_vars.mg_overworld_min), mcl_vars.mg_overworld_max) + y = min(max(y + O_Y_MIN, O_Y_MIN), O_Y_MAX) elseif d=="overworld" then x, y, z = floor(x / TRAVEL_X + 0.5), floor(y / TRAVEL_Y + 0.5), floor(z / TRAVEL_Z + 0.5) - y = min(max(y + mcl_vars.mg_nether_min, mcl_vars.mg_nether_min), mcl_vars.mg_nether_max) + y = min(max(y + N_Y_MIN, N_Y_MIN), N_Y_MAX) end return {x=x, y=y, z=z}, d end @@ -197,7 +210,7 @@ local function destroy_nether_portal(pos, node) local nn, orientation = node.name, node.param2 local obsidian = nn == OBSIDIAN - local check_remove = function(pos, orientation) + local function check_remove(pos, orientation) local node = get_node(pos) if node and (node.name == PORTAL and (orientation == nil or (node.param2 == orientation))) then minetest.remove_node(pos) @@ -370,7 +383,7 @@ local function finalize_teleport(obj, exit) if is_player then name = obj:get_player_name() end - local y, dim = mcl_worlds.y_to_layer(exit.y) + local _, dim = mcl_worlds.y_to_layer(exit.y) -- If player stands, player is at ca. something+0.5 which might cause precision problems, so we used ceil for objpos.y @@ -457,8 +470,8 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param) local nodes = find_nodes_in_area_under_air(pos1, pos2, {"group:building_block"}) if nodes then local nc = #nodes + log("action", "[mcl_portals] Area for destination Nether portal emerged! Found " .. tostring(nc) .. " nodes under the air around "..pos_to_string(pos)) if nc > 0 then - log("action", "[mcl_portals] Area for destination Nether portal emerged! Found " .. tostring(nc) .. " nodes under the air around "..pos_to_string(pos)) for i=1,nc do local node = nodes[i] local node1 = {x=node.x, y=node.y+1, z=node.z } @@ -474,7 +487,7 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param) return end if not distance or (distance0 < distance) or (distance0 < distance-1 and node.y > lava and pos0.y < lava) then - log("action", "[mcl_portals] found distance "..tostring(distance0).." at pos "..pos_to_string(node)) + log("verbose", "[mcl_portals] found distance "..tostring(distance0).." at pos "..pos_to_string(node)) distance = distance0 pos0 = {x=node1.x, y=node1.y, z=node1.z} end @@ -626,7 +639,7 @@ end -- Pos can be any of the inner part. -- The frame MUST be filled only with air or any fire, which will be replaced with Nether portal blocks. -- If no Nether portal can be lit, nothing happens. --- Returns number of portals created (0, 1 or 2) +-- Returns true if portal created function mcl_portals.light_nether_portal(pos) -- Only allow to make portals in Overworld and Nether local dim = mcl_worlds.pos_to_dimension(pos) @@ -636,11 +649,6 @@ function mcl_portals.light_nether_portal(pos) local orientation = random(0, 1) for orientation_iteration = 1, 2 do if check_and_light_shape(pos, orientation) then - minetest.after(0.2, function(pos) -- generate target map chunk - local pos1 = add(mul(mcl_vars.pos_to_chunk(pos), mcl_vars.chunk_size_in_nodes), mcl_vars.central_chunk_offset_in_nodes) - local pos2 = add(pos1, mcl_vars.chunk_size_in_nodes - 1) - minetest.emerge_area(pos1, pos2) - end, vector.new(pos)) return true end orientation = 1 - orientation @@ -672,6 +680,7 @@ local function teleport_no_delay(obj, pos) if exit then finalize_teleport(obj, exit) else + dim = dimension_to_teleport[dim] -- need to create arrival portal create_portal(target, limits[dim].pmin, limits[dim].pmax, name, obj) end diff --git a/mods/ITEMS/mcl_potions/commands.lua b/mods/ITEMS/mcl_potions/commands.lua index ad1d65b7..1fbf591d 100644 --- a/mods/ITEMS/mcl_potions/commands.lua +++ b/mods/ITEMS/mcl_potions/commands.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_potions") +local S = minetest.get_translator(minetest.get_current_modname()) -- ░█████╗░██╗░░██╗░█████╗░████████╗  ░█████╗░░█████╗░███╗░░░███╗███╗░░░███╗░█████╗░███╗░░██╗██████╗░░██████╗ -- ██╔══██╗██║░░██║██╔══██╗╚══██╔══╝  ██╔══██╗██╔══██╗████╗░████║████╗░████║██╔══██╗████╗░██║██╔══██╗██╔════╝ diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 996637aa..09b95115 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -107,7 +107,7 @@ minetest.register_globalstep(function(dtime) EF.invisible[player].timer = EF.invisible[player].timer + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#B0B0B0") end + if player:get_pos() then mcl_potions._add_spawner(player, "#7F8392") end if EF.invisible[player].timer >= EF.invisible[player].dur then mcl_potions.make_invisible(player, false) @@ -129,20 +129,13 @@ minetest.register_globalstep(function(dtime) EF.poisoned[player].timer = EF.poisoned[player].timer + dtime EF.poisoned[player].hit_timer = (EF.poisoned[player].hit_timer or 0) + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#225533") end + if player:get_pos() then mcl_potions._add_spawner(player, "#4E9331") end if EF.poisoned[player].hit_timer >= EF.poisoned[player].step then - - if entity and entity._cmi_is_mob then - entity.health = math.max(entity.health - 1, 1) - EF.poisoned[player].hit_timer = 0 - elseif is_player then - player:set_hp( math.max(player:get_hp() - 1, 1), { type = "punch", other = "poison"}) - EF.poisoned[player].hit_timer = 0 - else -- if not player or mob then remove - EF.poisoned[player] = nil + if mcl_util.get_hp(player) - 1 > 0 then + mcl_util.deal_damage(player, 1, {type = "magic"}) end - + EF.poisoned[player].hit_timer = 0 end if EF.poisoned[player] and EF.poisoned[player].timer >= EF.poisoned[player].dur then @@ -165,7 +158,7 @@ minetest.register_globalstep(function(dtime) EF.regenerating[player].timer = EF.regenerating[player].timer + dtime EF.regenerating[player].heal_timer = (EF.regenerating[player].heal_timer or 0) + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#A52BB2") end + if player:get_pos() then mcl_potions._add_spawner(player, "#CD5CAB") end if EF.regenerating[player].heal_timer >= EF.regenerating[player].step then @@ -199,7 +192,7 @@ minetest.register_globalstep(function(dtime) EF.water_breathing[player].timer = EF.water_breathing[player].timer + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#0000AA") end + if player:get_pos() then mcl_potions._add_spawner(player, "#2E5299") end if player:get_breath() then if player:get_breath() < 10 then player:set_breath(10) end @@ -224,7 +217,7 @@ minetest.register_globalstep(function(dtime) EF.leaping[player].timer = EF.leaping[player].timer + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#00CC33") end + if player:get_pos() then mcl_potions._add_spawner(player, "#22FF4C") end if EF.leaping[player].timer >= EF.leaping[player].dur then playerphysics.remove_physics_factor(player, "jump", "mcl_potions:leaping") @@ -246,7 +239,7 @@ minetest.register_globalstep(function(dtime) EF.swift[player].timer = EF.swift[player].timer + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#009999") end + if player:get_pos() then mcl_potions._add_spawner(player, "#7CAFC6") end if EF.swift[player].timer >= EF.swift[player].dur then playerphysics.remove_physics_factor(player, "speed", "mcl_potions:swiftness") @@ -268,7 +261,7 @@ minetest.register_globalstep(function(dtime) EF.night_vision[player].timer = EF.night_vision[player].timer + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#1010AA") end + if player:get_pos() then mcl_potions._add_spawner(player, "#1F1FA1") end if EF.night_vision[player].timer >= EF.night_vision[player].dur then EF.night_vision[player] = nil @@ -293,7 +286,7 @@ minetest.register_globalstep(function(dtime) EF.fire_proof[player].timer = EF.fire_proof[player].timer + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#E0B050") end + if player:get_pos() then mcl_potions._add_spawner(player, "#E49A3A") end if EF.fire_proof[player].timer >= EF.fire_proof[player].dur then EF.fire_proof[player] = nil @@ -314,7 +307,7 @@ minetest.register_globalstep(function(dtime) EF.weak[player].timer = EF.weak[player].timer + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#7700BB") end + if player:get_pos() then mcl_potions._add_spawner(player, "#484D48") end if EF.weak[player].timer >= EF.weak[player].dur then EF.weak[player] = nil @@ -335,7 +328,7 @@ minetest.register_globalstep(function(dtime) EF.strong[player].timer = EF.strong[player].timer + dtime - if player:get_pos() then mcl_potions._add_spawner(player, "#7700BB") end + if player:get_pos() then mcl_potions._add_spawner(player, "#932423") end if EF.strong[player].timer >= EF.strong[player].dur then EF.strong[player] = nil @@ -351,37 +344,12 @@ minetest.register_globalstep(function(dtime) end) - -local is_fire_node = { ["mcl_core:lava_flowing"]=true, - ["mcl_core:lava_source"]=true, - ["mcl_fire:eternal_fire"]=true, - ["mcl_fire:fire"]=true, - ["mcl_nether:magma"]=true, - ["mcl_nether:nether_lava_source"]=true, - ["mcl_nether:nether_lava_flowing"]=true, - ["mcl_nether:nether_lava_source"]=true -} - -- Prevent damage to player with Fire Resistance enabled -minetest.register_on_player_hpchange(function(player, hp_change, reason) - - if EF.fire_proof[player] and hp_change < 0 then - -- This is a bit forced, but it assumes damage is taken by fire and avoids it - -- also assumes any change in hp happens between calls to this function - -- it's worth noting that you don't take damage from players in this case... - local player_info = mcl_playerinfo[player:get_player_name()] - - if is_fire_node[player_info.node_head] or is_fire_node[player_info.node_feet] or is_fire_node[player_info.node_stand] then - return 0 - else - return hp_change - end - - else - return hp_change +mcl_damage.register_modifier(function(obj, damage, reason) + if EF.fire_proof[obj] and not reason.flags.bypasses_magic and reason.flags.is_fire then + return 0 end - -end, true) +end, -50) @@ -590,8 +558,8 @@ function mcl_potions.make_invisible(player, toggle) local is_player = player:is_player() local entity = player:get_luaentity() - local playername = player:get_player_name() - local skin_file = "" + --local playername = player:get_player_name() + local skin_file if toggle then -- hide player @@ -599,25 +567,22 @@ function mcl_potions.make_invisible(player, toggle) if entity then EF.invisible[player].old_size = entity.visual_size - elseif not player:is_player() then -- if not a player or entity, do nothing + elseif not is_player then -- if not a player or entity, do nothing return end - if minetest.get_modpath("mcl_armor") and player:is_player() then - armor.textures[playername].skin = skin_file - armor:update_player_visuals(player) - elseif not player:is_player() and minetest.get_modpath("mcl_armor") or not player:is_player() and not minetest.get_modpath("mcl_armor") then + if is_player then + mcl_player.player_set_skin(player, skin_file) + elseif not is_player then player:set_properties({visual_size = {x = 0, y = 0}}) end player:set_nametag_attributes({color = {a = 0}}) elseif EF.invisible[player] then -- show player - if minetest.get_modpath("mcl_armor") and player:is_player() then - skin_file = mcl_skins.skins[playername] .. ".png" - armor.textures[playername].skin = skin_file - armor:update_player_visuals(player) - elseif not player:is_player() and minetest.get_modpath("mcl_armor") or not player:is_player() and not minetest.get_modpath("mcl_armor") then + if is_player then + mcl_skins.update_player_skin(player) + elseif not is_player then player:set_properties({visual_size = EF.invisible[player].old_size}) end player:set_nametag_attributes({color = {r = 255, g = 255, b = 255, a = 255}}) @@ -701,6 +666,10 @@ function mcl_potions.healing_func(player, hp) local obj = player:get_luaentity() + if player:get_hp() == 0 then + return + end + if obj and obj.harmed_by_heal then hp = -hp end if hp > 0 then @@ -720,12 +689,7 @@ function mcl_potions.healing_func(player, hp) hp = -1 end - if obj and obj._cmi_is_mob then - obj.health = obj.health + hp - elseif player:is_player() then - player:set_hp(player:get_hp() + hp, { type = "punch", other = "harming" }) - end - + mcl_util.deal_damage(player, -hp, {type = "magic"}) end end diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index 65bb0d4d..36f45b01 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -1,4 +1,7 @@ -local S = minetest.get_translator("mcl_potions") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + mcl_potions = {} -- duration effects of redstone are a factor of 8/3 @@ -16,8 +19,6 @@ mcl_potions.INV_FACTOR = 0.50 mcl_potions.SPLASH_FACTOR = 0.75 mcl_potions.LINGERING_FACTOR = 0.25 - -local modpath = minetest.get_modpath("mcl_potions") dofile(modpath .. "/functions.lua") dofile(modpath .. "/commands.lua") dofile(modpath .. "/splash.lua") @@ -25,11 +26,9 @@ dofile(modpath .. "/lingering.lua") dofile(modpath .. "/tipped_arrow.lua") dofile(modpath .. "/potions.lua") -local brewhelp = S("Try different combinations to create potions.") - minetest.register_craftitem("mcl_potions:fermented_spider_eye", { description = S("Fermented Spider Eye"), - _doc_items_longdesc = brewhelp, + _doc_items_longdesc = S("Try different combinations to create potions."), wield_image = "mcl_potions_spider_eye_fermented.png", inventory_image = "mcl_potions_spider_eye_fermented.png", groups = { brewitem = 1, }, @@ -65,14 +64,12 @@ minetest.register_craftitem("mcl_potions:glass_bottle", { -- Try to fill glass bottle with water local get_water = false - local from_liquid_source = false + --local from_liquid_source = false local river_water = false - if not def then - -- Unknown node: no-op - elseif def.groups and def.groups.water and def.liquidtype == "source" then + if def and def.groups and def.groups.water and def.liquidtype == "source" then -- Water source get_water = true - from_liquid_source = true + --from_liquid_source = true river_water = node.name == "mclx_core:river_water_source" -- Or reduce water level of cauldron by 1 elseif string.sub(node.name, 1, 14) == "mcl_cauldrons:" then @@ -147,7 +144,7 @@ minetest.register_craft( { -- Template function for creating images of filled potions -- - colorstring must be a ColorString of form “#RRGGBB”, e.g. “#0000FF” for blue. -- - opacity is optional opacity from 0-255 (default: 127) -local potion_image = function(colorstring, opacity) +local function potion_image(colorstring, opacity) if not opacity then opacity = 127 end @@ -275,7 +272,7 @@ minetest.register_craftitem("mcl_potions:river_water", { }) -- Hurt mobs -local water_splash = function(obj, damage) +local function water_splash(obj, damage) if not obj then return end @@ -318,9 +315,9 @@ minetest.register_craftitem("mcl_potions:speckled_melon", { minetest.register_craft({ output = "mcl_potions:speckled_melon", recipe = { - {'mcl_core:gold_nugget', 'mcl_core:gold_nugget', 'mcl_core:gold_nugget'}, - {'mcl_core:gold_nugget', 'mcl_farming:melon_item', 'mcl_core:gold_nugget'}, - {'mcl_core:gold_nugget', 'mcl_core:gold_nugget', 'mcl_core:gold_nugget'}, + {"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"}, + {"mcl_core:gold_nugget", "mcl_farming:melon_item", "mcl_core:gold_nugget"}, + {"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"}, } }) @@ -432,22 +429,20 @@ local mod_table = { -- Compare two ingredients for compatable alchemy function mcl_potions.get_alchemy(ingr, pot) - - if output_table[pot] ~= nil then + if output_table[pot] then local brew_table = output_table[pot] - if brew_table[ingr] ~= nil then + if brew_table[ingr] then return brew_table[ingr] end - end - if mod_table[ingr] ~= nil then + if mod_table[ingr] then local brew_table = mod_table[ingr] - if brew_table[pot] ~= nil then + if brew_table[pot] then return brew_table[pot] end diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index f4f0e249..d22dd418 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -1,19 +1,16 @@ -local S = minetest.get_translator("mcl_potions") +local S = minetest.get_translator(minetest.get_current_modname()) -local lingering_image = function(colorstring, opacity) +local function lingering_image(colorstring, opacity) if not opacity then opacity = 127 end return "mcl_potions_splash_overlay.png^[colorize:"..colorstring..":"..tostring(opacity).."^mcl_potions_lingering_bottle.png" end - local lingering_effect_at = {} local function add_lingering_effect(pos, color, def, is_water, instant) - lingering_effect_at[pos] = {color = color, timer = 30, def = def, is_water = is_water} - end local function linger_particles(pos, d, texture, color) diff --git a/mods/ITEMS/mcl_potions/locale/mcl_potions.de.tr b/mods/ITEMS/mcl_potions/locale/mcl_potions.de.tr index 36f5280b..34693d53 100644 --- a/mods/ITEMS/mcl_potions/locale/mcl_potions.de.tr +++ b/mods/ITEMS/mcl_potions/locale/mcl_potions.de.tr @@ -112,18 +112,3 @@ No effect=Keine Wirkung A throwable potion that will shatter on impact, where it gives all nearby players and mobs a status effect.=Ein werfbarer Trank, der bei Kollision zerbrechen wird, wo er allen nahen Spielern und Mobs einen Statuseffekt geben wird. This particular arrow is tipped and will give an effect when it hits a player or mob.=Diese Pfeilspitze dieses Pfeils in einem Trank getränkt und gibt einen Effekt, wenn er einen Spieler oder einen Mob trifft. - - - -##### not used anymore ##### - -Lingering Weakness Potion=Schwächeverweiltrank -Lingering Weakness Potion +=Schwächeverweiltrank + -Lingering Strength Potion=Stärkeverweiltrank -Lingering Strength Potion II=Stärkeverweiltrank II -Lingering Strength Potion +=Stärkeverweiltrank + -Weakness Splash Potion=Schwächewurftrank -Weakness Splash Potion +=Schwächewurftrank + -Strength Splash Potion=Stärkewurftrank -Strength Splash Potion II=Stärkewurftrank II -Strength Splash Potion +=Stärkewurftrank + diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index 4a82348e..3d89d1d4 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -1,7 +1,7 @@ -local S = minetest.get_translator("mcl_potions") -local brewhelp = S("Try different combinations to create potions.") +local S = minetest.get_translator(minetest.get_current_modname()) +--local brewhelp = S("Try different combinations to create potions.") -local potion_image = function(colorstring, opacity) +local function potion_image(colorstring, opacity) if not opacity then opacity = 127 end @@ -98,7 +98,7 @@ local function register_potion(def) end elseif def.name == "healing" or def.name == "harming" then _tt = S("@1 HP", effect) - else + else _tt = tt or time_string(dur) or S("No effect") end return _tt @@ -459,7 +459,7 @@ local healing_def = { _tt = S("+4 HP"), _tt_2 = S("+8 HP"), _longdesc = S("Instantly heals."), - color = "#CC0000", + color = "#F82423", effect = 4, instant = true, on_use = mcl_potions.healing_func, @@ -473,7 +473,7 @@ local harming_def = { _tt = S("-6 HP"), _tt_II = S("-12 HP"), _longdesc = S("Instantly deals damage."), - color = "#660099", + color = "#430A09", effect = -6, instant = true, on_use = mcl_potions.healing_func, @@ -486,7 +486,7 @@ local night_vision_def = { description = S("Night Vision"), _tt = nil, _longdesc = S("Increases the perceived brightness of light under a dark sky."), - color = "#1010AA", + color = "#1F1FA1", effect = nil, is_dur = true, on_use = mcl_potions.night_vision_func, @@ -498,7 +498,7 @@ local swiftness_def = { description = S("Swiftness"), _tt = nil, _longdesc = S("Increases walking speed."), - color = "#009999", + color = "#7CAFC6", effect = 1.2, is_dur = true, on_use = mcl_potions.swiftness_func, @@ -511,7 +511,7 @@ local slowness_def = { description = S("Slowness"), _tt = nil, _longdesc = S("Decreases walking speed."), - color = "#000080", + color = "#5A6C81", effect = 0.85, is_dur = true, on_use = mcl_potions.swiftness_func, @@ -525,7 +525,7 @@ local leaping_def = { description = S("Leaping"), _tt = nil, _longdesc = S("Increases jump strength."), - color = "#00CC33", + color = "#22FF4C", effect = 1.15, is_dur = true, on_use = mcl_potions.leaping_func, @@ -538,7 +538,7 @@ local poison_def = { description = S("Poison"), _tt = nil, _longdesc = S("Applies the poison effect which deals damage at a regular interval."), - color = "#447755", + color = "#4E9331", effect = 2.5, is_dur = true, on_use = mcl_potions.poison_func, @@ -552,7 +552,7 @@ local regeneration_def = { description = S("Regeneration"), _tt = nil, _longdesc = S("Regenerates health over time."), - color = "#B52CC2", + color = "#CD5CAB", effect = 2.5, is_dur = true, on_use = mcl_potions.regeneration_func, @@ -565,7 +565,7 @@ local invisibility_def = { description = S("Invisibility"), _tt = nil, _longdesc = S("Grants invisibility."), - color = "#B0B0B0", + color = "#7F8392", is_dur = true, on_use = mcl_potions.invisiblility_func, is_plus = true, @@ -576,7 +576,7 @@ local water_breathing_def = { description = S("Water Breathing"), _tt = nil, _longdesc = S("Grants limitless breath underwater."), - color = "#0000AA", + color = "#2E5299", is_dur = true, on_use = mcl_potions.water_breathing_func, is_plus = true, @@ -587,7 +587,7 @@ local fire_resistance_def = { description = S("Fire Resistance"), _tt = nil, _longdesc = S("Grants immunity to damage from heat sources like fire."), - color = "#D0A040", + color = "#E49A3A", is_dur = true, on_use = mcl_potions.fire_resistance_func, is_plus = true, @@ -611,22 +611,22 @@ end -- description = S("Weakness"), -- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, --- wield_image = potion_image("#6600AA"), --- inventory_image = potion_image("#6600AA"), +-- wield_image = potion_image("#484D48"), +-- inventory_image = potion_image("#484D48"), -- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, -4, mcl_potions.DURATION*mcl_potions.INV_FACTOR) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#6600AA") +-- mcl_potions._use_potion(itemstack, user, "#484D48") -- return itemstack -- end, -- -- on_secondary_use = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, -4, mcl_potions.DURATION*mcl_potions.INV_FACTOR) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#6600AA") +-- mcl_potions._use_potion(itemstack, user, "#484D48") -- return itemstack -- end -- }) @@ -635,22 +635,22 @@ end -- description = S("Weakness +"), -- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, --- wield_image = potion_image("#7700BB"), --- inventory_image = potion_image("#7700BB"), +-- wield_image = potion_image("#484D48"), +-- inventory_image = potion_image("#484D48"), -- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, -4, mcl_potions.DURATION_2*mcl_potions.INV_FACTOR) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#7700BB") +-- mcl_potions._use_potion(itemstack, user, "#484D48") -- return itemstack -- end, -- -- on_secondary_use = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, -4, mcl_potions.DURATION_2*mcl_potions.INV_FACTOR) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#7700BB") +-- mcl_potions._use_potion(itemstack, user, "#484D48") -- return itemstack -- end -- }) @@ -659,22 +659,22 @@ end -- description = S("Strength"), -- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, --- wield_image = potion_image("#D444D4"), --- inventory_image = potion_image("#D444D4"), +-- wield_image = potion_image("#932423"), +-- inventory_image = potion_image("#932423"), -- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, 3, mcl_potions.DURATION) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#D444D4") +-- mcl_potions._use_potion(itemstack, user, "#932423") -- return itemstack -- end, -- -- on_secondary_use = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, 3, mcl_potions.DURATION) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#D444D4") +-- mcl_potions._use_potion(itemstack, user, "#932423") -- return itemstack -- end -- }) @@ -683,22 +683,22 @@ end -- description = S("Strength II"), -- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, --- wield_image = potion_image("#D444E4"), --- inventory_image = potion_image("#D444E4"), +-- wield_image = potion_image("#932423"), +-- inventory_image = potion_image("#932423"), -- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, 6, mcl_potions.DURATION_2) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#D444E4") +-- mcl_potions._use_potion(itemstack, user, "#932423") -- return itemstack -- end, -- -- on_secondary_use = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, 6, mcl_potions.DURATION_2) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#D444E4") +-- mcl_potions._use_potion(itemstack, user, "#932423") -- return itemstack -- end -- }) @@ -707,22 +707,22 @@ end -- description = S("Strength +"), -- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, --- wield_image = potion_image("#D444F4"), --- inventory_image = potion_image("#D444F4"), +-- wield_image = potion_image("#932423"), +-- inventory_image = potion_image("#932423"), -- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, 3, mcl_potions.DURATION_PLUS) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#D444F4") +-- mcl_potions._use_potion(itemstack, user, "#932423") -- return itemstack -- end, -- -- on_secondary_use = function(itemstack, user, pointed_thing) -- mcl_potions.weakness_func(user, 3, mcl_potions.DURATION_PLUS) -- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) --- mcl_potions._use_potion(itemstack, user, "#D444F4") +-- mcl_potions._use_potion(itemstack, user, "#932423") -- return itemstack -- end -- }) diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index bea07b8c..112b5875 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -1,7 +1,7 @@ -local S = minetest.get_translator("mcl_potions") +local S = minetest.get_translator(minetest.get_current_modname()) local GRAVITY = tonumber(minetest.settings:get("movement_gravity")) -local splash_image = function(colorstring, opacity) +local function splash_image(colorstring, opacity) if not opacity then opacity = 127 end @@ -10,7 +10,6 @@ end function mcl_potions.register_splash(name, descr, color, def) - local id = "mcl_potions:"..name.."_splash" local longdesc = def.longdesc if not def.no_effect then @@ -123,6 +122,6 @@ function mcl_potions.register_splash(name, descr, color, def) }) end -local function time_string(dur) +--[[local function time_string(dur) return math.floor(dur/60)..string.format(":%02d",math.floor(dur % 60)) -end +end]] diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index 860019e8..3991b277 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -1,15 +1,18 @@ -local S = minetest.get_translator("mcl_potions") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math + -- Time in seconds after which a stuck arrow is deleted local ARROW_TIMEOUT = 60 -- Time after which stuck arrow is rechecked for being stuck local STUCK_RECHECK_TIME = 5 -local GRAVITY = 9.81 +--local GRAVITY = 9.81 local YAW_OFFSET = -math.pi/2 -local dir_to_pitch = function(dir) - local dir2 = vector.normalize(dir) +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 @@ -121,7 +124,7 @@ function mcl_potions.register_arrow(name, desc, color, def) } -- Destroy arrow entity self at pos and drops it as an item - local spawn_item = function(self, pos) + local function spawn_item(self, pos) if not minetest.is_creative_enabled("") then local item = minetest.add_item(pos, "mcl_potions:"..name.."_arrow") item:set_velocity({x=0, y=0, z=0}) @@ -130,7 +133,7 @@ function mcl_potions.register_arrow(name, desc, color, def) self.object:remove() end - ARROW_ENTITY.on_step = function(self, dtime) + function ARROW_ENTITY.on_step(self, dtime) local pos = self.object:get_pos() local dpos = table.copy(pos) -- digital pos dpos = vector.round(dpos) @@ -197,7 +200,6 @@ function mcl_potions.register_arrow(name, desc, color, def) 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. @@ -216,7 +218,7 @@ function mcl_potions.register_arrow(name, desc, color, def) -- Arrows can only damage players and mobs if obj ~= self._shooter and obj:is_player() then ok = true - elseif obj:get_luaentity() ~= nil then + elseif obj:get_luaentity() then if obj ~= self._shooter and obj:get_luaentity()._cmi_is_mob then ok = true end @@ -235,7 +237,7 @@ function mcl_potions.register_arrow(name, desc, color, def) end -- If an attackable object was found, we will damage the closest one only - if closest_object ~= nil then + if closest_object then local obj = closest_object local is_player = obj:is_player() local lua = obj:get_luaentity() @@ -360,7 +362,7 @@ function mcl_potions.register_arrow(name, desc, color, def) if not v then v = 0 end - local old_v = self._viscosity + --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 @@ -387,13 +389,13 @@ function mcl_potions.register_arrow(name, desc, color, def) -- Force recheck of stuck arrows when punched. -- Otherwise, punching has no effect. - ARROW_ENTITY.on_punch = function(self) + function ARROW_ENTITY.on_punch(self) if self._stuck then self._stuckrechecktimer = STUCK_RECHECK_TIME end end - ARROW_ENTITY.get_staticdata = function(self) + function ARROW_ENTITY.get_staticdata(self) local out = { lastpos = self._lastpos, startpos = self._startpos, @@ -414,7 +416,7 @@ function mcl_potions.register_arrow(name, desc, color, def) return minetest.serialize(out) end - ARROW_ENTITY.on_activate = function(self, staticdata, dtime_s) + function ARROW_ENTITY.on_activate(self, staticdata, dtime_s) local data = minetest.deserialize(staticdata) if data then self._stuck = data.stuck @@ -452,20 +454,18 @@ function mcl_potions.register_arrow(name, desc, color, def) minetest.register_entity("mcl_potions:"..name.."_arrow_entity", ARROW_ENTITY) if minetest.get_modpath("mcl_bows") then - minetest.register_craft({ - output = 'mcl_potions:'..name..'_arrow 8', + output = "mcl_potions:"..name.."_arrow 8", recipe = { - {'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'}, - {'mcl_bows:arrow','mcl_potions:'..name..'_lingering','mcl_bows:arrow'}, - {'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'} + {"mcl_bows:arrow","mcl_bows:arrow","mcl_bows:arrow"}, + {"mcl_bows:arrow","mcl_potions:"..name.."_lingering","mcl_bows:arrow"}, + {"mcl_bows:arrow","mcl_bows:arrow","mcl_bows:arrow"} } }) end - if minetest.get_modpath("doc_identifier") ~= nil then + if minetest.get_modpath("doc_identifier") then doc.sub.identifier.register_object("mcl_bows:arrow_entity", "craftitems", "mcl_bows:arrow") end - end diff --git a/mods/ITEMS/mcl_signs/init.lua b/mods/ITEMS/mcl_signs/init.lua index e053c6e8..b6bfb3fe 100644 --- a/mods/ITEMS/mcl_signs/init.lua +++ b/mods/ITEMS/mcl_signs/init.lua @@ -1,6 +1,10 @@ -local S = minetest.get_translator("mcl_signs") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) local F = minetest.formspec_escape +local table = table + -- Load the characters map (characters.txt) --[[ File format of characters.txt: It's an UTF-8 encoded text file that contains metadata for all supported characters. It contains a sequence of info blocks, one for each character. Each info block is made out of 3 lines: @@ -13,7 +17,7 @@ After line 3, another info block may follow. This repeats until the end of the f All character files must be 5 or 6 pixels wide (5 pixels are preferred) ]] -local chars_file = io.open(minetest.get_modpath("mcl_signs").."/characters.txt", "r") +local chars_file = io.open(modpath.."/characters.txt", "r") -- FIXME: Support more characters (many characters are missing). Currently ASCII and Latin-1 Supplement are supported. local charmap = {} if not chars_file then @@ -46,7 +50,7 @@ local function round(num, idp) return math.floor(num * mult + 0.5) / mult end -local string_to_array = function(str) +local function string_to_array(str) local tab = {} for i=1,string.len(str) do table.insert(tab, string.sub(str, i,i)) @@ -54,7 +58,7 @@ local string_to_array = function(str) return tab end -local string_to_line_array = function(str) +local function string_to_line_array(str) local tab = {} local current = 1 local linechar = 1 @@ -73,7 +77,7 @@ local string_to_line_array = function(str) return tab end -local create_lines = function(text) +local function create_lines(text) local line_num = 1 local tab = {} for _, line in ipairs(string_to_line_array(text)) do @@ -86,19 +90,19 @@ local create_lines = function(text) return tab end -local generate_line = function(s, ypos) +local function generate_line(s, ypos) local i = 1 local parsed = {} local width = 0 local chars = 0 local printed_char_width = CHAR_WIDTH + 1 while chars < LINE_LENGTH and i <= #s do - local file = nil + local file -- Get and render character - if charmap[s:sub(i, i)] ~= nil then + if charmap[s:sub(i, i)] then file = charmap[s:sub(i, i)] i = i + 1 - elseif i < #s and charmap[s:sub(i, i + 1)] ~= nil then + elseif i < #s and charmap[s:sub(i, i + 1)] then file = charmap[s:sub(i, i + 1)] i = i + 2 else @@ -108,7 +112,7 @@ local generate_line = function(s, ypos) i = i + 1 minetest.log("verbose", "[mcl_signs] Unknown symbol in '"..s.."' at "..i) end - if file ~= nil then + if file then width = width + printed_char_width table.insert(parsed, file) chars = chars + 1 @@ -125,7 +129,7 @@ local generate_line = function(s, ypos) return texture end -local generate_texture = function(lines, signnodename) +local function generate_texture(lines, signnodename) local texture = "[combine:"..SIGN_WIDTH.."x"..SIGN_WIDTH local ypos if signnodename == "mcl_signs:wall_sign" then @@ -152,6 +156,7 @@ local signtext_info_wall = { local signtext_info_standing = {} local m = -1/16 + 1/64 + for rot=0, 15 do local yaw = math.pi*2 - (((math.pi*2) / 16) * rot) local delta = vector.multiply(minetest.yaw_to_dir(yaw), m) @@ -185,9 +190,9 @@ local function get_wall_signtext_info(param2, nodename) end end -local sign_groups = {handy=1,axey=1, flammable=1, deco_block=1, material_wood=1, attached_node=1, dig_by_piston=1, flammable=-1} +local sign_groups = {handy=1,axey=1, deco_block=1, material_wood=1, attached_node=1, dig_by_piston=1, flammable=-1} -local destruct_sign = function(pos) +local function destruct_sign(pos) local objects = minetest.get_objects_inside_radius(pos, 0.5) for _, v in ipairs(objects) do local ent = v:get_luaentity() @@ -203,7 +208,7 @@ local destruct_sign = function(pos) end end -local update_sign = function(pos, fields, sender, force_remove) +local function update_sign(pos, fields, sender, force_remove) local meta = minetest.get_meta(pos) if not meta then return @@ -256,7 +261,7 @@ local update_sign = function(pos, fields, sender, force_remove) text_entity:set_yaw(sign_info.yaw) end -local show_formspec = function(player, pos) +local function show_formspec(player, pos) minetest.show_formspec( player:get_player_name(), "mcl_signs:set_text_"..pos.x.."_"..pos.y.."_"..pos.z, @@ -322,7 +327,7 @@ minetest.register_node("mcl_signs:wall_sign", { local wdir = minetest.dir_to_wallmounted(dir) - local placer_pos = placer:get_pos() + --local placer_pos = placer:get_pos() local fdir = minetest.dir_to_facedir(dir) @@ -518,7 +523,7 @@ minetest.register_entity("mcl_signs:text", { _signnodename = nil, -- node name of sign node to which the text belongs on_activate = function(self, staticdata) - if staticdata ~= nil and staticdata ~= "" then + if staticdata and staticdata ~= "" then local des = minetest.deserialize(staticdata) if des then self._signnodename = des._signnodename @@ -545,11 +550,11 @@ minetest.register_craft({ if minetest.get_modpath("mcl_core") then minetest.register_craft({ - output = 'mcl_signs:wall_sign 3', + output = "mcl_signs:wall_sign 3", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'group:wood', 'group:wood', 'group:wood'}, - {'', 'mcl_core:stick', ''}, + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "group:wood", "group:wood"}, + {"", "mcl_core:stick", ""}, } }) end diff --git a/mods/ITEMS/mcl_sponges/init.lua b/mods/ITEMS/mcl_sponges/init.lua index 75a99b0f..a1998ecb 100644 --- a/mods/ITEMS/mcl_sponges/init.lua +++ b/mods/ITEMS/mcl_sponges/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_sponges") +local S = minetest.get_translator(minetest.get_current_modname()) local absorb = function(pos) local change = false @@ -73,7 +73,7 @@ minetest.register_node("mcl_sponges:sponge", { on_water = true end local water_found = minetest.find_node_near(pos, 1, "group:water") - if water_found ~= nil then + if water_found then on_water = true end if on_water then @@ -114,6 +114,19 @@ 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(), + collisiondetection = false, + vertical = false, + size = math.random(2, 5), + texture = "mcl_particles_sponge"..math.random(1, 5)..".png", + }) + end if not minetest.is_creative_enabled(name) then itemstack:take_item() end diff --git a/mods/ITEMS/mcl_stairs/api.lua b/mods/ITEMS/mcl_stairs/api.lua index aecf1083..34afb018 100644 --- a/mods/ITEMS/mcl_stairs/api.lua +++ b/mods/ITEMS/mcl_stairs/api.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_stairs") +local S = minetest.get_translator(minetest.get_current_modname()) -- Core mcl_stairs API @@ -20,7 +20,7 @@ local function place_slab_normal(itemstack, placer, pointed_thing) local p0 = pointed_thing.under local p1 = pointed_thing.above - local placer_pos = placer:get_pos() + --local placer_pos = placer:get_pos() local fpos = get_fpos(placer, pointed_thing) @@ -155,7 +155,7 @@ function mcl_stairs.register_stair(subname, recipeitem, groups, images, descript if recipeitem then minetest.register_craft({ - output = 'mcl_stairs:stair_' .. subname .. ' 4', + output = "mcl_stairs:stair_" .. subname .. " 4", recipe = { {recipeitem, "", ""}, {recipeitem, recipeitem, ""}, @@ -165,7 +165,7 @@ function mcl_stairs.register_stair(subname, recipeitem, groups, images, descript -- Flipped recipe minetest.register_craft({ - output = 'mcl_stairs:stair_' .. subname .. ' 4', + output = "mcl_stairs:stair_" .. subname .. " 4", recipe = { {"", "", recipeitem}, {"", recipeitem, recipeitem}, @@ -179,7 +179,7 @@ end -- Slab facedir to placement 6d matching table -local slab_trans_dir = {[0] = 8, 0, 2, 1, 3, 4} +--local slab_trans_dir = {[0] = 8, 0, 2, 1, 3, 4} -- Register slabs. -- Node will be called mcl_stairs:slab_ @@ -268,6 +268,7 @@ function mcl_stairs.register_slab(subname, recipeitem, groups, images, descripti end end, _mcl_hardness = hardness, + _mcl_blast_resistance = blast_resistance, _mcl_other_slab_half = upper_slab, on_rotate = function(pos, node, user, mode, param2) -- Flip slab @@ -296,7 +297,7 @@ function mcl_stairs.register_slab(subname, recipeitem, groups, images, descripti topdef._doc_items_usagehelp = nil topdef.drop = lower_slab topdef._mcl_other_slab_half = lower_slab - topdef.on_rotate = function(pos, node, user, mode, param2) + function topdef.on_rotate(pos, node, user, mode, param2) -- Flip slab if mode == screwdriver.ROTATE_AXIS then node.name = lower_slab @@ -331,6 +332,7 @@ function mcl_stairs.register_slab(subname, recipeitem, groups, images, descripti sounds = sounds, drop = lower_slab .. " 2", _mcl_hardness = hardness, + _mcl_blast_resistance = blast_resistance, }) if recipeitem then diff --git a/mods/ITEMS/mcl_stairs/cornerstair.lua b/mods/ITEMS/mcl_stairs/cornerstair.lua index 2d5f214e..ae3eb4ea 100644 --- a/mods/ITEMS/mcl_stairs/cornerstair.lua +++ b/mods/ITEMS/mcl_stairs/cornerstair.lua @@ -5,7 +5,7 @@ mcl_stairs.cornerstair = {} -local get_stair_param = function(node) +local function get_stair_param(node) local stair = minetest.get_item_group(node.name, "stair") if stair == 1 then return node.param2 @@ -24,7 +24,7 @@ local get_stair_param = function(node) end end -local get_stair_from_param = function(param, stairs) +local function get_stair_from_param(param, stairs) if param < 12 then if param < 4 then return {name = stairs[1], param2 = param} @@ -44,7 +44,7 @@ local get_stair_from_param = function(param, stairs) end end -local stair_param_to_connect = function(param, ceiling) +local function stair_param_to_connect(param, ceiling) local out = {false, false, false, false, false, false, false, false} if not ceiling then if param == 0 then @@ -126,7 +126,7 @@ local stair_param_to_connect = function(param, ceiling) return out end -local stair_connect_to_param = function(connect, ceiling) +local function stair_connect_to_param(connect, ceiling) local param if not ceiling then if connect[3] and connect[8] then @@ -240,7 +240,7 @@ function mcl_stairs.cornerstair.add(name, stairtiles) inner_groups.stair = 3 inner_groups.not_in_craft_guide = 1 local drop = node_def.drop or name - local after_dig_node = function(pos, oldnode) + local function after_dig_node(pos, oldnode) local param = get_stair_param(oldnode) local ceiling if param < 12 then @@ -273,7 +273,7 @@ function mcl_stairs.cornerstair.add(name, stairtiles) end end end - local swap_stair = function(index, n1, n2) + local function swap_stair(index, n1, n2) local connect = {false, false, false, false, false, false, false, false} connect[n1] = true connect[n2] = true @@ -425,13 +425,13 @@ function mcl_stairs.cornerstair.add(name, stairtiles) end end end - local reset_node = function(n1, n2) + local function reset_node(n1, n2) local connect = {false, false, false, false, false, false, false, false} connect[n1] = true connect[n2] = true node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[5].stairs) end - local swap_stair = function(index, n1, n2) + local function swap_stair(index, n1, n2) local connect = {false, false, false, false, false, false, false, false} connect[n1] = true connect[n2] = true diff --git a/mods/ITEMS/mcl_stairs/crafting.lua b/mods/ITEMS/mcl_stairs/crafting.lua index 702a7806..f31237ee 100644 --- a/mods/ITEMS/mcl_stairs/crafting.lua +++ b/mods/ITEMS/mcl_stairs/crafting.lua @@ -1,40 +1,40 @@ minetest.register_craft({ - output = 'mcl_core:sandstonecarved', + output = "mcl_core:sandstonecarved", recipe = { - {'mcl_stairs:slab_sandstone'}, - {'mcl_stairs:slab_sandstone'} + {"mcl_stairs:slab_sandstone"}, + {"mcl_stairs:slab_sandstone"} } }) minetest.register_craft({ - output = 'mcl_core:redsandstonecarved', + output = "mcl_core:redsandstonecarved", recipe = { - {'mcl_stairs:slab_redsandstone'}, - {'mcl_stairs:slab_redsandstone'} + {"mcl_stairs:slab_redsandstone"}, + {"mcl_stairs:slab_redsandstone"} } }) minetest.register_craft({ - output = 'mcl_core:stonebrickcarved', + output = "mcl_core:stonebrickcarved", recipe = { - {'mcl_stairs:slab_stonebrick'}, - {'mcl_stairs:slab_stonebrick'} + {"mcl_stairs:slab_stonebrick"}, + {"mcl_stairs:slab_stonebrick"} } }) minetest.register_craft({ - output = 'mcl_end:purpur_pillar', + output = "mcl_end:purpur_pillar", recipe = { - {'mcl_stairs:slab_purpur_block'}, - {'mcl_stairs:slab_purpur_block'} + {"mcl_stairs:slab_purpur_block"}, + {"mcl_stairs:slab_purpur_block"} } }) minetest.register_craft({ - output = 'mcl_nether:quartz_chiseled 2', + output = "mcl_nether:quartz_chiseled 2", recipe = { - {'mcl_stairs:slab_quartzblock'}, - {'mcl_stairs:slab_quartzblock'}, + {"mcl_stairs:slab_quartzblock"}, + {"mcl_stairs:slab_quartzblock"}, } }) diff --git a/mods/ITEMS/mcl_stairs/init.lua b/mods/ITEMS/mcl_stairs/init.lua index a5ca820b..92f0640b 100644 --- a/mods/ITEMS/mcl_stairs/init.lua +++ b/mods/ITEMS/mcl_stairs/init.lua @@ -7,8 +7,10 @@ mcl_stairs = {} -- Load other files -dofile(minetest.get_modpath("mcl_stairs").."/api.lua") -dofile(minetest.get_modpath("mcl_stairs").."/cornerstair.lua") -dofile(minetest.get_modpath("mcl_stairs").."/register.lua") -dofile(minetest.get_modpath("mcl_stairs").."/crafting.lua") -dofile(minetest.get_modpath("mcl_stairs").."/alias.lua") +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +dofile(modpath.."/api.lua") +dofile(modpath.."/cornerstair.lua") +dofile(modpath.."/register.lua") +dofile(modpath.."/crafting.lua") +dofile(modpath.."/alias.lua") diff --git a/mods/ITEMS/mcl_stairs/register.lua b/mods/ITEMS/mcl_stairs/register.lua index 565f5409..5de38058 100644 --- a/mods/ITEMS/mcl_stairs/register.lua +++ b/mods/ITEMS/mcl_stairs/register.lua @@ -3,7 +3,7 @@ -- slabs actually take slightly longer to be dug than their stair counterparts. -- Note sure if it is a good idea to preserve this oddity. -local S = minetest.get_translator("mcl_stairs") +local S = minetest.get_translator(minetest.get_current_modname()) local woods = { { "wood", "default_wood.png", S("Oak Wood Stairs"), S("Oak Wood Slab"), S("Double Oak Wood Slab") }, diff --git a/mods/ITEMS/mcl_throwing/init.lua b/mods/ITEMS/mcl_throwing/init.lua index 09a34c12..c468946d 100644 --- a/mods/ITEMS/mcl_throwing/init.lua +++ b/mods/ITEMS/mcl_throwing/init.lua @@ -1,10 +1,8 @@ mcl_throwing = {} -local S = minetest.get_translator("mcl_throwing") -local mod_death_messages = minetest.get_modpath("mcl_death_messages") local modpath = minetest.get_modpath(minetest.get_current_modname()) --- +-- -- Snowballs and other throwable items -- @@ -39,10 +37,10 @@ end -- Throw item function mcl_throwing.get_player_throw_function(entity_name, velocity) - local func = function(item, player, pointed_thing) + local function func(item, player, pointed_thing) local playerpos = player:get_pos() local dir = player:get_look_dir() - local obj = mcl_throwing.throw(item, {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, velocity, player:get_player_name()) + mcl_throwing.throw(item, {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, velocity, player:get_player_name()) if not minetest.is_creative_enabled(player:get_player_name()) then item:take_item() end diff --git a/mods/ITEMS/mcl_throwing/register.lua b/mods/ITEMS/mcl_throwing/register.lua index 3d8cc94c..ec11f86c 100644 --- a/mods/ITEMS/mcl_throwing/register.lua +++ b/mods/ITEMS/mcl_throwing/register.lua @@ -1,5 +1,8 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local math = math +local vector = vector + -- The snowball entity local snowball_ENTITY={ physical = false, @@ -15,6 +18,7 @@ local snowball_ENTITY={ _lastpos={}, } + local egg_ENTITY={ physical = false, timer=0, @@ -29,6 +33,7 @@ local egg_ENTITY={ _lastpos={}, } + -- Ender pearl entity local pearl_ENTITY={ physical = false, @@ -45,7 +50,7 @@ local pearl_ENTITY={ _thrower = nil, -- Player ObjectRef of the player who threw the ender pearl } -local check_object_hit = function(self, pos, dmg) +local function check_object_hit(self, pos, dmg) for _,object in pairs(minetest.get_objects_inside_radius(pos, 1.5)) do local entity = object:get_luaentity() @@ -70,7 +75,7 @@ local check_object_hit = function(self, pos, dmg) return false end -local snowball_particles = function(pos, vel) +local function snowball_particles(pos, vel) local vel = vector.normalize(vector.multiply(vel, -1)) minetest.add_particlespawner({ amount = 20, @@ -93,14 +98,13 @@ local snowball_particles = function(pos, vel) end -- Snowball on_step()--> called when snowball is moving. -local snowball_on_step = function(self, dtime) - self.timer=self.timer+dtime +local function snowball_on_step(self, dtime) + self.timer = self.timer + dtime local pos = self.object:get_pos() local vel = self.object:get_velocity() local node = minetest.get_node(pos) local def = minetest.registered_nodes[node.name] - -- Destroy when hitting a solid node if self._lastpos.x~=nil then if (def and def.walkable) or not def then @@ -110,33 +114,31 @@ local snowball_on_step = function(self, dtime) return end end - if check_object_hit(self, pos, {snowball_vulnerable = 3}) then minetest.sound_play("mcl_throwing_snowball_impact_soft", { pos = pos, max_hear_distance=16, gain=0.7 }, true) snowball_particles(pos, vel) self.object:remove() return end - self._lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set _lastpos-->Node will be added at last pos outside the node end -- Movement function of egg -local egg_on_step = function(self, dtime) - self.timer=self.timer+dtime +local function egg_on_step(self, dtime) + self.timer = self.timer + dtime local pos = self.object:get_pos() local node = minetest.get_node(pos) local def = minetest.registered_nodes[node.name] -- Destroy when hitting a solid node with chance to spawn chicks - if self._lastpos.x~=nil then + if self._lastpos.x then if (def and def.walkable) or not def then -- 1/8 chance to spawn a chick -- FIXME: Chicks have a quite good chance to spawn in walls local r = math.random(1,8) -- Turn given object into a child - local make_child= function(object) + local function make_child(object) local ent = object:get_luaentity() object:set_properties({ visual_size = { x = ent.base_size.x/2, y = ent.base_size.y/2 }, @@ -185,8 +187,8 @@ local egg_on_step = function(self, dtime) end -- Movement function of ender pearl -local pearl_on_step = function(self, dtime) - self.timer=self.timer+dtime +local function pearl_on_step(self, dtime) + self.timer = self.timer + dtime local pos = self.object:get_pos() pos.y = math.floor(pos.y) local node = minetest.get_node(pos) @@ -224,7 +226,7 @@ local pearl_on_step = function(self, dtime) lv, ld = math.abs(vc.x), "x" end if math.abs(vc.z) > lv then - lv, ld = math.abs(vc.z), "z" + ld = "z" --math.abs(vc.z) end if ld ~= "x" then vc.x = 0 end if ld ~= "y" then vc.y = 0 end diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 8001e5cf..bf7b5238 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -1,8 +1,6 @@ -local S = minetest.get_translator("mcl_tnt") +local S = minetest.get_translator(minetest.get_current_modname()) local tnt_griefing = minetest.settings:get_bool("mcl_tnt_griefing", true) -local mod_death_messages = minetest.get_modpath("mcl_death_messages") - local function spawn_tnt(pos, entname) minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,}, true) local tnt = minetest.add_entity(pos, entname) @@ -11,7 +9,8 @@ local function spawn_tnt(pos, entname) end tnt = {} -tnt.ignite = function(pos) + +function tnt.ignite(pos) minetest.remove_node(pos) local e = spawn_tnt(pos, "mcl_tnt:tnt") minetest.check_for_falling(pos) @@ -20,7 +19,7 @@ end -- Add smoke particle of entity at pos. -- Intended to be called every step -tnt.smoke_step = function(pos) +function tnt.smoke_step(pos) minetest.add_particle({ pos = {x=pos.x,y=pos.y+0.5,z=pos.z}, velocity = vector.new(math.random() * 0.2 - 0.1, 1.0 + math.random(), math.random() * 0.2 - 0.1), @@ -116,7 +115,7 @@ function TNT:on_activate(staticdata) self.object:set_texture_mod("^mcl_tnt_blink.png") end -local function add_effects(pos, radius, drops) +--[[local function add_effects(pos, radius, drops) minetest.add_particlespawner({ amount = 64, time = 0.5, @@ -163,7 +162,7 @@ local function add_effects(pos, radius, drops) texture = texture, collisiondetection = true, }) -end +end]] function TNT:on_step(dtime) local pos = self.object:get_pos() @@ -191,9 +190,9 @@ if minetest.get_modpath("mcl_mobitems") then minetest.register_craft({ output = "mcl_tnt:tnt", recipe = { - {'mcl_mobitems:gunpowder','group:sand','mcl_mobitems:gunpowder'}, - {'group:sand','mcl_mobitems:gunpowder','group:sand'}, - {'mcl_mobitems:gunpowder','group:sand','mcl_mobitems:gunpowder'} + {"mcl_mobitems:gunpowder", "group:sand", "mcl_mobitems:gunpowder"}, + {"group:sand", "mcl_mobitems:gunpowder", "group:sand"}, + {"mcl_mobitems:gunpowder", "group:sand", "mcl_mobitems:gunpowder"} } }) end diff --git a/mods/ITEMS/mcl_tnt/mod.conf b/mods/ITEMS/mcl_tnt/mod.conf index 9d75a788..2e90ddb8 100644 --- a/mods/ITEMS/mcl_tnt/mod.conf +++ b/mods/ITEMS/mcl_tnt/mod.conf @@ -1,3 +1,3 @@ name = mcl_tnt depends = mcl_explosions, mcl_particles -optional_depends = mcl_sounds, mcl_mobitems, mcl_death_messages, doc_identifier, mesecons +optional_depends = mcl_sounds, mcl_mobitems, doc_identifier, mesecons diff --git a/mods/ITEMS/mcl_tools/crafting.lua b/mods/ITEMS/mcl_tools/crafting.lua index 00d378d7..636cb666 100644 --- a/mods/ITEMS/mcl_tools/crafting.lua +++ b/mods/ITEMS/mcl_tools/crafting.lua @@ -1,235 +1,235 @@ minetest.register_craft({ - output = 'mcl_tools:pick_wood', + output = "mcl_tools:pick_wood", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"group:wood", "group:wood", "group:wood"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:pick_stone', + output = "mcl_tools:pick_stone", recipe = { - {'mcl_core:cobble', 'mcl_core:cobble', 'mcl_core:cobble'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:pick_iron', + output = "mcl_tools:pick_iron", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:pick_gold', + output = "mcl_tools:pick_gold", recipe = { - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:pick_diamond', + output = "mcl_tools:pick_diamond", recipe = { - {'mcl_core:diamond', 'mcl_core:diamond', 'mcl_core:diamond'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_wood', + output = "mcl_tools:shovel_wood", recipe = { - {'group:wood'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"group:wood"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_stone', + output = "mcl_tools:shovel_stone", recipe = { - {'mcl_core:cobble'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"mcl_core:cobble"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_iron', + output = "mcl_tools:shovel_iron", recipe = { - {'mcl_core:iron_ingot'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"mcl_core:iron_ingot"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_gold', + output = "mcl_tools:shovel_gold", recipe = { - {'mcl_core:gold_ingot'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"mcl_core:gold_ingot"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_diamond', + output = "mcl_tools:shovel_diamond", recipe = { - {'mcl_core:diamond'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"mcl_core:diamond"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_wood', + output = "mcl_tools:axe_wood", recipe = { - {'group:wood', 'group:wood'}, - {'group:wood', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"group:wood", "group:wood"}, + {"group:wood", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_wood', + output = "mcl_tools:axe_wood", recipe = { - {'group:wood', 'group:wood'}, - {'mcl_core:stick', 'group:wood'}, - {'mcl_core:stick', ''}, + {"group:wood", "group:wood"}, + {"mcl_core:stick", "group:wood"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_stone', + output = "mcl_tools:axe_stone", recipe = { - {'mcl_core:cobble', 'mcl_core:cobble'}, - {'mcl_core:cobble', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"mcl_core:cobble", "mcl_core:cobble"}, + {"mcl_core:cobble", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_stone', + output = "mcl_tools:axe_stone", recipe = { - {'mcl_core:cobble', 'mcl_core:cobble'}, - {'mcl_core:stick', 'mcl_core:cobble'}, - {'mcl_core:stick', ''}, + {"mcl_core:cobble", "mcl_core:cobble"}, + {"mcl_core:stick", "mcl_core:cobble"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_iron', + output = "mcl_tools:axe_iron", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_iron', + output = "mcl_tools:axe_iron", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:stick', 'mcl_core:iron_ingot'}, - {'mcl_core:stick', ''}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:stick", "mcl_core:iron_ingot"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_gold', + output = "mcl_tools:axe_gold", recipe = { - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'mcl_core:gold_ingot', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_gold', + output = "mcl_tools:axe_gold", recipe = { - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'mcl_core:stick', 'mcl_core:gold_ingot'}, - {'mcl_core:stick', ''}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"mcl_core:stick", "mcl_core:gold_ingot"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_diamond', + output = "mcl_tools:axe_diamond", recipe = { - {'mcl_core:diamond', 'mcl_core:diamond'}, - {'mcl_core:diamond', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"mcl_core:diamond", "mcl_core:diamond"}, + {"mcl_core:diamond", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_diamond', + output = "mcl_tools:axe_diamond", recipe = { - {'mcl_core:diamond', 'mcl_core:diamond'}, - {'mcl_core:stick', 'mcl_core:diamond'}, - {'mcl_core:stick', ''}, + {"mcl_core:diamond", "mcl_core:diamond"}, + {"mcl_core:stick", "mcl_core:diamond"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_wood', + output = "mcl_tools:sword_wood", recipe = { - {'group:wood'}, - {'group:wood'}, - {'mcl_core:stick'}, + {"group:wood"}, + {"group:wood"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_stone', + output = "mcl_tools:sword_stone", recipe = { - {'mcl_core:cobble'}, - {'mcl_core:cobble'}, - {'mcl_core:stick'}, + {"mcl_core:cobble"}, + {"mcl_core:cobble"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_iron', + output = "mcl_tools:sword_iron", recipe = { - {'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot'}, - {'mcl_core:stick'}, + {"mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_gold', + output = "mcl_tools:sword_gold", recipe = { - {'mcl_core:gold_ingot'}, - {'mcl_core:gold_ingot'}, - {'mcl_core:stick'}, + {"mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_diamond', + output = "mcl_tools:sword_diamond", recipe = { - {'mcl_core:diamond'}, - {'mcl_core:diamond'}, - {'mcl_core:stick'}, + {"mcl_core:diamond"}, + {"mcl_core:diamond"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shears', + output = "mcl_tools:shears", recipe = { - { 'mcl_core:iron_ingot', '' }, - { '', 'mcl_core:iron_ingot', }, + { "mcl_core:iron_ingot", "" }, + { "", "mcl_core:iron_ingot", }, } }) minetest.register_craft({ - output = 'mcl_tools:shears', + output = "mcl_tools:shears", recipe = { - { '', 'mcl_core:iron_ingot', }, - { 'mcl_core:iron_ingot', '' }, + { "", "mcl_core:iron_ingot" }, + { "mcl_core:iron_ingot", "" }, } }) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 2d804b9b..c05aeb2d 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mcl_tools") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) -- mods/default/tools.lua @@ -175,7 +177,7 @@ minetest.register_tool("mcl_tools:pick_diamond", { }, }) -local make_grass_path = function(itemstack, placer, pointed_thing) +local function make_grass_path(itemstack, placer, pointed_thing) -- Use pointed node's on_rightclick function first, if present local node = minetest.get_node(pointed_thing.under) if placer and not placer:get_player_control().sneak then @@ -213,7 +215,7 @@ end local carve_pumpkin if minetest.get_modpath("mcl_farming") then - carve_pumpkin = function(itemstack, placer, pointed_thing) + function carve_pumpkin(itemstack, placer, pointed_thing) -- Use pointed node's on_rightclick function first, if present local node = minetest.get_node(pointed_thing.under) if placer and not placer:get_player_control().sneak then @@ -233,7 +235,7 @@ if minetest.get_modpath("mcl_farming") then local wear = mcl_autogroup.get_wear(toolname, "shearsy") itemstack:add_wear(wear) end - minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true) + minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true) local dir = vector.subtract(pointed_thing.under, pointed_thing.above) local param2 = minetest.dir_to_facedir(dir) minetest.swap_node(pointed_thing.under, {name="mcl_farming:pumpkin_face", param2 = param2}) @@ -352,54 +354,32 @@ minetest.register_tool("mcl_tools:shovel_diamond", { }) -- Axes +local function make_stripped_trunk(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then return end -local make_stripped_trunk = function(itemstack, placer, pointed_thing) - if pointed_thing.type == "node" then - local pos = minetest.get_pointed_thing_position(pointed_thing) - local node = minetest.get_node(pos) - local node_name = node.name - if placer and not placer: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, placer, itemstack) or itemstack - end - end - if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) - return itemstack - end + local node = minetest.get_node(pointed_thing.under) + local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] + + if not placer:get_player_control().sneak and noddef.on_rightclick then + return minetest.item_place(itemstack, placer, pointed_thing) + end + if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then + minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) + return itemstack + end + + if noddef._mcl_stripped_varient == nil then + return itemstack + else + minetest.swap_node(pointed_thing.under, {name=noddef._mcl_stripped_varient, param2=node.param2}) if not minetest.is_creative_enabled(placer:get_player_name()) then -- Add wear (as if digging a axey node) local toolname = itemstack:get_name() local wear = mcl_autogroup.get_wear(toolname, "axey") itemstack:add_wear(wear) end - if node_name == "mcl_core:tree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak"}) - elseif node_name == "mcl_core:darktree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak"}) - elseif node_name == "mcl_core:acaciatree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia"}) - elseif node_name == "mcl_core:birchtree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch"}) - elseif node_name == "mcl_core:sprucetree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce"}) - elseif node_name == "mcl_core:jungletree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle"}) - elseif node_name == "mcl_core:tree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak_bark"}) - elseif node_name == "mcl_core:darktree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak_bark"}) - elseif node_name == "mcl_core:acaciatree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia_bark"}) - elseif node_name == "mcl_core:birchtree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch_bark"}) - elseif node_name == "mcl_core:sprucetree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce_bark"}) - elseif node_name == "mcl_core:jungletree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle_bark"}) - end end - return itemstack + return itemstack end minetest.register_tool("mcl_tools:axe_wood", { @@ -632,5 +612,5 @@ minetest.register_tool("mcl_tools:shears", { }) -dofile(minetest.get_modpath("mcl_tools").."/crafting.lua") -dofile(minetest.get_modpath("mcl_tools").."/aliases.lua") +dofile(modpath.."/crafting.lua") +dofile(modpath.."/aliases.lua") diff --git a/mods/ITEMS/mcl_torches/api.lua b/mods/ITEMS/mcl_torches/api.lua new file mode 100644 index 00000000..dab50879 --- /dev/null +++ b/mods/ITEMS/mcl_torches/api.lua @@ -0,0 +1,267 @@ +local smoke_pdef = { + amount = 0.5, + maxexptime = 2.0, + minvel = { x = 0.0, y = 0.5, z = 0.0 }, + maxvel = { x = 0.0, y = 0.6, z = 0.0 }, + minsize = 1.5, + maxsize = 1.5, + minrelpos = { x = -1/16, y = 0.04, z = -1/16 }, + maxrelpos = { x = 1/16, y = 0.06, z = 1/16 }, +} + +local function spawn_flames_floor(pos) + -- Flames + mcl_particles.add_node_particlespawner(pos, { + amount = 8, + time = 0, + minpos = vector.add(pos, { x = -0.1, y = 0.05, z = -0.1 }), + maxpos = vector.add(pos, { x = 0.1, y = 0.15, z = 0.1 }), + minvel = { x = -0.01, y = 0, z = -0.01 }, + maxvel = { x = 0.01, y = 0.1, z = 0.01 }, + minexptime = 0.3, + maxexptime = 0.6, + minsize = 0.7, + maxsize = 2, + texture = "mcl_particles_flame.png", + glow = minetest.registered_nodes[minetest.get_node(pos).name].light_source, + }, "low") + -- Smoke + mcl_particles.spawn_smoke(pos, "torch", smoke_pdef) +end + +local function spawn_flames_wall(pos) + --local minrelpos, maxrelpos + local node = minetest.get_node(pos) + local dir = minetest.wallmounted_to_dir(node.param2) + + local smoke_pdef = table.copy(smoke_pdef) + + if dir.x < 0 then + smoke_pdef.minrelpos = { x = -0.38, y = 0.04, z = -0.1 } + smoke_pdef.maxrelpos = { x = -0.2, y = 0.14, z = 0.1 } + elseif dir.x > 0 then + smoke_pdef.minrelpos = { x = 0.2, y = 0.04, z = -0.1 } + smoke_pdef.maxrelpos = { x = 0.38, y = 0.14, z = 0.1 } + elseif dir.z < 0 then + smoke_pdef.minrelpos = { x = -0.1, y = 0.04, z = -0.38 } + smoke_pdef.maxrelpos = { x = 0.1, y = 0.14, z = -0.2 } + elseif dir.z > 0 then + smoke_pdef.minrelpos = { x = -0.1, y = 0.04, z = 0.2 } + smoke_pdef.maxrelpos = { x = 0.1, y = 0.14, z = 0.38 } + else + return + end + + + -- Flames + mcl_particles.add_node_particlespawner(pos, { + amount = 8, + time = 0, + minpos = vector.add(pos, smoke_pdef.minrelpos), + maxpos = vector.add(pos, smoke_pdef.maxrelpos), + minvel = { x = -0.01, y = 0, z = -0.01 }, + maxvel = { x = 0.01, y = 0.1, z = 0.01 }, + minexptime = 0.3, + maxexptime = 0.6, + minsize = 0.7, + maxsize = 2, + texture = "mcl_particles_flame.png", + glow = minetest.registered_nodes[node.name].light_source, + }, "low") + -- Smoke + mcl_particles.spawn_smoke(pos, "torch", smoke_pdef) +end + +local function remove_flames(pos) + mcl_particles.delete_node_particlespawners(pos) +end + +-- +-- 3d torch part +-- + +-- Check if placement at given node is allowed +local function check_placement_allowed(node, wdir) + -- Torch placement rules: Disallow placement on some nodes. General rule: Solid, opaque, full cube collision box nodes are allowed. + -- Special allowed nodes: + -- * soul sand + -- * mob spawner + -- * chorus flower + -- * glass, barrier, ice + -- * Fence, wall, end portal frame with ender eye: Only on top + -- * Slab, stairs: Only on top if upside down + + -- Special forbidden nodes: + -- * Piston, sticky piston + local def = minetest.registered_nodes[node.name] + if not def then + return false + -- No ceiling torches + elseif wdir == 0 then + return false + elseif not def.buildable_to then + if node.name ~= "mcl_core:ice" and node.name ~= "mcl_nether:soul_sand" and node.name ~= "mcl_mobspawners:spawner" and node.name ~= "mcl_core:barrier" and node.name ~= "mcl_end:chorus_flower" and node.name ~= "mcl_end:chorus_flower_dead" and (not def.groups.glass) and + ((not def.groups.solid) or (not def.groups.opaque)) then + -- Only allow top placement on these nodes + if node.name == "mcl_end:dragon_egg" or node.name == "mcl_portals:end_portal_frame_eye" or def.groups.fence == 1 or def.groups.wall or def.groups.slab_top == 1 or def.groups.anvil or def.groups.pane or (def.groups.stair == 1 and minetest.facedir_to_dir(node.param2).y ~= 0) then + if wdir ~= 1 then + return false + end + else + return false + end + elseif minetest.get_item_group(node.name, "piston") >= 1 then + return false + end + end + return true +end + +function mcl_torches.register_torch(def) + local itemstring = minetest.get_current_modname() .. ":" .. def.name + local itemstring_wall = itemstring .. "_wall" + + def.light = def.light or minetest.LIGHT_MAX + def.mesh_floor = def.mesh_floor or "mcl_torches_torch_floor.obj" + def.mesh_wall = def.mesh_wall or "mcl_torches_torch_wall.obj" + + local groups = def.groups or {} + + groups.attached_node = 1 + groups.torch = 1 + groups.torch_particles = def.particles and 1 + groups.dig_by_water = 1 + groups.destroy_by_lava_flow = 1 + groups.dig_by_piston = 1 + + local floordef = { + description = def.description, + _doc_items_longdesc = def.doc_items_longdesc, + _doc_items_usagehelp = def.doc_items_usagehelp, + _doc_items_hidden = def.doc_items_hidden, + _doc_items_create_entry = def._doc_items_create_entry, + drawtype = "mesh", + mesh = def.mesh_floor, + inventory_image = def.icon, + wield_image = def.icon, + tiles = def.tiles, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + liquids_pointable = false, + light_source = def.light, + groups = groups, + drop = def.drop or itemstring, + selection_box = { + type = "wallmounted", + wall_top = {-1/16, -1/16, -1/16, 1/16, 0.5, 1/16}, + wall_bottom = {-1/16, -0.5, -1/16, 1/16, 1/16, 1/16}, + }, + sounds = def.sounds, + node_placement_prediction = "", + on_place = function(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then + -- no interaction possible with entities, for now. + return itemstack + end + + local under = pointed_thing.under + local node = minetest.get_node(under) + local def = minetest.registered_nodes[node.name] + if not def then return itemstack end + + -- Call on_rightclick if the pointed node defines it + if placer and not placer: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(under, node, placer, itemstack) or itemstack + end + end + + local above = pointed_thing.above + local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}) + + if check_placement_allowed(node, wdir) == false then + return itemstack + end + + local itemstring = itemstack:get_name() + local fakestack = ItemStack(itemstack) + local idef = fakestack:get_definition() + local retval + + if wdir == 1 then + retval = fakestack:set_name(itemstring) + else + retval = fakestack:set_name(itemstring_wall) + end + if not retval then + return itemstack + end + + local success + itemstack, success = minetest.item_place(fakestack, placer, pointed_thing, wdir) + itemstack:set_name(itemstring) + + if success and idef.sounds and idef.sounds.place then + minetest.sound_play(idef.sounds.place, {pos=under, gain=1}, true) + end + return itemstack + end, + on_rotate = false, + on_construct = def.particles and spawn_flames_floor, + on_destruct = def.particles and remove_flames, + } + minetest.register_node(itemstring, floordef) + + local groups_wall = table.copy(groups) + groups_wall.torch = 2 + + local walldef = { + drawtype = "mesh", + mesh = def.mesh_wall, + tiles = def.tiles, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + light_source = def.light, + groups = groups_wall, + drop = def.drop or itemstring, + selection_box = { + type = "wallmounted", + wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1}, + wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1}, + wall_side = {-0.5, -0.5, -0.1, -0.2, 0.1, 0.1}, + }, + sounds = def.sounds, + on_rotate = false, + on_construct = def.particles and spawn_flames_wall, + on_destruct = def.particles and remove_flames, + } + minetest.register_node(itemstring_wall, walldef) + + -- Add entry alias for the Help + if minetest.get_modpath("doc") then + doc.add_entry_alias("nodes", itemstring, "nodes", itemstring_wall) + end +end + +minetest.register_lbm({ + label = "Torch flame particles", + name = "mcl_torches:flames", + nodenames = {"group:torch_particles"}, + run_at_every_load = true, + action = function(pos, node) + local torch_group = minetest.get_item_group(node.name, "torch") + if torch_group == 1 then + spawn_flames_floor(pos) + elseif torch_group == 2 then + spawn_flames_wall(pos) + end + end, +}) diff --git a/mods/ITEMS/mcl_torches/init.lua b/mods/ITEMS/mcl_torches/init.lua index 451a8dfa..6b6ebcae 100644 --- a/mods/ITEMS/mcl_torches/init.lua +++ b/mods/ITEMS/mcl_torches/init.lua @@ -1,338 +1,6 @@ -local S = minetest.get_translator("mcl_torches") -local LIGHT_TORCH = minetest.LIGHT_MAX - -local spawn_flames_floor = function(pos) - -- Flames - mcl_particles.add_node_particlespawner(pos, { - amount = 8, - time = 0, - minpos = vector.add(pos, { x = -0.1, y = 0.05, z = -0.1 }), - maxpos = vector.add(pos, { x = 0.1, y = 0.15, z = 0.1 }), - minvel = { x = -0.01, y = 0, z = -0.01 }, - maxvel = { x = 0.01, y = 0.1, z = 0.01 }, - minexptime = 0.3, - maxexptime = 0.6, - minsize = 0.7, - maxsize = 2, - texture = "mcl_particles_flame.png", - glow = LIGHT_TORCH, - }, "low") - -- Smoke - mcl_particles.add_node_particlespawner(pos, { - amount = 0.5, - time = 0, - minpos = vector.add(pos, { x = -1/16, y = 0.04, z = -1/16 }), - maxpos = vector.add(pos, { x = -1/16, y = 0.06, z = -1/16 }), - minvel = { x = 0, y = 0.5, z = 0 }, - maxvel = { x = 0, y = 0.6, z = 0 }, - minexptime = 2.0, - maxexptime = 2.0, - minsize = 1.5, - maxsize = 1.5, - texture = "mcl_particles_smoke_anim.png", - animation = { - type = "vertical_frames", - aspect_w = 8, - aspect_h = 8, - length = 2.05, - }, - }, "medium") -end - -local spawn_flames_wall = function(pos, param2) - local minrelpos, maxrelpos - local dir = minetest.wallmounted_to_dir(param2) - if dir.x < 0 then - minrelpos = { x = -0.38, y = 0.04, z = -0.1 } - maxrelpos = { x = -0.2, y = 0.14, z = 0.1 } - elseif dir.x > 0 then - minrelpos = { x = 0.2, y = 0.04, z = -0.1 } - maxrelpos = { x = 0.38, y = 0.14, z = 0.1 } - elseif dir.z < 0 then - minrelpos = { x = -0.1, y = 0.04, z = -0.38 } - maxrelpos = { x = 0.1, y = 0.14, z = -0.2 } - elseif dir.z > 0 then - minrelpos = { x = -0.1, y = 0.04, z = 0.2 } - maxrelpos = { x = 0.1, y = 0.14, z = 0.38 } - else - return - end - -- Flames - mcl_particles.add_node_particlespawner(pos, { - amount = 8, - time = 0, - minpos = vector.add(pos, minrelpos), - maxpos = vector.add(pos, maxrelpos), - minvel = { x = -0.01, y = 0, z = -0.01 }, - maxvel = { x = 0.01, y = 0.1, z = 0.01 }, - minexptime = 0.3, - maxexptime = 0.6, - minsize = 0.7, - maxsize = 2, - texture = "mcl_particles_flame.png", - glow = LIGHT_TORCH, - }, "low") - -- Smoke - mcl_particles.add_node_particlespawner(pos, { - amount = 0.5, - time = 0, - minpos = vector.add(pos, minrelpos), - maxpos = vector.add(pos, maxrelpos), - minvel = { x = 0, y = 0.5, z = 0 }, - maxvel = { x = 0, y = 0.6, z = 0 }, - minexptime = 2.0, - maxexptime = 2.0, - minsize = 1.5, - maxsize = 1.5, - texture = "mcl_particles_smoke_anim.png", - animation = { - type = "vertical_frames", - aspect_w = 8, - aspect_h = 8, - length = 2.05, - }, - }, "medium") -end - -local remove_flames = function(pos) - mcl_particles.delete_node_particlespawners(pos) -end - --- --- 3d torch part --- - --- Check if placement at given node is allowed -local function check_placement_allowed(node, wdir) - -- Torch placement rules: Disallow placement on some nodes. General rule: Solid, opaque, full cube collision box nodes are allowed. - -- Special allowed nodes: - -- * soul sand - -- * mob spawner - -- * chorus flower - -- * glass, barrier, ice - -- * Fence, wall, end portal frame with ender eye: Only on top - -- * Slab, stairs: Only on top if upside down - - -- Special forbidden nodes: - -- * Piston, sticky piston - local def = minetest.registered_nodes[node.name] - if not def then - return false - -- No ceiling torches - elseif wdir == 0 then - return false - elseif not def.buildable_to then - if node.name ~= "mcl_core:ice" and node.name ~= "mcl_nether:soul_sand" and node.name ~= "mcl_mobspawners:spawner" and node.name ~= "mcl_core:barrier" and node.name ~= "mcl_end:chorus_flower" and node.name ~= "mcl_end:chorus_flower_dead" and (not def.groups.glass) and - ((not def.groups.solid) or (not def.groups.opaque)) then - -- Only allow top placement on these nodes - if node.name == "mcl_end:dragon_egg" or node.name == "mcl_portals:end_portal_frame_eye" or def.groups.fence == 1 or def.groups.wall or def.groups.slab_top == 1 or def.groups.anvil or def.groups.pane or (def.groups.stair == 1 and minetest.facedir_to_dir(node.param2).y ~= 0) then - if wdir ~= 1 then - return false - end - else - return false - end - elseif minetest.get_item_group(node.name, "piston") >= 1 then - return false - end - end - return true -end - mcl_torches = {} -mcl_torches.register_torch = function(substring, description, doc_items_longdesc, doc_items_usagehelp, icon, mesh_floor, mesh_wall, tiles, light, groups, sounds, moredef, moredef_floor, moredef_wall) - local itemstring = minetest.get_current_modname()..":"..substring - local itemstring_wall = minetest.get_current_modname()..":"..substring.."_wall" - - if light == nil then light = minetest.LIGHT_MAX end - if mesh_floor == nil then mesh_floor = "mcl_torches_torch_floor.obj" end - if mesh_wall == nil then mesh_wall = "mcl_torches_torch_wall.obj" end - if groups == nil then groups = {} end - - groups.attached_node = 1 - groups.torch = 1 - groups.dig_by_water = 1 - groups.destroy_by_lava_flow = 1 - groups.dig_by_piston = 1 - - local floordef = { - description = description, - _doc_items_longdesc = doc_items_longdesc, - _doc_items_usagehelp = doc_items_usagehelp, - drawtype = "mesh", - mesh = mesh_floor, - inventory_image = icon, - wield_image = icon, - tiles = tiles, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - is_ground_content = false, - walkable = false, - liquids_pointable = false, - light_source = light, - groups = groups, - drop = itemstring, - selection_box = { - type = "wallmounted", - wall_top = {-1/16, -1/16, -1/16, 1/16, 0.5, 1/16}, - wall_bottom = {-1/16, -0.5, -1/16, 1/16, 1/16, 1/16}, - }, - sounds = sounds, - node_placement_prediction = "", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.type ~= "node" then - -- no interaction possible with entities, for now. - return itemstack - end - - local under = pointed_thing.under - local node = minetest.get_node(under) - local def = minetest.registered_nodes[node.name] - if not def then return itemstack end - - -- Call on_rightclick if the pointed node defines it - if placer and not placer: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(under, node, placer, itemstack) or itemstack - end - end - - local above = pointed_thing.above - local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}) - - if check_placement_allowed(node, wdir) == false then - return itemstack - end - - local itemstring = itemstack:get_name() - local fakestack = ItemStack(itemstack) - local idef = fakestack:get_definition() - local retval - - if wdir == 1 then - retval = fakestack:set_name(itemstring) - else - retval = fakestack:set_name(itemstring_wall) - end - if not retval then - return itemstack - end - - local success - itemstack, success = minetest.item_place(fakestack, placer, pointed_thing, wdir) - itemstack:set_name(itemstring) - - if success and idef.sounds and idef.sounds.place then - minetest.sound_play(idef.sounds.place, {pos=under, gain=1}, true) - end - return itemstack - end, - on_rotate = false, - } - if moredef ~= nil then - for k,v in pairs(moredef) do - floordef[k] = v - end - end - if moredef_floor ~= nil then - for k,v in pairs(moredef_floor) do - floordef[k] = v - end - end - minetest.register_node(itemstring, floordef) - - local groups_wall = table.copy(groups) - groups_wall.torch = 2 - - local walldef = { - drawtype = "mesh", - mesh = mesh_wall, - tiles = tiles, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - is_ground_content = false, - walkable = false, - light_source = light, - groups = groups_wall, - drop = itemstring, - selection_box = { - type = "wallmounted", - wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1}, - wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1}, - wall_side = {-0.5, -0.5, -0.1, -0.2, 0.1, 0.1}, - }, - sounds = sounds, - on_rotate = false, - } - if moredef ~= nil then - for k,v in pairs(moredef) do - walldef[k] = v - end - end - if moredef_wall ~= nil then - for k,v in pairs(moredef_wall) do - walldef[k] = v - end - end - minetest.register_node(itemstring_wall, walldef) - - - -- Add entry alias for the Help - if minetest.get_modpath("doc") then - doc.add_entry_alias("nodes", itemstring, "nodes", itemstring_wall) - end - -end - -mcl_torches.register_torch("torch", - S("Torch"), - S("Torches are light sources which can be placed at the side or on the top of most blocks."), - nil, - "default_torch_on_floor.png", - "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj", - {{ - name = "default_torch_on_floor_animated.png", - animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} - }}, - LIGHT_TORCH, - {dig_immediate=3, torch=1, deco_block=1}, - mcl_sounds.node_sound_wood_defaults(), - {_doc_items_hidden = false, - on_destruct = function(pos) - remove_flames(pos) - end}, - {on_construct = function(pos) - spawn_flames_floor(pos) - end}, - {on_construct = function(pos) - local node = minetest.get_node(pos) - spawn_flames_wall(pos, node.param2) - end}) - -minetest.register_craft({ - output = "mcl_torches:torch 4", - recipe = { - { "group:coal" }, - { "mcl_core:stick" }, - } -}) - -minetest.register_lbm({ - label = "Torch flame particles", - name = "mcl_torches:flames", - nodenames = {"mcl_torches:torch", "mcl_torches:torch_wall"}, - run_at_every_load = true, - action = function(pos, node) - if node.name == "mcl_torches:torch" then - spawn_flames_floor(pos) - elseif node.name == "mcl_torches:torch_wall" then - spawn_flames_wall(pos, node.param2) - end - end, -}) +local modpath = minetest.get_modpath(minetest.get_current_modname()) +dofile(modpath .. "/api.lua") +dofile(modpath .. "/register.lua") diff --git a/mods/ITEMS/mcl_torches/register.lua b/mods/ITEMS/mcl_torches/register.lua new file mode 100644 index 00000000..f8c34e6b --- /dev/null +++ b/mods/ITEMS/mcl_torches/register.lua @@ -0,0 +1,27 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +mcl_torches.register_torch({ + name = "torch", + description = S("Torch"), + doc_items_longdesc = S("Torches are light sources which can be placed at the side or on the top of most blocks."), + doc_items_hidden = false, + icon = "default_torch_on_floor.png", + tiles = {{ + name = "default_torch_on_floor_animated.png", + animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} + }}, + -- this is 15 in minecraft + light = 14, + groups = {dig_immediate = 3, deco_block = 1}, + sounds = mcl_sounds.node_sound_wood_defaults(), + particles = true, +}) + +minetest.register_craft({ + output = "mcl_torches:torch 4", + recipe = { + {"group:coal"}, + {"mcl_core:stick"}, + } +}) + diff --git a/mods/ITEMS/mcl_torches/screenshot.png b/mods/ITEMS/mcl_torches/screenshot.png deleted file mode 100644 index 5c9f8591..00000000 Binary files a/mods/ITEMS/mcl_torches/screenshot.png and /dev/null differ diff --git a/mods/ITEMS/mcl_totems/init.lua b/mods/ITEMS/mcl_totems/init.lua index b4ec3eb8..499d7362 100644 --- a/mods/ITEMS/mcl_totems/init.lua +++ b/mods/ITEMS/mcl_totems/init.lua @@ -1,5 +1,58 @@ --- Node is currently defined in mobs_mc. --- TODO: Add full item definition here when status effects become a thing. +local hud_totem = {} --- Add group for Creative Mode. -minetest.override_item("mobs_mc:totem", {groups = { combat_item=1}}) +minetest.register_on_leaveplayer(function(player) + hud_totem[player] = nil +end) + +-- 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 + local hp = obj:get_hp() + if hp - damage <= 0 then + local wield = obj:get_wielded_item() + if wield:get_name() == "mobs_mc:totem" then + 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 + if pnname == mobs_mc.misc.totem_fail_nodes[n] then + return + end + end + -- Reset breath as well + if obj:get_breath() < 11 then + obj:set_breath(10) + end + + if not minetest.is_creative_enabled(obj:get_player_name()) then + wield:take_item() + obj:set_wielded_item(wield) + end + + -- Effects + minetest.sound_play({name = "mcl_totems_totem", gain=1}, {pos=ppos, max_hear_distance=16}, true) + + -- 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 }, + z_index = 100, + }) + minetest.after(3, function() + if obj:is_player() then + obj:hud_remove(hud_totem[obj]) + hud_totem[obj] = nil + end + end) + end + + -- Set HP to exactly 1 + return hp - 1 + end + end + end +end, 1000) diff --git a/mods/ITEMS/mcl_totems/mod.conf b/mods/ITEMS/mcl_totems/mod.conf index 70c5844c..4ba94def 100644 --- a/mods/ITEMS/mcl_totems/mod.conf +++ b/mods/ITEMS/mcl_totems/mod.conf @@ -1,2 +1,2 @@ name = mcl_totems -depends = mobs_mc +depends = mobs_mc, mcl_damage diff --git a/mods/ITEMS/mcl_walls/init.lua b/mods/ITEMS/mcl_walls/init.lua index 36694c6f..14b512ff 100644 --- a/mods/ITEMS/mcl_walls/init.lua +++ b/mods/ITEMS/mcl_walls/init.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mcl_walls") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) mcl_walls = {} @@ -29,7 +31,7 @@ local function update_wall(pos) local colonpos = thisnode.name:find(":") local underscorepos local itemname, basename, modname - if colonpos ~= nil then + if colonpos then itemname = thisnode.name:sub(colonpos+1) modname = thisnode.name:sub(1, colonpos-1) end @@ -151,7 +153,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory minetest.register_node(nodename.."_"..i, { collision_box = { - type = 'fixed', + type = "fixed", fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, drawtype = "nodebox", @@ -180,7 +182,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory minetest.register_node(nodename.."_16", { drawtype = "nodebox", collision_box = { - type = 'fixed', + type = "fixed", fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, tiles = tiles, @@ -206,7 +208,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory minetest.register_node(nodename.."_21", { drawtype = "nodebox", collision_box = { - type = 'fixed', + type = "fixed", fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, tiles = tiles, @@ -247,7 +249,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory fixed = pillar }, collision_box = { - type = 'fixed', + type = "fixed", fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, collisionbox = {-0.2, 0, -0.2, 0.2, 1.4, 0.2}, @@ -267,7 +269,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory end end -dofile(minetest.get_modpath("mcl_walls") .. "/register.lua") +dofile(modpath.."/register.lua") minetest.register_on_placenode(update_wall_global) minetest.register_on_dignode(update_wall_global) diff --git a/mods/ITEMS/mcl_walls/register.lua b/mods/ITEMS/mcl_walls/register.lua index 0ccefd62..483af493 100644 --- a/mods/ITEMS/mcl_walls/register.lua +++ b/mods/ITEMS/mcl_walls/register.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_walls") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_walls.register_wall("mcl_walls:cobble", S("Cobblestone Wall"), "mcl_core:cobble", {"mcl_walls_cobble_wall_top.png", "default_cobble.png", "mcl_walls_cobble_wall_side.png"}) mcl_walls.register_wall("mcl_walls:mossycobble", S("Mossy Cobblestone Wall"), "mcl_core:mossycobble", {"mcl_walls_cobble_mossy_wall_top.png", "default_mossycobble.png", "mcl_walls_cobble_mossy_wall_side.png"}) diff --git a/mods/ITEMS/mcl_wool/init.lua b/mods/ITEMS/mcl_wool/init.lua index 22648efc..8fb4f51e 100644 --- a/mods/ITEMS/mcl_wool/init.lua +++ b/mods/ITEMS/mcl_wool/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_wool") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") -- minetest/wool/init.lua @@ -99,13 +99,13 @@ for _, row in ipairs(wool.dyes) do -- Crafting from dye and white wool minetest.register_craft({ type = "shapeless", - output = 'mcl_wool:'..name, - recipe = {"mcl_dye:"..dye, 'mcl_wool:white'}, + output = "mcl_wool:"..name, + recipe = {"mcl_dye:"..dye, "mcl_wool:white"}, }) end minetest.register_craft({ - output = 'mcl_wool:'..name..'_carpet 3', - recipe = {{'mcl_wool:'..name, 'mcl_wool:'..name}}, + output = "mcl_wool:"..name.."_carpet 3", + recipe = {{"mcl_wool:"..name, "mcl_wool:"..name}}, }) end diff --git a/mods/ITEMS/mcl_wool/locale/mcl_wool.de.tr b/mods/ITEMS/mcl_wool/locale/mcl_wool.de.tr index 5b979d51..9f67a52f 100644 --- a/mods/ITEMS/mcl_wool/locale/mcl_wool.de.tr +++ b/mods/ITEMS/mcl_wool/locale/mcl_wool.de.tr @@ -22,7 +22,7 @@ Blue Carpet=Blauer Teppich Magenta Wool=Magenta Wolle Magenta Carpet=Magenta Teppich Orange Wool=Orange Wolle -Orange Carpet=Orange Teppich +Orange Carpet=Oranger Teppich Purple Wool=Violette Wolle Purple Carpet=Violetter Teppich Brown Wool=Braune Wolle diff --git a/mods/ITEMS/mclx_core/init.lua b/mods/ITEMS/mclx_core/init.lua index bc17e007..4bb40184 100644 --- a/mods/ITEMS/mclx_core/init.lua +++ b/mods/ITEMS/mclx_core/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mclx_core") +local S = minetest.get_translator(minetest.get_current_modname()) -- Liquids: River Water diff --git a/mods/ITEMS/mclx_fences/init.lua b/mods/ITEMS/mclx_fences/init.lua index 08c3d91a..e78c7ef7 100644 --- a/mods/ITEMS/mclx_fences/init.lua +++ b/mods/ITEMS/mclx_fences/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mclx_fences") +local S = minetest.get_translator(minetest.get_current_modname()) -- Red Nether Brick Fence @@ -25,7 +25,7 @@ mcl_fences.register_fence_gate( -- Crafting minetest.register_craft({ - output = 'mclx_fences:red_nether_brick_fence 6', + output = "mclx_fences:red_nether_brick_fence 6", recipe = { {"mcl_nether:red_nether_brick", "mcl_nether:netherbrick", "mcl_nether:red_nether_brick"}, {"mcl_nether:red_nether_brick", "mcl_nether:netherbrick", "mcl_nether:red_nether_brick"}, @@ -33,14 +33,14 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mclx_fences:red_nether_brick_fence_gate', + output = "mclx_fences:red_nether_brick_fence_gate", recipe = { {"mcl_nether:nether_wart_item", "mcl_nether:red_nether_brick", "mcl_nether:netherbrick"}, {"mcl_nether:netherbrick", "mcl_nether:red_nether_brick", "mcl_nether:nether_wart_item"}, } }) minetest.register_craft({ - output = 'mclx_fences:red_nether_brick_fence_gate', + output = "mclx_fences:red_nether_brick_fence_gate", recipe = { {"mcl_nether:netherbrick", "mcl_nether:red_nether_brick", "mcl_nether:nether_wart_item"}, {"mcl_nether:nether_wart_item", "mcl_nether:red_nether_brick", "mcl_nether:netherbrick"}, @@ -48,7 +48,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mclx_fences:nether_brick_fence_gate 2', + output = "mclx_fences:nether_brick_fence_gate 2", recipe = { {"mcl_nether:netherbrick", "mcl_nether:nether_brick", "mcl_nether:netherbrick"}, {"mcl_nether:netherbrick", "mcl_nether:nether_brick", "mcl_nether:netherbrick"}, diff --git a/mods/ITEMS/mclx_stairs/init.lua b/mods/ITEMS/mclx_stairs/init.lua index 26ab5c4b..effa87f1 100644 --- a/mods/ITEMS/mclx_stairs/init.lua +++ b/mods/ITEMS/mclx_stairs/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mclx_stairs") +local S = minetest.get_translator(minetest.get_current_modname()) local doc_mod = minetest.get_modpath("doc") diff --git a/mods/ITEMS/screwdriver/init.lua b/mods/ITEMS/screwdriver/init.lua index e6aedf19..baa4ff9c 100644 --- a/mods/ITEMS/screwdriver/init.lua +++ b/mods/ITEMS/screwdriver/init.lua @@ -1,18 +1,21 @@ -local S = minetest.get_translator("screwdriver") +local S = minetest.get_translator(minetest.get_current_modname()) screwdriver = {} screwdriver.ROTATE_FACE = 1 screwdriver.ROTATE_AXIS = 2 -screwdriver.disallow = function(pos, node, user, mode, new_param2) + +function screwdriver.disallow(pos, node, user, mode, new_param2) return false end -screwdriver.rotate_simple = function(pos, node, user, mode, new_param2) + +function screwdriver.rotate_simple(pos, node, user, mode, new_param2) if mode ~= screwdriver.ROTATE_FACE then return false end end -screwdriver.rotate_3way = function(pos, node, user, mode, new_param2) + +function screwdriver.rotate_3way(pos, node, user, mode, new_param2) if mode == screwdriver.ROTATE_AXIS then if node.param2 == 0 then node.param2 = 6 @@ -71,7 +74,7 @@ local facedir_tbl = { }, } -screwdriver.rotate.facedir = function(pos, node, mode) +function screwdriver.rotate.facedir(pos, node, mode) local rotation = node.param2 % 32 -- get first 5 bits local other = node.param2 - rotation rotation = facedir_tbl[mode][rotation] or 0 @@ -82,10 +85,10 @@ screwdriver.rotate.colorfacedir = screwdriver.rotate.facedir local wallmounted_tbl = { [screwdriver.ROTATE_FACE] = {[2] = 5, [3] = 4, [4] = 2, [5] = 3, [1] = 0, [0] = 1}, - [screwdriver.ROTATE_AXIS] = {[2] = 5, [3] = 4, [4] = 2, [5] = 1, [1] = 0, [0] = 3} + [screwdriver.ROTATE_AXIS] = {[2] = 5, [3] = 4, [4] = 2, [5] = 1, [1] = 0, [0] = 3}, } -screwdriver.rotate.wallmounted = function(pos, node, mode) +function screwdriver.rotate.wallmounted(pos, node, mode) local rotation = node.param2 % 8 -- get first 3 bits local other = node.param2 - rotation rotation = wallmounted_tbl[mode][rotation] or 0 @@ -105,7 +108,7 @@ end screwdriver.rotate.colorwallmounted = screwdriver.rotate.wallmounted -- Handles rotation -screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses) +function screwdriver.handler(itemstack, user, pointed_thing, mode, uses) if pointed_thing.type ~= "node" then return end @@ -157,7 +160,6 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses) if should_rotate and new_param2 ~= node.param2 then node.param2 = new_param2 minetest.swap_node(pos, node) - minetest.check_for_falling(pos) if ndef.after_rotate then ndef.after_rotate(vector.new(pos)) diff --git a/mods/ITEMS/screwdriver/locale/screwdriver.de.tr b/mods/ITEMS/screwdriver/locale/screwdriver.de.tr index 35c99c05..eaf44b0d 100644 --- a/mods/ITEMS/screwdriver/locale/screwdriver.de.tr +++ b/mods/ITEMS/screwdriver/locale/screwdriver.de.tr @@ -1,2 +1,2 @@ # textdomain: screwdriver -Screwdriver=Schraubendreher +Screwdriver=Schraubenzieher diff --git a/mods/ITEMS/xpanes/init.lua b/mods/ITEMS/xpanes/init.lua index e1914a9f..fe67934a 100644 --- a/mods/ITEMS/xpanes/init.lua +++ b/mods/ITEMS/xpanes/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("xpanes") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") local function is_pane(pos) @@ -142,7 +142,7 @@ function xpanes.register_pane(name, def) tiles = {def.textures[3], def.textures[2], def.textures[1]}, use_texture_alpha = def.use_texture_alpha, groups = groups, - drop = "xpanes:" .. name .. "_flat", + drop = drop, sounds = def.sounds, node_box = { type = "connected", @@ -153,7 +153,6 @@ function xpanes.register_pane(name, def) connect_right = {{1/32, -1/2, -1/32, 1/2, 1/2, 1/32}}, }, connects_to = {"group:pane", "group:stone", "group:glass", "group:wood", "group:tree"}, - drop = drop, _mcl_blast_resistance = def._mcl_blast_resistance, _mcl_hardness = def._mcl_hardness, _mcl_silk_touch_drop = def._mcl_silk_touch_drop and {"xpanes:" .. name .. "_flat"}, @@ -171,7 +170,7 @@ end local canonical_color = "yellow" -- Register glass pane (stained and unstained) -local pane = function(description, node, append) +local function pane(description, node, append) local texture1, longdesc, entry_name, create_entry local is_canonical = true -- Special case: Default (unstained) glass texture diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 5f051034..a630dba0 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -6,8 +6,12 @@ local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superfl local generate_fallen_logs = minetest.settings:get_bool("mcl_generate_fallen_logs", false) +local mod_mcl_structures = minetest.get_modpath("mcl_structures") +local mod_mcl_core = minetest.get_modpath("mcl_core") +local mod_mcl_mushrooms = minetest.get_modpath("mcl_mushrooms") + -- Jungle bush schematic. In PC/Java Edition it's Jungle Wood + Oak Leaves -local jungle_bush_schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_bush_oak_leaves.mts" +local jungle_bush_schematic = mod_mcl_core.."/schematics/mcl_core_jungle_bush_oak_leaves.mts" local deco_id_chorus_plant @@ -1775,7 +1779,7 @@ local function register_biomelike_ores() -- Mesa strata (registered as sheet ores) -- Helper function to create strata. - local stratum = function(y_min, height, color, seed, is_perfect) + local function stratum(y_min, height, color, seed, is_perfect) if not height then height = 1 end @@ -2307,7 +2311,7 @@ local function register_decorations() biomes = {"IcePlainsSpikes"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_large.mts", + schematic = mod_mcl_structures.."/schematics/mcl_structures_ice_spike_large.mts", rotation = "random", flags = "place_center_x, place_center_z", }) @@ -2328,7 +2332,7 @@ local function register_decorations() biomes = {"IcePlainsSpikes"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_small.mts", + schematic = mod_mcl_structures.."/schematics/mcl_structures_ice_spike_small.mts", rotation = "random", flags = "place_center_x, place_center_z", }) @@ -2351,7 +2355,7 @@ local function register_decorations() biomes = {"Forest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_large_"..i..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_large_"..i..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2371,7 +2375,7 @@ local function register_decorations() biomes = {"ExtremeHills", "ExtremeHillsM", "ExtremeHills+", "ExtremeHills+_snowtop"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_large_"..i..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_large_"..i..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2392,7 +2396,7 @@ local function register_decorations() biomes = {"Forest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2411,7 +2415,7 @@ local function register_decorations() biomes = {"FlowerForest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2430,7 +2434,7 @@ local function register_decorations() biomes = {"ExtremeHills", "ExtremeHillsM", "ExtremeHills+", "ExtremeHills+_snowtop"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2450,7 +2454,7 @@ local function register_decorations() biomes = {"ExtremeHills+", "ExtremeHills+_snowtop"}, y_min = 50, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2469,7 +2473,7 @@ local function register_decorations() biomes = {"MesaPlateauF_grasstop"}, y_min = 30, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2488,7 +2492,7 @@ local function register_decorations() biomes = {"MesaPlateauFM_grasstop"}, y_min = 30, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2508,7 +2512,7 @@ local function register_decorations() biomes = {"IcePlains"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2520,7 +2524,7 @@ local function register_decorations() biomes = {"Jungle", "JungleM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2532,7 +2536,7 @@ local function register_decorations() biomes = {"JungleEdge", "JungleEdgeM", "Savanna"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2554,7 +2558,7 @@ local function register_decorations() biomes = {"Forest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_balloon.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_balloon.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2575,7 +2579,7 @@ local function register_decorations() biomes = {"Swampland", "Swampland_shore"}, y_min = 0, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_swamp.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_swamp.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2592,7 +2596,7 @@ local function register_decorations() biomes = {"Jungle"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree_huge_"..i..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree_huge_"..i..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2604,7 +2608,7 @@ local function register_decorations() biomes = {"JungleM"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree_huge_"..i..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree_huge_"..i..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2619,7 +2623,7 @@ local function register_decorations() biomes = {"Jungle"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2631,7 +2635,7 @@ local function register_decorations() biomes = {"JungleEdge", "JungleEdgeM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2644,7 +2648,7 @@ local function register_decorations() biomes = {"JungleM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2669,7 +2673,7 @@ local function register_decorations() biomes = biomes, y_min = y, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/"..sprucename, + schematic = mod_mcl_core.."/schematics/"..sprucename, flags = "place_center_x, place_center_z", }) end @@ -2723,7 +2727,7 @@ local function register_decorations() biomes = {"Taiga", "ColdTaiga"}, y_min = 2, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_spruce_lollipop.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_spruce_lollipop.mts", flags = "place_center_x, place_center_z", }) @@ -2743,7 +2747,7 @@ local function register_decorations() biomes = {"Taiga", "ColdTaiga"}, y_min = 3, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_spruce_matchstick.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_spruce_matchstick.mts", flags = "place_center_x, place_center_z", }) @@ -2763,7 +2767,7 @@ local function register_decorations() biomes = {"IcePlains"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_spruce_5.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_spruce_5.mts", flags = "place_center_x, place_center_z", }) @@ -2777,7 +2781,7 @@ local function register_decorations() biomes = {"Savanna", "SavannaM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_acacia_"..a..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_acacia_"..a..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2799,7 +2803,7 @@ local function register_decorations() biomes = {"BirchForest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_birch.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_birch.mts", flags = "place_center_x, place_center_z", }) minetest.register_decoration({ @@ -2817,7 +2821,7 @@ local function register_decorations() biomes = {"BirchForestM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_birch_tall.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_birch_tall.mts", flags = "place_center_x, place_center_z", }) @@ -2836,7 +2840,7 @@ local function register_decorations() biomes = {"Forest", "FlowerForest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_birch.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_birch.mts", flags = "place_center_x, place_center_z", }) @@ -2856,7 +2860,7 @@ local function register_decorations() biomes = {"RoofedForest"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_dark_oak.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_dark_oak.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2878,7 +2882,7 @@ local function register_decorations() biomes = { "RoofedForest" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_brown.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_huge_brown.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2890,7 +2894,7 @@ local function register_decorations() biomes = { "RoofedForest" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_giant_brown.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_giant_brown.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2903,7 +2907,7 @@ local function register_decorations() biomes = { "MushroomIsland", "MushroomIslandShore" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_brown.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_huge_brown.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2915,7 +2919,7 @@ local function register_decorations() biomes = { "MushroomIsland", "MushroomIslandShore" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_giant_brown.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_giant_brown.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2929,7 +2933,7 @@ local function register_decorations() biomes = { "RoofedForest" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_red.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_huge_red.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2941,7 +2945,7 @@ local function register_decorations() biomes = { "RoofedForest" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_giant_red.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_giant_red.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2954,7 +2958,7 @@ local function register_decorations() biomes = { "MushroomIsland", "MushroomIslandShore" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_red.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_huge_red.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2966,7 +2970,7 @@ local function register_decorations() biomes = { "MushroomIsland", "MushroomIslandShore" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_giant_red.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_giant_red.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2987,7 +2991,7 @@ local function register_decorations() biomes = {"MegaTaiga", "MegaSpruceTaiga"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder.mts", + schematic = mod_mcl_structures.."/schematics/mcl_structures_boulder.mts", flags = "place_center_x, place_center_z", }) @@ -3007,7 +3011,7 @@ local function register_decorations() biomes = {"MegaTaiga", "MegaSpruceTaiga"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder_small.mts", + schematic = mod_mcl_structures.."/schematics/mcl_structures_boulder_small.mts", flags = "place_center_x, place_center_z", }) @@ -3079,7 +3083,7 @@ local function register_decorations() }) -- Doubletall grass - local register_doubletall_grass = function(offset, scale, biomes) + local function register_doubletall_grass(offset, scale, biomes) for b=1, #biomes do local param2 = minetest.registered_biomes[biomes[b]]._mcl_palette_index @@ -3115,7 +3119,7 @@ local function register_decorations() register_doubletall_grass(-0.0005, -0.03, {"Savanna", "SavannaM"}) -- Large ferns - local register_double_fern = function(offset, scale, biomes) + local function register_double_fern(offset, scale, biomes) for b=1, #biomes do local param2 = minetest.registered_biomes[biomes[b]]._mcl_palette_index minetest.register_decoration({ @@ -3149,7 +3153,7 @@ local function register_decorations() register_double_fern(0.15, 0.1, { "JungleM" }) -- Large flowers - local register_large_flower = function(name, biomes, seed, offset, flower_forest_offset) + local function register_large_flower(name, biomes, seed, offset, flower_forest_offset) local maxi if flower_forest_offset then maxi = 2 @@ -3580,7 +3584,8 @@ local function register_decorations() local fern_minimal = { "Jungle", "JungleM", "JungleEdge", "JungleEdgeM", "Taiga", "MegaTaiga", "MegaSpruceTaiga", "ColdTaiga" } local fern_low = { "Jungle", "JungleM", "JungleEdge", "JungleEdgeM", "Taiga", "MegaTaiga", "MegaSpruceTaiga" } local fern_Jungle = { "Jungle", "JungleM", "JungleEdge", "JungleEdgeM" } - local fern_JungleM = { "JungleM" }, + --local fern_JungleM = { "JungleM" }, + register_grass_decoration("fern", -0.03, 0.09, fern_minimal) register_grass_decoration("fern", -0.015, 0.075, fern_minimal) register_grass_decoration("fern", 0, 0.06, fern_minimal) @@ -3591,7 +3596,7 @@ local function register_decorations() register_grass_decoration("fern", 0.05, 0.01, fern_Jungle) register_grass_decoration("fern", 0.07, -0.01, fern_Jungle) register_grass_decoration("fern", 0.09, -0.03, fern_Jungle) - register_grass_decoration("fern", 0.12, -0.03, fern_JungleM) + register_grass_decoration("fern", 0.12, -0.03, {"JungleM"}) local b_seagrass = {"ColdTaiga_ocean","ExtremeHills_ocean","ExtremeHillsM_ocean","ExtremeHills+_ocean","Taiga_ocean","MegaTaiga_ocean","MegaSpruceTaiga_ocean","StoneBeach_ocean","Plains_ocean","SunflowerPlains_ocean","Forest_ocean","FlowerForest_ocean","BirchForest_ocean","BirchForestM_ocean","RoofedForest_ocean","Swampland_ocean","Jungle_ocean","JungleM_ocean","JungleEdge_ocean","JungleEdgeM_ocean","MushroomIsland_ocean","Desert_ocean","Savanna_ocean","SavannaM_ocean","Mesa_ocean","MesaBryce_ocean","MesaPlateauF_ocean","MesaPlateauFM_ocean", "ColdTaiga_deep_ocean","ExtremeHills_deep_ocean","ExtremeHillsM_deep_ocean","ExtremeHills+_deep_ocean","Taiga_deep_ocean","MegaTaiga_deep_ocean","MegaSpruceTaiga_deep_ocean","StoneBeach_deep_ocean","Plains_deep_ocean","SunflowerPlains_deep_ocean","Forest_deep_ocean","FlowerForest_deep_ocean","BirchForest_deep_ocean","BirchForestM_deep_ocean","RoofedForest_deep_ocean","Swampland_deep_ocean","Jungle_deep_ocean","JungleM_deep_ocean","JungleEdge_deep_ocean","JungleEdgeM_deep_ocean","MushroomIsland_deep_ocean","Desert_deep_ocean","Savanna_deep_ocean","SavannaM_deep_ocean","Mesa_deep_ocean","MesaBryce_deep_ocean","MesaPlateauF_deep_ocean","MesaPlateauFM_deep_ocean", @@ -3906,7 +3911,7 @@ end -- Decorations in non-Overworld dimensions local function register_dimension_decorations() --[[ NETHER ]] - -- TODO: Nether + -- TODO: Nether --[[ THE END ]] @@ -3973,10 +3978,17 @@ if mg_name ~= "singlenode" then if deco_id_chorus_plant then mcl_mapgen_core.register_generator("chorus_grow", nil, function(minp, maxp, blockseed) local gennotify = minetest.get_mapgen_object("gennotify") - local poslist = {} + --local poslist = {} + local pr = PseudoRandom(blockseed + 14) for _, pos in ipairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do - local realpos = { x = pos.x, y = pos.y + 1, z = pos.z } - mcl_end.grow_chorus_plant(realpos) + local x, y, z = pos.x, pos.y, pos.z + if x < -2 or x > 2 or z < -2 or z > 2 then + local realpos = { x = x, y = y + 1, z = z } + local node = minetest.get_node(realpos) + if node and node.name == "mcl_end:chorus_flower" then + mcl_end.grow_chorus_plant(realpos, node, pr) + end + end end end) end diff --git a/mods/MAPGEN/mcl_dungeons/init.lua b/mods/MAPGEN/mcl_dungeons/init.lua index dc9c6d61..58e23b12 100644 --- a/mods/MAPGEN/mcl_dungeons/init.lua +++ b/mods/MAPGEN/mcl_dungeons/init.lua @@ -9,15 +9,38 @@ if mcl_vars.mg_dungeons == false or mg_name == "singlenode" then return end -local min_y = math.max(mcl_vars.mg_overworld_min, mcl_vars.mg_bedrock_overworld_max) + 1 -local max_y = mcl_vars.mg_overworld_max - 1 +--lua locals +--minetest +local registered_nodes = minetest.registered_nodes +local swap_node = minetest.swap_node +local set_node = minetest.set_node +local dir_to_facedir = minetest.dir_to_facedir +local get_meta = minetest.get_meta +local emerge_area = minetest.emerge_area +--vector +local vector_add = vector.add +local vector_subtract = vector.subtract + +--table +local table_insert = table.insert +local table_sort = table.sort + +--math +local math_min = math.min +local math_max = math.max +local math_ceil = math.ceil + +--custom mcl_vars local get_node = mcl_vars.get_node + +local min_y = math_max(mcl_vars.mg_overworld_min, mcl_vars.mg_bedrock_overworld_max) + 1 +local max_y = mcl_vars.mg_overworld_max - 1 -- Calculate the number of dungeon spawn attempts -- In Minecraft, there 8 dungeon spawn attempts Minecraft chunk (16*256*16 = 65536 blocks). -- Minetest chunks don't have this size, so scale the number accordingly. -local attempts = math.ceil(((mcl_vars.chunksize * mcl_vars.MAP_BLOCKSIZE) ^ 3) / 8192) -- 63 = 80*80*80/8192 +local attempts = math_ceil(((mcl_vars.chunksize * mcl_vars.MAP_BLOCKSIZE) ^ 3) / 8192) -- 63 = 80*80*80/8192 local dungeonsizes = { { x=5, y=4, z=5}, @@ -26,12 +49,12 @@ local dungeonsizes = { { x=7, y=4, z=7}, } -local dirs = { +--[[local dirs = { { x= 1, y=0, z= 0 }, { x= 0, y=0, z= 1 }, { x=-1, y=0, z= 0 }, { x= 0, y=0, z=-1 }, -} +}]] local surround_vectors = { { x=-1, y=0, z=0 }, @@ -43,7 +66,7 @@ local surround_vectors = { local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) if calls_remaining >= 1 then return end - local p1, p2, dim, pr = param.p1, param.p2, param.dim, param.pr + local p1, _, dim, pr = param.p1, param.p2, param.dim, param.pr local x, y, z = p1.x, p1.y, p1.z local check = not (param.dontcheck or false) @@ -51,8 +74,8 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) local y_floor = y local y_ceiling = y + dim.y + 1 if check then for tx = x+1, x+dim.x do for tz = z+1, z+dim.z do - if not minetest.registered_nodes[get_node({x = tx, y = y_floor , z = tz}).name].walkable - or not minetest.registered_nodes[get_node({x = tx, y = y_ceiling, z = tz}).name].walkable then return false end + if not registered_nodes[get_node({x = tx, y = y_floor , z = tz}).name].walkable + or not registered_nodes[get_node({x = tx, y = y_ceiling, z = tz}).name].walkable then return false end end end end -- Check for air openings (2 stacked air at ground level) in wall positions @@ -69,25 +92,25 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) openings_counter = openings_counter + 1 if not openings[x] then openings[x]={} end openings[x][z] = true - table.insert(corners, {x=x, z=z}) + table_insert(corners, {x=x, z=z}) end if get_node({x=x2, y=y+1, z=z}).name == "air" and get_node({x=x2, y=y+2, z=z}).name == "air" then openings_counter = openings_counter + 1 if not openings[x2] then openings[x2]={} end openings[x2][z] = true - table.insert(corners, {x=x2, z=z}) + table_insert(corners, {x=x2, z=z}) end if get_node({x=x, y=y+1, z=z2}).name == "air" and get_node({x=x, y=y+2, z=z2}).name == "air" then openings_counter = openings_counter + 1 if not openings[x] then openings[x]={} end openings[x][z2] = true - table.insert(corners, {x=x, z=z2}) + table_insert(corners, {x=x, z=z2}) end if get_node({x=x2, y=y+1, z=z2}).name == "air" and get_node({x=x2, y=y+2, z=z2}).name == "air" then openings_counter = openings_counter + 1 if not openings[x2] then openings[x2]={} end openings[x2][z2] = true - table.insert(corners, {x=x2, z=z2}) + table_insert(corners, {x=x2, z=z2}) end for wx = x+1, x+dim.x do @@ -180,16 +203,16 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) secondChance = false end lastRandom = r - table.insert(chestSlots, r) + table_insert(chestSlots, r) end - table.sort(chestSlots) + table_sort(chestSlots) local currentChest = 1 -- Calculate the mob spawner position, to be re-used for later - local sp = {x = x + math.ceil(dim.x/2), y = y+1, z = z + math.ceil(dim.z/2)} - local rn = minetest.registered_nodes[get_node(sp).name] + local sp = {x = x + math_ceil(dim.x/2), y = y+1, z = z + math_ceil(dim.z/2)} + local rn = registered_nodes[get_node(sp).name] if rn and rn.is_ground_content then - table.insert(spawner_posses, sp) + table_insert(spawner_posses, sp) end -- Generate walls and floor @@ -203,13 +226,13 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) -- Do not overwrite nodes with is_ground_content == false (e.g. bedrock) -- Exceptions: cobblestone and mossy cobblestone so neighborings dungeons nicely connect to each other local name = get_node(p).name - if minetest.registered_nodes[name].is_ground_content or name == "mcl_core:cobble" or name == "mcl_core:mossycobble" then + if registered_nodes[name].is_ground_content or name == "mcl_core:cobble" or name == "mcl_core:mossycobble" then -- Floor if ty == y then if pr:next(1,4) == 1 then - minetest.swap_node(p, {name = "mcl_core:cobble"}) + swap_node(p, {name = "mcl_core:cobble"}) else - minetest.swap_node(p, {name = "mcl_core:mossycobble"}) + swap_node(p, {name = "mcl_core:mossycobble"}) end -- Generate walls @@ -221,14 +244,14 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) -- Check if it's an opening first if (ty == maxy) or (not (openings[tx] and openings[tx][tz])) then -- Place wall or ceiling - minetest.swap_node(p, {name = "mcl_core:cobble"}) + swap_node(p, {name = "mcl_core:cobble"}) elseif ty < maxy - 1 then -- Normally the openings are already clear, but not if it is a corner -- widening. Make sure to clear at least the bottom 2 nodes of an opening. - if name ~= "air" then minetest.swap_node(p, {name = "air"}) end + if name ~= "air" then swap_node(p, {name = "air"}) end elseif name ~= "air" then -- This allows for variation between 2-node and 3-node high openings. - minetest.swap_node(p, {name = "mcl_core:cobble"}) + swap_node(p, {name = "mcl_core:cobble"}) end -- If it was an opening, the lower 3 blocks are not touched at all @@ -236,9 +259,9 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) else if (ty==y+1) and (tx==x+1 or tx==maxx-1 or tz==z+1 or tz==maxz-1) and (currentChest < totalChests + 1) and (chestSlots[currentChest] == chestSlotCounter) then currentChest = currentChest + 1 - table.insert(chests, {x=tx, y=ty, z=tz}) + table_insert(chests, {x=tx, y=ty, z=tz}) else - minetest.swap_node(p, {name = "air"}) + swap_node(p, {name = "air"}) end local forChest = ty==y+1 and (tx==x+1 or tx==maxx-1 or tz==z+1 or tz==maxz-1) @@ -246,9 +269,9 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) -- Place next chest at the wall (if it was its chosen wall slot) if forChest and (currentChest < totalChests + 1) and (chestSlots[currentChest] == chestSlotCounter) then currentChest = currentChest + 1 - table.insert(chests, {x=tx, y=ty, z=tz}) + table_insert(chests, {x=tx, y=ty, z=tz}) -- else - --minetest.swap_node(p, {name = "air"}) + --swap_node(p, {name = "air"}) end if forChest then chestSlotCounter = chestSlotCounter + 1 @@ -263,15 +286,15 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) local surroundings = {} for s=1, #surround_vectors do -- Detect the 4 horizontal neighbors - local spos = vector.add(pos, surround_vectors[s]) - local wpos = vector.subtract(pos, surround_vectors[s]) + local spos = vector_add(pos, surround_vectors[s]) + local wpos = vector_subtract(pos, surround_vectors[s]) local nodename = get_node(spos).name local nodename2 = get_node(wpos).name - local nodedef = minetest.registered_nodes[nodename] - local nodedef2 = minetest.registered_nodes[nodename2] + local nodedef = registered_nodes[nodename] + local nodedef2 = registered_nodes[nodename2] -- The chest needs an open space in front of it and a walkable node (except chest) behind it if nodedef and nodedef.walkable == false and nodedef2 and nodedef2.walkable == true and nodename2 ~= "mcl_chests:chest" then - table.insert(surroundings, spos) + table_insert(surroundings, spos) end end -- Set param2 (=facedir) of this chest @@ -282,11 +305,11 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) else -- 1 or multiple possible open directions: Choose random facedir local face_to = surroundings[pr:next(1, #surroundings)] - facedir = minetest.dir_to_facedir(vector.subtract(pos, face_to)) + facedir = dir_to_facedir(vector_subtract(pos, face_to)) end - minetest.set_node(pos, {name="mcl_chests:chest", param2=facedir}) - local meta = minetest.get_meta(pos) + set_node(pos, {name="mcl_chests:chest", param2=facedir}) + local meta = get_meta(pos) local loottable = { @@ -336,7 +359,7 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) -- Bonus loot for v6 mapgen: Otherwise unobtainable saplings. if mg_name == "v6" then - table.insert(loottable, { + table_insert(loottable, { stacks_min = 1, stacks_max = 3, items = { @@ -356,7 +379,7 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) for s=#spawner_posses, 1, -1 do local sp = spawner_posses[s] -- ... and place it and select a random mob - minetest.set_node(sp, {name = "mcl_mobspawners:spawner"}) + set_node(sp, {name = "mcl_mobspawners:spawner"}) local mobs = { "mobs_mc:zombie", "mobs_mc:zombie", @@ -370,7 +393,7 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) end local function dungeons_nodes(minp, maxp, blockseed) - local ymin, ymax = math.max(min_y, minp.y), math.min(max_y, maxp.y) + local ymin, ymax = math_max(min_y, minp.y), math_min(max_y, maxp.y) if ymax < ymin then return false end local pr = PseudoRandom(blockseed) for a=1, attempts do @@ -381,8 +404,7 @@ local function dungeons_nodes(minp, maxp, blockseed) local p1 = {x=x,y=y,z=z} local p2 = {x = x+dim.x+1, y = y+dim.y+1, z = z+dim.z+1} minetest.log("verbose","[mcl_dungeons] size=" ..minetest.pos_to_string(dim) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2)) - local param = {p1=p1, p2=p2, dim=dim, pr=pr} - minetest.emerge_area(p1, p2, ecb_spawn_dungeon, param) + emerge_area(p1, p2, ecb_spawn_dungeon, {p1=p1, p2=p2, dim=dim, pr=pr}) end end @@ -391,8 +413,7 @@ function mcl_dungeons.spawn_dungeon(p1, _, pr) local dim = dungeonsizes[pr:next(1, #dungeonsizes)] local p2 = {x = p1.x+dim.x+1, y = p1.y+dim.y+1, z = p1.z+dim.z+1} minetest.log("verbose","[mcl_dungeons] size=" ..minetest.pos_to_string(dim) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2)) - local param = {p1=p1, p2=p2, dim=dim, pr=pr, dontcheck=true} - minetest.emerge_area(p1, p2, ecb_spawn_dungeon, param) + emerge_area(p1, p2, ecb_spawn_dungeon, {p1=p1, p2=p2, dim=dim, pr=pr, dontcheck=true}) end mcl_mapgen_core.register_generator("dungeons", nil, dungeons_nodes, 999999) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 1ee861e4..41bee508 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -65,21 +65,21 @@ local c_dirt = minetest.get_content_id("mcl_core:dirt") local c_dirt_with_grass = minetest.get_content_id("mcl_core:dirt_with_grass") local c_dirt_with_grass_snow = minetest.get_content_id("mcl_core:dirt_with_grass_snow") local c_sand = minetest.get_content_id("mcl_core:sand") -local c_sandstone = minetest.get_content_id("mcl_core:sandstone") +--local c_sandstone = minetest.get_content_id("mcl_core:sandstone") local c_void = minetest.get_content_id("mcl_core:void") local c_lava = minetest.get_content_id("mcl_core:lava_source") local c_water = minetest.get_content_id("mcl_core:water_source") local c_soul_sand = minetest.get_content_id("mcl_nether:soul_sand") local c_netherrack = minetest.get_content_id("mcl_nether:netherrack") local c_nether_lava = minetest.get_content_id("mcl_nether:nether_lava_source") -local c_end_stone = minetest.get_content_id("mcl_end:end_stone") +--local c_end_stone = minetest.get_content_id("mcl_end:end_stone") local c_realm_barrier = minetest.get_content_id("mcl_core:realm_barrier") local c_top_snow = minetest.get_content_id("mcl_core:snow") local c_snow_block = minetest.get_content_id("mcl_core:snowblock") local c_clay = minetest.get_content_id("mcl_core:clay") local c_leaves = minetest.get_content_id("mcl_core:leaves") local c_jungleleaves = minetest.get_content_id("mcl_core:jungleleaves") -local c_jungletree = minetest.get_content_id("mcl_core:jungletree") +--local c_jungletree = minetest.get_content_id("mcl_core:jungletree") local c_cocoa_1 = minetest.get_content_id("mcl_cocoas:cocoa_1") local c_cocoa_2 = minetest.get_content_id("mcl_cocoas:cocoa_2") local c_cocoa_3 = minetest.get_content_id("mcl_cocoas:cocoa_3") @@ -765,7 +765,7 @@ local function register_mgv6_decorations() }) -- Large flowers - local register_large_flower = function(name, seed, offset) + local function register_large_flower(name, seed, offset) minetest.register_decoration({ deco_type = "schematic", schematic = { @@ -1169,18 +1169,18 @@ end -- minp and maxp (from an on_generated callback) and returns the real world coordinates -- as X, Z. -- Inverse function of xz_to_biomemap -local biomemap_to_xz = function(index, minp, maxp) +--[[local function biomemap_to_xz(index, minp, maxp) local xwidth = maxp.x - minp.x + 1 local zwidth = maxp.z - minp.z + 1 local x = ((index-1) % xwidth) + minp.x local z = ((index-1) / zwidth) + minp.z return x, z -end +end]] -- Takes x and z coordinates and minp and maxp of a generated chunk -- (in on_generated callback) and returns a biomemap index) -- Inverse function of biomemap_to_xz -local xz_to_biomemap_index = function(x, z, minp, maxp) +local function xz_to_biomemap_index(x, z, minp, maxp) local xwidth = maxp.x - minp.x + 1 local zwidth = maxp.z - minp.z + 1 local minix = x % xwidth @@ -1248,9 +1248,14 @@ local function generate_clay(minp, maxp, blockseed, voxelmanip_data, voxelmanip_ end local function generate_end_exit_portal(pos) - local dragon_entity = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon"):get_luaentity() - dragon_entity._initial = true - dragon_entity._portal_pos = pos + local obj = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon") + if obj then + local dragon_entity = obj:get_luaentity() + dragon_entity._initial = true + dragon_entity._portal_pos = pos + else + minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") + end mcl_structures.call_struct(pos, "end_exit_portal") end @@ -1399,7 +1404,7 @@ local function generate_structures(minp, maxp, blockseed, biomemap) -- TODO: Spawn witch in or around hut when the mob sucks less. - local place_tree_if_free = function(pos, prev_result) + local function place_tree_if_free(pos, prev_result) local nn = minetest.get_node(pos).name if nn == "mcl_flowers:waterlily" or nn == "mcl_core:water_source" or nn == "mcl_core:water_flowing" or nn == "air" then minetest.set_node(pos, {name="mcl_core:tree", param2=0}) @@ -1594,7 +1599,7 @@ local function generate_tree_decorations(minp, maxp, seed, data, param2_data, ar if dir < 5 and data[p_pos] == c_air - and l ~= nil and l > 12 then + and l and l > 12 then local c = pr:next(1, 3) if c == 1 then data[p_pos] = c_cocoa_1 @@ -1715,7 +1720,7 @@ end -- Generate mushrooms in caves manually. -- Minetest's API does not support decorations in caves yet. :-( -local generate_underground_mushrooms = function(minp, maxp, seed) +local function generate_underground_mushrooms(minp, maxp, seed) local pr_shroom = PseudoRandom(seed-24359) -- Generate rare underground mushrooms -- TODO: Make them appear in groups, use Perlin noise @@ -1731,7 +1736,7 @@ local generate_underground_mushrooms = function(minp, maxp, seed) bpos = {x = stone[n].x, y = stone[n].y + 1, z = stone[n].z } local l = minetest.get_node_light(bpos, 0.5) - if bpos.y >= min and bpos.y <= max and l ~= nil and l <= 12 and pr_shroom:next(1,1000) < 4 then + if bpos.y >= min and bpos.y <= max and l and l <= 12 and pr_shroom:next(1,1000) < 4 then if pr_shroom:next(1,2) == 1 then minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) else @@ -1749,7 +1754,7 @@ else end -- Generate Nether decorations manually: Eternal fire, mushrooms, nether wart -- Minetest's API does not support decorations in caves yet. :-( -local generate_nether_decorations = function(minp, maxp, seed) +local function generate_nether_decorations(minp, maxp, seed) local pr_nether = PseudoRandom(seed+667) if minp.y > mcl_vars.mg_nether_max or maxp.y < mcl_vars.mg_nether_min then @@ -1766,7 +1771,7 @@ local generate_nether_decorations = function(minp, maxp, seed) local ssand = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:soul_sand"}) -- Helper function to spawn “fake” decoration - local special_deco = function(nodes, spawn_func) + local function special_deco(nodes, spawn_func) for n = 1, #nodes do bpos = {x = nodes[n].x, y = nodes[n].y + 1, z = nodes[n].z } @@ -1794,7 +1799,7 @@ local generate_nether_decorations = function(minp, maxp, seed) -- Note: Spawned *after* the fire because of light level checks special_deco(rack, function(bpos) local l = minetest.get_node_light(bpos, 0.5) - if bpos.y > mcl_vars.mg_lava_nether_max + 6 and l ~= nil and l <= 12 and pr_nether:next(1,1000) <= 4 then + if bpos.y > mcl_vars.mg_lava_nether_max + 6 and l and l <= 12 and pr_nether:next(1,1000) <= 4 then -- TODO: Make mushrooms appear in groups, use Perlin noise if pr_nether:next(1,2) == 1 then minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) @@ -1864,7 +1869,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed) mcl_vars.add_chunk(minp) end) -minetest.register_on_generated=function(node_function) +function minetest.register_on_generated(node_function) mcl_mapgen_core.register_generator("mod_"..tostring(#registered_generators+1), nil, node_function) end @@ -1885,11 +1890,9 @@ function mcl_mapgen_core.register_generator(id, lvm_function, node_function, pri } registered_generators[id] = new_record - table.sort( - registered_generators, - function(a, b) - return (a.i < b.i) or ((a.i == b.i) and (a.vf ~= nil) and (b.vf == nil)) - end) + table.sort(registered_generators, function(a, b) + return (a.i < b.i) or ((a.i == b.i) and a.vf and (b.vf == nil)) + end) end function mcl_mapgen_core.unregister_generator(id) @@ -1897,9 +1900,9 @@ function mcl_mapgen_core.unregister_generator(id) local rec = registered_generators[id] registered_generators[id] = nil if rec.vf then lvm = lvm - 1 end - if rev.nf then nodes = nodes - 1 end + if rec.nf then nodes = nodes - 1 end if rec.needs_param2 then param2 = param2 - 1 end - if rec.needs_level0 then level0 = level0 - 1 end + --if rec.needs_level0 then level0 = level0 - 1 end end -- Generate basic layer-based nodes: void, bedrock, realm barrier, lava seas, etc. @@ -1907,7 +1910,7 @@ end local bedrock_check if mcl_vars.mg_bedrock_is_rough then - bedrock_check = function(pos, _, pr) + function bedrock_check(pos, _, pr) local y = pos.y -- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer -- This code assumes a bedrock height of 5 layers. @@ -1979,7 +1982,7 @@ end -- Below the bedrock, generate air/void local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) - local biomemap, ymin, ymax + local biomemap --ymin, ymax local lvm_used = false local pr = PseudoRandom(blockseed) @@ -2077,7 +2080,7 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local n = nodes[n] local p_pos = area:index(n.x, n.y, n.z) local p_pos_above = area:index(n.x, n.y+1, n.z) - local p_pos_below = area:index(n.x, n.y-1, n.z) + --local p_pos_below = area:index(n.x, n.y-1, n.z) local b_pos = aream:index(n.x, 0, n.z) local bn = minetest.get_biome_name(biomemap[b_pos]) if bn then @@ -2126,7 +2129,7 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) -- * Remove stone, sand, dirt in v6 so our End map generator works in v6. -- * Generate spawn platform (End portal destination) elseif minp.y <= mcl_vars.mg_end_max and maxp.y >= mcl_vars.mg_end_min then - local nodes, n + local nodes if mg_name == "v6" then nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"}) else @@ -2134,7 +2137,7 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) end if #nodes > 0 then lvm_used = true - for _, n in pairs(nodes) do + for _,n in pairs(nodes) do data[area:index(n.x, n.y, n.z)] = c_air end end @@ -2144,8 +2147,8 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and minp.z <= mcl_vars.mg_end_platform_pos.z and maxp.z >= mcl_vars.mg_end_platform_pos.z then - local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} - local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} + --local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} + --local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} for x=math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2) do for z=math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2), math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2) do diff --git a/mods/MAPGEN/mcl_strongholds/init.lua b/mods/MAPGEN/mcl_strongholds/init.lua index e465b2e4..083172a3 100644 --- a/mods/MAPGEN/mcl_strongholds/init.lua +++ b/mods/MAPGEN/mcl_strongholds/init.lua @@ -25,7 +25,7 @@ local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superfl -- The stronghold positions are based on the world seed. -- The actual position might be offset by a few blocks because it might be shifted -- to make sure the end portal room is completely within the boundaries of a mapchunk. -local init_strongholds = function() +local function init_strongholds() if strongholds_inited then return end @@ -67,7 +67,7 @@ local init_strongholds = function() end -- Stronghold generation for register_on_generated. -local generate_strongholds = function(minp, maxp, blockseed) +local function generate_strongholds(minp, maxp, blockseed) local pr = PseudoRandom(blockseed) for s=1, #strongholds do if not strongholds[s].generated then diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index b7afd18b..8efdd91b 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -1,5 +1,9 @@ -local S = minetest.get_translator("mcl_structures") -mcl_structures ={} +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) +local modpath = minetest.get_modpath(modname) + +mcl_structures = {} + local rotations = { "0", "90", @@ -14,8 +18,9 @@ local function ecb_place(blockpos, action, calls_remaining, param) param.after_placement_callback(param.p1, param.p2, param.size, param.rotation, param.pr, param.callback_param) end end -mcl_structures.place_schematic = function(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr, callback_param) - local s = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return(schematic)")() + +function mcl_structures.place_schematic(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr, callback_param) + local s = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic")() if s and s.size then local x, z = s.size.x, s.size.z if rotation then @@ -31,17 +36,17 @@ mcl_structures.place_schematic = function(pos, schematic, rotation, replacements end local p1 = {x=pos.x , y=pos.y , z=pos.z } local p2 = {x=pos.x+x-1, y=pos.y+s.size.y-1, z=pos.z+z-1} - minetest.log("verbose","[mcl_structures] size=" ..minetest.pos_to_string(s.size) .. ", rotation=" .. tostring(rotation) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2)) + minetest.log("verbose", "[mcl_structures] size=" ..minetest.pos_to_string(s.size) .. ", rotation=" .. tostring(rotation) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2)) local param = {pos=vector.new(pos), schematic=s, rotation=rotation, replacements=replacements, force_placement=force_placement, flags=flags, p1=p1, p2=p2, after_placement_callback = after_placement_callback, size=vector.new(s.size), pr=pr, callback_param=callback_param} minetest.emerge_area(p1, p2, ecb_place, param) end end -mcl_structures.get_struct = function(file) - local localfile = minetest.get_modpath("mcl_structures").."/schematics/"..file +function mcl_structures.get_struct(file) + local localfile = modpath.."/schematics/"..file local file, errorload = io.open(localfile, "rb") - if errorload ~= nil then - minetest.log("error", '[mcl_structures] Could not open this struct: ' .. localfile) + if errorload then + minetest.log("error", "[mcl_structures] Could not open this struct: "..localfile) return nil end @@ -53,7 +58,7 @@ end -- Call on_construct on pos. -- Useful to init chests from formspec. -local init_node_construct = function(pos) +local function init_node_construct(pos) local node = minetest.get_node(pos) local def = minetest.registered_nodes[node.name] if def and def.on_construct then @@ -64,7 +69,7 @@ local init_node_construct = function(pos) end -- The call of Struct -mcl_structures.call_struct = function(pos, struct_style, rotation, pr) +function mcl_structures.call_struct(pos, struct_style, rotation, pr) minetest.log("action","[mcl_structures] call_struct " .. struct_style.." at "..minetest.pos_to_string(pos)) if not rotation then rotation = "random" @@ -96,13 +101,13 @@ mcl_structures.call_struct = function(pos, struct_style, rotation, pr) end end -mcl_structures.generate_desert_well = function(pos, rot) +function mcl_structures.generate_desert_well(pos, rot) local newpos = {x=pos.x,y=pos.y-2,z=pos.z} - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_well.mts" + local path = modpath.."/schematics/mcl_structures_desert_well.mts" return mcl_structures.place_schematic(newpos, path, rot or "0", nil, true) end -mcl_structures.generate_igloo = function(pos, rotation, pr) +function mcl_structures.generate_igloo(pos, rotation, pr) -- Place igloo local success, rotation = mcl_structures.generate_igloo_top(pos, pr) -- Place igloo basement with 50% chance @@ -110,7 +115,8 @@ mcl_structures.generate_igloo = function(pos, rotation, pr) if r == 1 then -- Select basement depth local dim = mcl_worlds.pos_to_dimension(pos) - local buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10) + --local buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10) + local buffer if dim == "nether" then buffer = pos.y - (mcl_vars.mg_lava_nether_max + 10) elseif dim == "end" then @@ -147,7 +153,7 @@ mcl_structures.generate_igloo = function(pos, rotation, pr) else return success end - local set_brick = function(pos) + local function set_brick(pos) local c = pr:next(1, 3) -- cracked chance local m = pr:next(1, 10) -- chance for monster egg local brick @@ -197,11 +203,11 @@ mcl_structures.generate_igloo = function(pos, rotation, pr) return success end -mcl_structures.generate_igloo_top = function(pos, pr) +function mcl_structures.generate_igloo_top(pos, pr) -- FIXME: This spawns bookshelf instead of furnace. Fix this! -- Furnace does ot work atm because apparently meta is not set. :-( local newpos = {x=pos.x,y=pos.y-1,z=pos.z} - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_igloo_top.mts" + local path = modpath.."/schematics/mcl_structures_igloo_top.mts" local rotation = tostring(pr:next(0,3)*90) return mcl_structures.place_schematic(newpos, path, rotation, nil, true), rotation end @@ -219,7 +225,7 @@ local function igloo_placement_callback(p1, p2, size, orientation, pr) else return end - local size = {x=9,y=5,z=7} + --local size = {x=9,y=5,z=7} local lootitems = mcl_loot.get_multi_loot({ { stacks_min = 1, @@ -249,22 +255,22 @@ local function igloo_placement_callback(p1, p2, size, orientation, pr) mcl_loot.fill_inventory(inv, "main", lootitems, pr) end -mcl_structures.generate_igloo_basement = function(pos, orientation, pr) +function mcl_structures.generate_igloo_basement(pos, orientation, pr) -- TODO: Add brewing stand -- TODO: Add monster eggs -- TODO: Spawn villager and zombie villager - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_igloo_basement.mts" + local path = modpath.."/schematics/mcl_structures_igloo_basement.mts" mcl_structures.place_schematic(pos, path, orientation, nil, true, nil, igloo_placement_callback, pr) end -mcl_structures.generate_boulder = function(pos, rotation, pr) +function mcl_structures.generate_boulder(pos, rotation, pr) -- Choose between 2 boulder sizes (2×2×2 or 3×3×3) local r = pr:next(1, 10) local path if r <= 3 then - path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder_small.mts" + path = modpath.."/schematics/mcl_structures_boulder_small.mts" else - path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder.mts" + path = modpath.."/schematics/mcl_structures_boulder.mts" end local newpos = {x=pos.x,y=pos.y-1,z=pos.z} @@ -283,22 +289,22 @@ local function hut_placement_callback(p1, p2, size, orientation, pr) end end -mcl_structures.generate_witch_hut = function(pos, rotation, pr) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_witch_hut.mts" +function mcl_structures.generate_witch_hut(pos, rotation, pr) + local path = modpath.."/schematics/mcl_structures_witch_hut.mts" mcl_structures.place_schematic(pos, path, rotation, nil, true, nil, hut_placement_callback, pr) end -mcl_structures.generate_ice_spike_small = function(pos, rotation) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_small.mts" +function mcl_structures.generate_ice_spike_small(pos, rotation) + local path = modpath.."/schematics/mcl_structures_ice_spike_small.mts" return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0 end -mcl_structures.generate_ice_spike_large = function(pos, rotation) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_large.mts" +function mcl_structures.generate_ice_spike_large(pos, rotation) + local path = modpath.."/schematics/mcl_structures_ice_spike_large.mts" return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0 end -mcl_structures.generate_fossil = function(pos, rotation, pr) +function mcl_structures.generate_fossil(pos, rotation, pr) -- Generates one out of 8 possible fossil pieces local newpos = {x=pos.x,y=pos.y-1,z=pos.z} local fossils = { @@ -312,22 +318,22 @@ mcl_structures.generate_fossil = function(pos, rotation, pr) "mcl_structures_fossil_spine_4.mts", -- 8×5×13 } local r = pr:next(1, #fossils) - local path = minetest.get_modpath("mcl_structures").."/schematics/"..fossils[r] + local path = modpath.."/schematics/"..fossils[r] return mcl_structures.place_schematic(newpos, path, rotation or "random", nil, true) end -mcl_structures.generate_end_exit_portal = function(pos, rot) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts" +function mcl_structures.generate_end_exit_portal(pos, rot) + local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true) end -mcl_structures.generate_end_exit_portal_open = function(pos, rot) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts" +function mcl_structures.generate_end_exit_portal_open(pos, rot) + local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) end -mcl_structures.generate_end_gateway_portal = function(pos, rot) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts" +function mcl_structures.generate_end_gateway_portal(pos, rot) + local path = modpath.."/schematics/mcl_structures_end_gateway_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) end @@ -335,7 +341,7 @@ local function shrine_placement_callback(p1, p2, size, rotation, pr) -- Find and setup spawner with silverfish local spawners = minetest.find_nodes_in_area(p1, p2, "mcl_mobspawners:spawner") for s=1, #spawners do - local meta = minetest.get_meta(spawners[s]) + --local meta = minetest.get_meta(spawners[s]) mcl_mobspawners.setup_spawner(spawners[s], "mobs_mc:silverfish") end @@ -361,7 +367,7 @@ local function shrine_placement_callback(p1, p2, size, rotation, pr) end -- 50% stonebrick (no change necessary) end - if bricktype ~= nil then + if bricktype then minetest.set_node(bricks[b], { name = bricktype }) end end @@ -409,12 +415,12 @@ local function shrine_placement_callback(p1, p2, size, rotation, pr) end end -mcl_structures.generate_end_portal_shrine = function(pos, rotation, pr) +function mcl_structures.generate_end_portal_shrine(pos, rotation, pr) local offset = {x=6, y=4, z=6} - local size = {x=13, y=8, z=13} + --local size = {x=13, y=8, z=13} local newpos = { x = pos.x - offset.x, y = pos.y, z = pos.z - offset.z } - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_portal_room_simple.mts" + local path = modpath.."/schematics/mcl_structures_end_portal_room_simple.mts" mcl_structures.place_schematic(newpos, path, rotation or "0", nil, true, nil, shrine_placement_callback, pr) end @@ -471,8 +477,6 @@ local function temple_placement_callback(p1, p2, size, rotation, pr) { itemstring = "mcl_mobitems:string", weight = 10, amount_min = 1, amount_max = 8 }, } }}, pr) - - local meta = minetest.get_meta(chests[c]) init_node_construct(chests[c]) local meta = minetest.get_meta(chests[c]) local inv = meta:get_inventory() @@ -494,11 +498,11 @@ local function temple_placement_callback(p1, p2, size, rotation, pr) end end -mcl_structures.generate_desert_temple = function(pos, rotation, pr) +function mcl_structures.generate_desert_temple(pos, rotation, pr) -- No Generating for the temple ... Why using it ? No Change - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_temple.mts" + local path = modpath.."/schematics/mcl_structures_desert_temple.mts" local newpos = {x=pos.x,y=pos.y-12,z=pos.z} - local size = {x=22, y=24, z=22} + --local size = {x=22, y=24, z=22} if newpos == nil then return end @@ -518,7 +522,7 @@ Format of return value: TODO: Implement this function for all other structure types as well. ]] -mcl_structures.get_registered_structures = function(structure_type) +function mcl_structures.get_registered_structures(structure_type) if registered_structures[structure_type] then return table.copy(registered_structures[structure_type]) else @@ -528,7 +532,7 @@ end -- Register a structures table for the given type. The table format is the same as for -- mcl_structures.get_registered_structures. -mcl_structures.register_structures = function(structure_type, structures) +function mcl_structures.register_structures(structure_type, structures) registered_structures[structure_type] = structures end diff --git a/mods/MAPGEN/mcl_villages/buildings.lua b/mods/MAPGEN/mcl_villages/buildings.lua index e43db6d9..a6902906 100644 --- a/mods/MAPGEN/mcl_villages/buildings.lua +++ b/mods/MAPGEN/mcl_villages/buildings.lua @@ -12,19 +12,19 @@ function settlements.build_schematic(vm, data, va, pos, building, replace_wall, -- pick random material local material = wallmaterial[math.random(1,#wallmaterial)] -- schematic conversion to lua - local schem_lua = minetest.serialize_schematic(building, - "lua", - {lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)" + local schem_lua = minetest.serialize_schematic(building, + "lua", + {lua_use_comments = false, lua_num_indent_spaces = 0}).." return schematic" -- replace material if replace_wall == "y" then schem_lua = schem_lua:gsub("mcl_core:cobble", material) end - schem_lua = schem_lua:gsub("mcl_core:dirt_with_grass", + schem_lua = schem_lua:gsub("mcl_core:dirt_with_grass", platform_material) -- Disable special junglewood for now. -- special material for spawning npcs - -- schem_lua = schem_lua:gsub("mcl_core:junglewood", + -- schem_lua = schem_lua:gsub("mcl_core:junglewood", -- "settlements:junglewood") -- @@ -37,25 +37,25 @@ function settlements.build_schematic(vm, data, va, pos, building, replace_wall, local possible_rotations = {"0", "90", "180", "270"} local rotation = possible_rotations[ math.random( #possible_rotations ) ] settlements.foundation( - pos, - width, - depth, - height, + pos, + width, + depth, + height, rotation) vm:set_data(data) -- place schematic minetest.place_schematic_on_vmanip( - vm, - pos, - schematic, - rotation, - nil, + vm, + pos, + schematic, + rotation, + nil, true) vm:write_to_map(true) end]] ------------------------------------------------------------------------------- --- initialize settlement_info +-- initialize settlement_info ------------------------------------------------------------------------------- function settlements.initialize_settlement_info(pr) local count_buildings = {} @@ -81,10 +81,10 @@ function settlements.create_site_plan(maxp, minp, pr) local possible_rotations = {"0", "90", "180", "270"} -- find center of chunk local center = { - x=math.floor((minp.x+maxp.x)/2), - y=maxp.y, + x=math.floor((minp.x+maxp.x)/2), + y=maxp.y, z=math.floor((minp.z+maxp.z)/2) - } + } -- find center_surface of chunk local center_surface , surface_material = settlements.find_surface(center, true) local chunks = {} @@ -105,8 +105,8 @@ function settlements.create_site_plan(maxp, minp, pr) -- add to settlement info table local index = 1 settlement_info[index] = { - pos = center_surface, - name = building_all_info["name"], + pos = center_surface, + name = building_all_info["name"], hsize = building_all_info["hsize"], rotat = rotation, surface_mat = surface_material @@ -149,8 +149,8 @@ function settlements.create_site_plan(maxp, minp, pr) rotation = possible_rotations[ pr:next(1, #possible_rotations ) ] number_built = number_built + 1 settlement_info[index] = { - pos = pos_surface, - name = building_all_info["name"], + pos = pos_surface, + name = building_all_info["name"], hsize = building_all_info["hsize"], rotat = rotation, surface_mat = surface_material @@ -187,10 +187,10 @@ local function construct_node(p1, p2, name) end return nodes end - minetest.log("warning","[mcl_villages] No on_construct defined for node name " .. name) + minetest.log("warning", "[mcl_villages] No on_construct defined for node name " .. name) return end - minetest.log("warning","[mcl_villages] Attempt to 'construct' inexistant nodes: " .. name) + minetest.log("warning", "[mcl_villages] Attempt to 'construct' inexistant nodes: " .. name) end local function init_nodes(p1, p2, size, rotation, pr) construct_node(p1, p2, "mcl_itemframes:item_frame") @@ -215,10 +215,10 @@ function settlements.place_schematics(settlement_info, pr) end end - local pos = settlement_info[i]["pos"] - local rotation = settlement_info[i]["rotat"] + local pos = settlement_info[i]["pos"] + local rotation = settlement_info[i]["rotat"] -- get building node material for better integration to surrounding - local platform_material = settlement_info[i]["surface_mat"] + local platform_material = settlement_info[i]["surface_mat"] --platform_material_name = minetest.get_name_from_content_id(platform_material) -- pick random material --local material = wallmaterial[pr:next(1,#wallmaterial)] @@ -226,9 +226,9 @@ function settlements.place_schematics(settlement_info, pr) local building = building_all_info["mts"] local replace_wall = building_all_info["rplc"] -- schematic conversion to lua - local schem_lua = minetest.serialize_schematic(building, - "lua", - {lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)" + local schem_lua = minetest.serialize_schematic(building, + "lua", + {lua_use_comments = false, lua_num_indent_spaces = 0}).." return schematic" schem_lua = schem_lua:gsub("mcl_core:stonebrickcarved", "mcl_villages:stonebrickcarved") -- replace material if replace_wall then @@ -269,10 +269,10 @@ function settlements.place_schematics(settlement_info, pr) -- build foundation for the building an make room above -- place schematic mcl_structures.place_schematic( - pos, - schematic, - rotation, - nil, + pos, + schematic, + rotation, + nil, true, nil, init_nodes, diff --git a/mods/MAPGEN/mcl_villages/const.lua b/mods/MAPGEN/mcl_villages/const.lua index 4e2b3913..eb780620 100644 --- a/mods/MAPGEN/mcl_villages/const.lua +++ b/mods/MAPGEN/mcl_villages/const.lua @@ -1,5 +1,5 @@ -- switch for debugging -settlements.debug = function(message) +function settlements.debug(message) -- minetest.chat_send_all(message) -- minetest.log("warning", "[mcl_villages] "..message) minetest.log("verbose", "[mcl_villages] "..message) @@ -7,16 +7,16 @@ end --[[ Manually set in 'buildings.lua' -- material to replace cobblestone with -wallmaterial = { - "mcl_core:junglewood", - "mcl_core:sprucewood", - "mcl_core:wood", - "mcl_core:birchwood", - "mcl_core:acaciawood", - "mcl_core:stonebrick", - "mcl_core:cobble", - "mcl_core:sandstonecarved", - "mcl_core:sandstone", +local wallmaterial = { + "mcl_core:junglewood", + "mcl_core:sprucewood", + "mcl_core:wood", + "mcl_core:birchwood", + "mcl_core:acaciawood", + "mcl_core:stonebrick", + "mcl_core:cobble", + "mcl_core:sandstonecarved", + "mcl_core:sandstone", "mcl_core:sandstonesmooth2" } --]] @@ -78,4 +78,4 @@ max_height_difference = 56 -- -- half_map_chunk_size = 40 -quarter_map_chunk_size = 20 +--quarter_map_chunk_size = 20 diff --git a/mods/MAPGEN/mcl_villages/foundation.lua b/mods/MAPGEN/mcl_villages/foundation.lua index 038a2f20..71c5cfdd 100644 --- a/mods/MAPGEN/mcl_villages/foundation.lua +++ b/mods/MAPGEN/mcl_villages/foundation.lua @@ -9,15 +9,15 @@ function settlements.ground(pos, pr) -- role model: Wendelsteinkircherl, Brannen while true do cnt = cnt+1 if cnt > 20 then break end - if cnt>pr:next(2,4) then - mat = "mcl_core:stone" + if cnt>pr:next(2,4) then + mat = "mcl_core:stone" end minetest.swap_node(p2, {name=mat}) p2.y = p2.y-1 end end ------------------------------------------------------------------------------- --- function clear space above baseplate +-- function clear space above baseplate ------------------------------------------------------------------------------- function settlements.terraform(settlement_info, pr) local fheight, fwidth, fdepth, schematic_data @@ -30,7 +30,7 @@ function settlements.terraform(settlement_info, pr) break end end - local pos = settlement_info[i]["pos"] + local pos = settlement_info[i]["pos"] if settlement_info[i]["rotat"] == "0" or settlement_info[i]["rotat"] == "180" then fwidth = schematic_data["hwidth"] fdepth = schematic_data["hdepth"] @@ -54,9 +54,9 @@ function settlements.terraform(settlement_info, pr) -- local p = {x=pos.x+xi, y=pos.y+yi, z=pos.z+zi} -- local node = mcl_vars.get_node(p) -- if node and node.name ~= "air" then --- minetest.swap_node(p,{name="air"}) +-- minetest.swap_node(p,{name="air"}) -- end - minetest.swap_node({x=pos.x+xi, y=pos.y+yi, z=pos.z+zi},{name="air"}) + minetest.swap_node({x=pos.x+xi, y=pos.y+yi, z=pos.z+zi},{name="air"}) end end end diff --git a/mods/MAPGEN/mcl_villages/init.lua b/mods/MAPGEN/mcl_villages/init.lua index 19de10b9..7e460990 100644 --- a/mods/MAPGEN/mcl_villages/init.lua +++ b/mods/MAPGEN/mcl_villages/init.lua @@ -1,5 +1,5 @@ settlements = {} -settlements.modpath = minetest.get_modpath("mcl_villages") +settlements.modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(settlements.modpath.."/const.lua") dofile(settlements.modpath.."/utils.lua") @@ -37,7 +37,7 @@ minetest.register_node("mcl_villages:stonebrickcarved", { -- -- register inhabitants -- -if minetest.get_modpath("mobs_mc") ~= nil then +if minetest.get_modpath("mobs_mc") then mobs:register_spawn("mobs_mc:villager", --name {"mcl_core:stonebrickcarved"}, --nodes 15, --max_light @@ -46,7 +46,7 @@ if minetest.get_modpath("mobs_mc") ~= nil then 7, --active_object_count 31000, --max_height nil) --day_toggle -end +end --]] -- @@ -85,7 +85,7 @@ if mg_name ~= "singlenode" then if blockseed % 77 ~= 17 then return end -- needed for manual and automated settlement building -- don't build settlements on (too) uneven terrain - local heightmap = minetest.get_mapgen_object("heightmap") + --local heightmap = minetest.get_mapgen_object("heightmap") local height_difference = settlements.evaluate_heightmap() if height_difference > max_height_difference then return end diff --git a/mods/MAPGEN/mcl_villages/paths.lua b/mods/MAPGEN/mcl_villages/paths.lua index 4973171a..63f2ba14 100644 --- a/mods/MAPGEN/mcl_villages/paths.lua +++ b/mods/MAPGEN/mcl_villages/paths.lua @@ -6,10 +6,10 @@ function settlements.paths(settlement_info) local end_point local distance --for k,v in pairs(settlement_info) do - starting_point = settlement_info[1]["pos"] + starting_point = settlement_info[1]["pos"] for o,p in pairs(settlement_info) do - end_point = settlement_info[o]["pos"] + end_point = settlement_info[o]["pos"] if starting_point ~= end_point then -- loop until end_point is reched (distance == 0) @@ -40,35 +40,35 @@ function settlements.paths(settlement_info) -- evaluate which pos is closer to the end_point if dist_north_p_to_end <= dist_south_p_to_end and dist_north_p_to_end <= dist_west_p_to_end and - dist_north_p_to_end <= dist_east_p_to_end + dist_north_p_to_end <= dist_east_p_to_end then starting_point = north_p distance = dist_north_p_to_end elseif dist_south_p_to_end <= dist_north_p_to_end and dist_south_p_to_end <= dist_west_p_to_end and - dist_south_p_to_end <= dist_east_p_to_end + dist_south_p_to_end <= dist_east_p_to_end then starting_point = south_p distance = dist_south_p_to_end elseif dist_west_p_to_end <= dist_north_p_to_end and dist_west_p_to_end <= dist_south_p_to_end and - dist_west_p_to_end <= dist_east_p_to_end + dist_west_p_to_end <= dist_east_p_to_end then starting_point = west_p distance = dist_west_p_to_end elseif dist_east_p_to_end <= dist_north_p_to_end and dist_east_p_to_end <= dist_south_p_to_end and - dist_east_p_to_end <= dist_west_p_to_end + dist_east_p_to_end <= dist_west_p_to_end then starting_point = east_p distance = dist_east_p_to_end end -- find surface of new starting point local surface_point, surface_mat = settlements.find_surface(starting_point) - -- replace surface node with mcl_core:grass_path + -- replace surface node with mcl_core:grass_path if surface_point then if surface_mat == "mcl_core:sand" or surface_mat == "mcl_core:redsand" then diff --git a/mods/MAPGEN/mcl_villages/utils.lua b/mods/MAPGEN/mcl_villages/utils.lua index d7617541..993de11c 100644 --- a/mods/MAPGEN/mcl_villages/utils.lua +++ b/mods/MAPGEN/mcl_villages/utils.lua @@ -126,7 +126,7 @@ function settlements.fill_chest(pos, pr) -- fill chest local inv = minetest.get_inventory( {type="node", pos=pos} ) - local function get_treasures(pr) + local function get_treasures(prand) local loottable = {{ stacks_min = 3, stacks_max = 8, @@ -150,7 +150,7 @@ function settlements.fill_chest(pos, pr) { itemstring = "mobs_mc:diamond_horse_armor", weight = 1 }, } }} - local items = mcl_loot.get_multi_loot(loottable, pr) + local items = mcl_loot.get_multi_loot(loottable, prand) return items end @@ -163,14 +163,14 @@ end ------------------------------------------------------------------------------- function settlements.initialize_furnace(pos) -- find chests within radius - local furnacepos = minetest.find_node_near(pos, + local furnacepos = minetest.find_node_near(pos, 7, --radius {"mcl_furnaces:furnace"}) -- initialize furnacepos (mts furnacepos don't have meta) - if furnacepos + if furnacepos then local meta = minetest.get_meta(furnacepos) - if meta:get_string("infotext") ~= "furnace" + if meta:get_string("infotext") ~= "furnace" then minetest.registered_nodes["mcl_furnaces:furnace"].on_construct(furnacepos) end @@ -181,14 +181,14 @@ end ------------------------------------------------------------------------------- function settlements.initialize_anvil(pos) -- find chests within radius - local anvilpos = minetest.find_node_near(pos, + local anvilpos = minetest.find_node_near(pos, 7, --radius {"mcl_anvils:anvil"}) -- initialize anvilpos (mts anvilpos don't have meta) - if anvilpos + if anvilpos then local meta = minetest.get_meta(anvilpos) - if meta:get_string("infotext") ~= "anvil" + if meta:get_string("infotext") ~= "anvil" then minetest.registered_nodes["mcl_anvils:anvil"].on_construct(anvilpos) end diff --git a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua index 904c3af0..168ecf53 100644 --- a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua +++ b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua @@ -27,7 +27,7 @@ if mg_name == "v6" then } else -- This generates dark oak wood in mesa biomes and oak wood everywhere else. - tsm_railcorridors.nodes.corridor_woods_function = function(pos, node) + function tsm_railcorridors.nodes.corridor_woods_function(pos, node) if minetest.get_item_group(node.name, "hardened_clay") ~= 0 then return "mcl_core:darkwood", "mcl_fences:dark_oak_fence" else diff --git a/mods/MAPGEN/tsm_railcorridors/init.lua b/mods/MAPGEN/tsm_railcorridors/init.lua index 893f3d73..65a7d6a6 100644 --- a/mods/MAPGEN/tsm_railcorridors/init.lua +++ b/mods/MAPGEN/tsm_railcorridors/init.lua @@ -1,3 +1,6 @@ +local pairs = pairs +local tonumber = tonumber + tsm_railcorridors = {} -- Load node names @@ -8,7 +11,7 @@ local setting -- Probability function -- TODO: Check if this is correct -local P = function (float) +local function P(float) return math.floor(32767 * float) end @@ -80,14 +83,14 @@ end -- Enable cobwebs local place_cobwebs = true setting = minetest.settings:get_bool("tsm_railcorridors_place_cobwebs") -if setting ~= nil then +if setting then place_cobwebs = setting end -- Enable mob spawners local place_mob_spawners = true setting = minetest.settings:get_bool("tsm_railcorridors_place_mob_spawners") -if setting ~= nil then +if setting then place_mob_spawners = setting end @@ -114,7 +117,8 @@ if not tsm_railcorridors.nodes.corridor_woods_function then end -- Random Perlin noise generators -local pr, pr_carts, pr_treasures, pr_deco, webperlin_major, webperlin_minor +local pr, pr_carts, pr_deco, webperlin_major, webperlin_minor +--local pr_treasures local function InitRandomizer(seed) -- Mostly used for corridor gen. @@ -124,7 +128,7 @@ local function InitRandomizer(seed) -- Separate randomizer for carts because spawning carts is very timing-dependent pr_carts = PseudoRandom(seed-654) -- Chest contents randomizer - pr_treasures = PseudoRandom(seed+777) + --pr_treasures = PseudoRandom(seed+777) -- Used for cobweb generation, both noises have to reach a high value for cobwebs to appear webperlin_major = PerlinNoise(934, 3, 0.6, 500) webperlin_minor = PerlinNoise(834, 3, 0.6, 50) @@ -174,7 +178,7 @@ end -- Tries to place a rail, taking the damage chance into account local function PlaceRail(pos, damage_chance) - if damage_chance ~= nil and damage_chance > 0 then + if damage_chance and damage_chance > 0 then local x = pr:next(0,100) if x <= damage_chance then return false @@ -394,7 +398,7 @@ local function RecheckCartHack(params) local cart_id = params[2] -- Find cart for _, obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do - if obj ~= nil and obj:get_luaentity().name == cart_id then + if obj and obj:get_luaentity().name == cart_id then -- Cart found! We can now safely call the callback func. -- (calling it earlier has the danger of failing) minetest.log("info", "[tsm_railcorridors] Cart spawn succeeded: "..minetest.pos_to_string(pos)) @@ -680,11 +684,11 @@ local function create_corridor_section(waypoint, axis, sign, up_or_down, up_or_d railsegcount = segcount end for i=1,railsegcount do - local p = {x=waypoint.x+vek.x*i, y=waypoint.y+vek.y*i-1, z=waypoint.z+vek.z*i} + local p = {x = waypoint.x + vek.x * i, y = waypoint.y + vek.y * i-1, z = waypoint.z + vek.z * i} -- Randomly returns either the left or right side of the main rail. -- Also returns offset as second return value. - local left_or_right = function(pos, vek) + local function left_or_right(pos, vek) local off if pr:next(1, 2) == 1 then -- left @@ -764,7 +768,7 @@ local function create_corridor_section(waypoint, axis, sign, up_or_down, up_or_d -- Place cobwebs left and right in the corridor if place_cobwebs and tsm_railcorridors.nodes.cobweb then -- Helper function to place a cobweb at the side (based on chance an Perlin noise) - local cobweb_at_side = function(basepos, vek) + local function cobweb_at_side(basepos, vek) if pr:next(1,5) == 1 then local h = pr:next(0, 2) -- 3 possible cobweb heights local cpos = {x=basepos.x+vek.x, y=basepos.y+h, z=basepos.z+vek.z} @@ -823,7 +827,7 @@ local function create_corridor_line(waypoint, axis, sign, length, wood, post, da local s = sign local ud = false -- Up or down local udn = false -- Up or down is next - local udp = false -- Up or down was previous + local udp -- Up or down was previous local up = false -- true if going up local upp = false -- true if was going up previously for i=1,length do @@ -911,7 +915,7 @@ local function create_corridor_line(waypoint, axis, sign, length, wood, post, da a="z" elseif a=="z" then a="x" - end; + end; s = pr:next(1, 2) == 1 end end diff --git a/mods/MISC/findbiome/init.lua b/mods/MISC/findbiome/init.lua index ce7fd979..8560d160 100644 --- a/mods/MISC/findbiome/init.lua +++ b/mods/MISC/findbiome/init.lua @@ -1,6 +1,6 @@ -local S = minetest.get_translator("findbiome") +local S = minetest.get_translator(minetest.get_current_modname()) -local mod_biomeinfo = minetest.get_modpath("biomeinfo") ~= nil +local mod_biomeinfo = minetest.get_modpath("biomeinfo") local mg_name = minetest.get_mapgen_setting("mg_name") local water_level = tonumber(minetest.get_mapgen_setting("water_level")) @@ -119,7 +119,7 @@ local function find_biome(pos, biomes) local edge_dist = 0 local dir_step = 0 local dir_ind = 1 - local success = false + local success local spawn_pos local biome_ids @@ -166,7 +166,7 @@ local function find_biome(pos, biomes) spawn_pos = {x = spos.x, y = spos.y, z = spos.z} end if spawn_pos then - local adjusted_pos, outside = adjust_pos_to_biome_limits(spawn_pos, biome_id) + local _,outside = adjust_pos_to_biome_limits(spawn_pos, biome_id) if is_in_world(spawn_pos) and not outside then return true end diff --git a/mods/MISC/mcl_commands/alias.lua b/mods/MISC/mcl_commands/alias.lua index 2989b7b3..5c9ee9f3 100644 --- a/mods/MISC/mcl_commands/alias.lua +++ b/mods/MISC/mcl_commands/alias.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) local function register_chatcommand_alias(alias, cmd) local def = minetest.chatcommands[cmd] diff --git a/mods/MISC/mcl_commands/init.lua b/mods/MISC/mcl_commands/init.lua index 7a9fe486..a287c292 100644 --- a/mods/MISC/mcl_commands/init.lua +++ b/mods/MISC/mcl_commands/init.lua @@ -1,7 +1,3 @@ -local S = minetest.get_translator("mcl_commands") - -local mod_death_messages = minetest.get_modpath("mcl_death_messages") - local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/kill.lua") diff --git a/mods/MISC/mcl_commands/kill.lua b/mods/MISC/mcl_commands/kill.lua index 2de69e6a..becd4291 100644 --- a/mods/MISC/mcl_commands/kill.lua +++ b/mods/MISC/mcl_commands/kill.lua @@ -1,5 +1,4 @@ -local S = minetest.get_translator("mcl_commands") -local mod_death_messages = minetest.get_modpath("mcl_death_messages") +local S = minetest.get_translator(minetest.get_current_modname()) local function handle_kill_command(suspect, victim) if minetest.settings:get_bool("enable_damage") == false then @@ -21,17 +20,8 @@ local function handle_kill_command(suspect, victim) if wield:get_name() == "mobs_mc:totem" then victimref:set_wielded_item("") end - if mod_death_messages then - local msg - if suspect == victim then - msg = S("@1 committed suicide.", victim) - else - msg = S("@1 was killed by @2.", victim, suspect) - end - mcl_death_messages.player_damage(victimref, msg) - end -- DIE! - victimref:set_hp(0) + victimref:set_hp(0, {_mcl_type = "out_of_world"}) -- Log if not suspect == victim then minetest.log("action", string.format("%s killed %s using /kill", suspect, victim)) @@ -56,4 +46,4 @@ minetest.register_chatcommand("kill", { return handle_kill_command(name, param) end end, -}) \ No newline at end of file +}) diff --git a/mods/MISC/mcl_commands/list.lua b/mods/MISC/mcl_commands/list.lua index 0257e283..5661454b 100644 --- a/mods/MISC/mcl_commands/list.lua +++ b/mods/MISC/mcl_commands/list.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("list", { description = S("Show who is logged on"), diff --git a/mods/MISC/mcl_commands/mod.conf b/mods/MISC/mcl_commands/mod.conf index d651fad7..00d70709 100644 --- a/mods/MISC/mcl_commands/mod.conf +++ b/mods/MISC/mcl_commands/mod.conf @@ -1,4 +1,3 @@ name = mcl_commands author = Wuzzy description = MCL2 commands -optional_depends = mcl_death_messages diff --git a/mods/MISC/mcl_commands/say.lua b/mods/MISC/mcl_commands/say.lua index 2b01a7e9..9fd53c17 100644 --- a/mods/MISC/mcl_commands/say.lua +++ b/mods/MISC/mcl_commands/say.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_privilege("announce", { description = S("Can use /say"), diff --git a/mods/MISC/mcl_commands/seed.lua b/mods/MISC/mcl_commands/seed.lua index da5f6a30..6a99d53c 100644 --- a/mods/MISC/mcl_commands/seed.lua +++ b/mods/MISC/mcl_commands/seed.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("seed", { description = S("Displays the world seed"), diff --git a/mods/MISC/mcl_commands/setblock.lua b/mods/MISC/mcl_commands/setblock.lua index 30d68b74..95acdd35 100644 --- a/mods/MISC/mcl_commands/setblock.lua +++ b/mods/MISC/mcl_commands/setblock.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("setblock", { params = S(",, "), @@ -6,7 +6,7 @@ minetest.register_chatcommand("setblock", { privs = {give=true, interact=true}, func = function(name, param) local p = {} - local nodestring = nil + local nodestring p.x, p.y, p.z, nodestring = param:match("^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) +(.+)$") p.x, p.y, p.z = tonumber(p.x), tonumber(p.y), tonumber(p.z) if p.x and p.y and p.z and nodestring then diff --git a/mods/MISC/mcl_commands/sound.lua b/mods/MISC/mcl_commands/sound.lua index 934abb80..5833676f 100644 --- a/mods/MISC/mcl_commands/sound.lua +++ b/mods/MISC/mcl_commands/sound.lua @@ -1,42 +1,37 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("playsound",{ params = S(" "), --TODO:add source description = S("Play a sound. Arguments: : name of the sound. : Target."), privs = {server = true}, - func = function(name, params) + func = function(name, rawparams) local P = {} local i = 0 - for str in string.gmatch(params, "([^ ]+)") do + for str in string.gmatch(rawparams, "([^ ]+)") do i = i + 1 P[i] = str end - local params = {} if P[1] == tostring(P[1]) then params.name = P[1] else return false, S("Sound name is invalid!") --TODO: add mc chat message end - if P[2] == tostring(P[2]) and minetest.player_exists(P[2]) then params.target = P[2] else return false, S("Target is invalid!!") end - -- if P[3] then -- params.pos = nil --TODO:position -- else -- params.pos = nil -- end - -- if P[4] == tonumber(P[4]) then -- params.gain = P[4] -- else -- params.gain = 1.0 -- end - -- if P[5] == tonumber(P[5]) then -- params.pitch = P[5] -- else diff --git a/mods/MISC/mcl_commands/summon.lua b/mods/MISC/mcl_commands/summon.lua index eb6066ff..69da0a66 100644 --- a/mods/MISC/mcl_commands/summon.lua +++ b/mods/MISC/mcl_commands/summon.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) local orig_func = minetest.registered_chatcommands["spawnentity"].func local cmd = table.copy(minetest.registered_chatcommands["spawnentity"]) diff --git a/mods/MISC/mcl_privs/init.lua b/mods/MISC/mcl_privs/init.lua index 00670db1..63694ab1 100644 --- a/mods/MISC/mcl_privs/init.lua +++ b/mods/MISC/mcl_privs/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_privs") +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."), diff --git a/mods/MISC/mcl_temp_helper_recipes/init.lua b/mods/MISC/mcl_temp_helper_recipes/init.lua index d1262cb2..420cd6c2 100644 --- a/mods/MISC/mcl_temp_helper_recipes/init.lua +++ b/mods/MISC/mcl_temp_helper_recipes/init.lua @@ -4,7 +4,7 @@ minetest.register_craft({ type = "shapeless", - output = 'mcl_chests:trapped_chest', + output = "mcl_chests:trapped_chest", recipe = {"mcl_core:iron_ingot", "mcl_core:stick", "group:wood", "mcl_chests:chest"}, }) @@ -27,7 +27,12 @@ minetest.register_craft({ minetest.register_craft({ type = "shapeless", output = "mcl_ocean:prismarine_crystals", - recipe = { "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_core:gold_ingot" }, + recipe = { + "mcl_ocean:prismarine_shard", + "mcl_ocean:prismarine_shard", + "mcl_ocean:prismarine_shard", + "mcl_core:gold_ingot", + }, }) minetest.register_craft({ diff --git a/mods/MISC/mcl_wip/init.lua b/mods/MISC/mcl_wip/init.lua index 0eb56dd8..54fd81c1 100644 --- a/mods/MISC/mcl_wip/init.lua +++ b/mods/MISC/mcl_wip/init.lua @@ -1,6 +1,6 @@ --- Mod to mark WIP (Work In Progress) content +-- Allow items or nodes to be marked as WIP (Work In Progress) or Experimental -local S = minetest.get_translator("mcl_wip") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_wip = {} mcl_wip.registered_wip_items = {} diff --git a/mods/PLAYER/mcl_criticals/init.lua b/mods/PLAYER/mcl_criticals/init.lua new file mode 100644 index 00000000..27d09abb --- /dev/null +++ b/mods/PLAYER/mcl_criticals/init.lua @@ -0,0 +1,30 @@ +mcl_damage.register_modifier(function(obj, damage, reason) + if reason.type == "player" then + local hitter = reason.direct + if mcl_sprint.is_sprinting(hitter) then + obj:add_velocity(hitter:get_velocity()) + elseif (hitter:get_velocity() or hitter:get_player_velocity()).y < 0 then + local pos = mcl_util.get_object_center(obj) + 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", + }) + minetest.sound_play("mcl_criticals_hit", {object = obj}) + -- the minecraft wiki is actually wrong about a crit dealing 150% damage, see minecraft source code + return damage + math.random(0, math.floor(damage * 1.5 + 2)) + end + end +end, -100) diff --git a/mods/PLAYER/mcl_criticals/mod.conf b/mods/PLAYER/mcl_criticals/mod.conf new file mode 100644 index 00000000..5b0b9133 --- /dev/null +++ b/mods/PLAYER/mcl_criticals/mod.conf @@ -0,0 +1,2 @@ +name = mcl_criticals +depends = mcl_damage diff --git a/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.0.ogg b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.0.ogg new file mode 100644 index 00000000..8184d107 Binary files /dev/null and b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.0.ogg differ diff --git a/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.1.ogg b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.1.ogg new file mode 100644 index 00000000..aed99816 Binary files /dev/null and b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.1.ogg differ diff --git a/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.2.ogg b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.2.ogg new file mode 100644 index 00000000..6d573b9f Binary files /dev/null and b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.2.ogg differ diff --git a/mods/PLAYER/mcl_death_drop/API.md b/mods/PLAYER/mcl_death_drop/API.md index b19e2fd7..3fc5163e 100644 --- a/mods/PLAYER/mcl_death_drop/API.md +++ b/mods/PLAYER/mcl_death_drop/API.md @@ -7,8 +7,8 @@ Drop registered inventories on player death. * function(player): must return inventory * listname: string * drop: bool - * true: the entire list will be dropped - * false: items with curse_of_vanishing enchantement will be broken. + * true: the list will be dropped + * false: the list will only be cleared ## mcl_death_drop.registered_dropped_lists Table containing dropped list inventory, name and drop state. \ No newline at end of file diff --git a/mods/PLAYER/mcl_death_drop/init.lua b/mods/PLAYER/mcl_death_drop/init.lua index 7c54334a..bfeee0c3 100644 --- a/mods/PLAYER/mcl_death_drop/init.lua +++ b/mods/PLAYER/mcl_death_drop/init.lua @@ -1,17 +1,18 @@ local random = math.random +local ipairs = ipairs + mcl_death_drop = {} mcl_death_drop.registered_dropped_lists = {} function mcl_death_drop.register_dropped_list(inv, listname, drop) - table.insert(mcl_death_drop.registered_dropped_lists, {inv=inv, listname=listname, drop=drop}) + table.insert(mcl_death_drop.registered_dropped_lists, {inv = inv, listname = listname, drop = drop}) end mcl_death_drop.register_dropped_list("PLAYER", "main", true) mcl_death_drop.register_dropped_list("PLAYER", "craft", true) mcl_death_drop.register_dropped_list("PLAYER", "armor", true) -mcl_death_drop.register_dropped_list(function(player) return select(3, armor:get_valid_player(player)) end , "armor", false) minetest.register_on_dieplayer(function(player) local keep = minetest.settings:get_bool("mcl_keepInventory", false) @@ -20,7 +21,7 @@ minetest.register_on_dieplayer(function(player) local playerinv = player:get_inventory() local pos = player:get_pos() -- No item drop if in deep void - local void, void_deadly = mcl_worlds.is_in_void(pos) + local _, void_deadly = mcl_worlds.is_in_void(pos) for l=1,#mcl_death_drop.registered_dropped_lists do local inv = mcl_death_drop.registered_dropped_lists[l].inv @@ -31,7 +32,7 @@ minetest.register_on_dieplayer(function(player) end local listname = mcl_death_drop.registered_dropped_lists[l].listname local drop = mcl_death_drop.registered_dropped_lists[l].drop - if inv ~= nil then + if inv then for i, stack in ipairs(inv:get_list(listname)) do local x = random(0, 9)/3 local z = random(0, 9)/3 @@ -50,7 +51,6 @@ minetest.register_on_dieplayer(function(player) inv:set_list(listname, {}) end end - armor:set_player_armor(player) - armor:update_inventory(player) + mcl_armor.update(player) end end) diff --git a/mods/PLAYER/mcl_hunger/api.lua b/mods/PLAYER/mcl_hunger/api.lua index 55153b9b..20937023 100644 --- a/mods/PLAYER/mcl_hunger/api.lua +++ b/mods/PLAYER/mcl_hunger/api.lua @@ -76,7 +76,7 @@ if mcl_hunger.active then satuchanged = true end if satuchanged then - if h ~= nil then h = h end + if h then h = h end mcl_hunger.update_saturation_hud(player, mcl_hunger.get_saturation(player), h) end end @@ -86,7 +86,8 @@ if mcl_hunger.active then function mcl_hunger.saturate(playername, increase, update_hudbar) local player = minetest.get_player_by_name(playername) - local ok = mcl_hunger.set_saturation(player, math.min(mcl_hunger.get_saturation(player) + increase, mcl_hunger.get_hunger(player))) + local ok = mcl_hunger.set_saturation(player, + math.min(mcl_hunger.get_saturation(player) + increase, mcl_hunger.get_hunger(player))) if update_hudbar ~= false then mcl_hunger.update_saturation_hud(player, mcl_hunger.get_saturation(player), mcl_hunger.get_hunger(player)) end @@ -105,7 +106,7 @@ if mcl_hunger.active then -- otherwise the following poison/exhaust fields are ignored food[name].poison = poison -- poison damage per tick for poisonous food food[name].exhaust = exhaust -- exhaustion per tick for poisonous food - food[name].poisonchance = poisonchance -- chance percentage that this item poisons the player (default: 100% if poisoning is enabled) + food[name].poisonchance = poisonchance -- chance percentage that this item poisons the player (default: 100%) food[name].sound = sound -- special sound that is played when eating end diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index 393bdc9a..5dec8b1b 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -1,10 +1,7 @@ -local S = minetest.get_translator("mcl_hunger") -local mod_death_messages = minetest.get_modpath("mcl_death_messages") +--local S = minetest.get_translator(minetest.get_current_modname()) -- wrapper for minetest.item_eat (this way we make sure other mods can't break this one) -local org_eat = minetest.do_item_eat -minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing) - +function minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing) if not user or user:is_player() == false then return itemstack end @@ -38,7 +35,8 @@ minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, p -- FIXME: In singleplayer, there's a cheat to circumvent this, simply by pausing the game between eats. -- This is because os.time() obviously does not care about the pause. A fix needs a different timer mechanism. if no_eat_delay or (mcl_hunger.last_eat[name] < 0) or (os.difftime(os.time(), mcl_hunger.last_eat[name]) >= 2) then - local can_eat_when_full = creative or (mcl_hunger.active == false) or minetest.get_item_group(itemstack:get_name(), "can_eat_when_full") == 1 + local can_eat_when_full = creative or (mcl_hunger.active == false) + or minetest.get_item_group(itemstack:get_name(), "can_eat_when_full") == 1 -- Don't allow eating when player has full hunger bar (some exceptional items apply) if can_eat_when_full or (mcl_hunger.get_hunger(user) < 20) then itemstack = mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing) @@ -67,7 +65,8 @@ function mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_t def.saturation = hp_change def.replace = replace_with_item end - local func = mcl_hunger.item_eat(def.saturation, def.replace, def.poisontime, def.poison, def.exhaust, def.poisonchance, def.sound) + local func = mcl_hunger.item_eat(def.saturation, def.replace, def.poisontime, + def.poison, def.exhaust, def.poisonchance, def.sound) return func(itemstack, user, pointed_thing) end @@ -90,7 +89,6 @@ local function poisonp(tick, time, time_left, damage, exhaustion, name) if not player then return end - local name = player:get_player_name() -- Abort if food poisonings have been stopped if mcl_hunger.poison_hunger[name] == 0 then return @@ -110,10 +108,7 @@ local function poisonp(tick, time, time_left, damage, exhaustion, name) -- Deal damage and exhaust player -- TODO: Introduce fatal poison at higher difficulties if player:get_hp()-damage > 0 then - if mod_death_messages then - mcl_death_messages.player_damage(player, S("@1 succumbed to the poison.", name)) - end - player:set_hp(player:get_hp()-damage) + mcl_util.deal_damage(player, damage, {type = "hunger"}) end mcl_hunger.exhaust(name, exhaustion) @@ -126,12 +121,12 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso return function(itemstack, user, pointed_thing) local itemname = itemstack:get_name() local creative = minetest.is_creative_enabled(user:get_player_name()) - if itemstack:peek_item() ~= nil and user ~= nil then + if itemstack:peek_item() and user then if not creative then itemstack:take_item() end local name = user:get_player_name() - local hp = user:get_hp() + --local hp = user:get_hp() local pos = user:get_pos() -- player height diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index b640dfdc..8c154700 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -1,5 +1,7 @@ -local S = minetest.get_translator("mcl_hunger") -local mod_death_messages = minetest.get_modpath("mcl_death_messages") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) + +local S = minetest.get_translator(modname) mcl_hunger = {} @@ -37,9 +39,9 @@ mcl_hunger.debug = false -- Cooldown timers for each player, to force a short delay between consuming 2 food items mcl_hunger.last_eat = {} -dofile(minetest.get_modpath("mcl_hunger").."/api.lua") -dofile(minetest.get_modpath("mcl_hunger").."/hunger.lua") -dofile(minetest.get_modpath("mcl_hunger").."/register_foods.lua") +dofile(modpath.."/api.lua") +dofile(modpath.."/hunger.lua") +dofile(modpath.."/register_foods.lua") --[[ IF HUNGER IS ENABLED ]] if mcl_hunger.active == true then @@ -65,9 +67,7 @@ end -- Count number of poisonings a player has at once mcl_hunger.poison_hunger = {} -- food poisoning, increasing hunger --- HUD item ids -local hunger_hud = {} - +-- HUD local function init_hud(player) hb.init_hudbar(player, "hunger", mcl_hunger.get_hunger(player)) if mcl_hunger.debug then @@ -140,14 +140,14 @@ local timerMult = 1 -- Cycles from 0 to 7, each time when timer hits half a seco minetest.register_globalstep(function(dtime) main_timer = main_timer + dtime timer = timer + dtime - if main_timer > mcl_hunger.HUD_TICK or timer > 0.5 then + 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() local h = tonumber(mcl_hunger.get_hunger(player)) local hp = player:get_hp() - if timer > 0.5 then + 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. @@ -161,10 +161,7 @@ minetest.register_globalstep(function(dtime) -- Damage hungry player down to 1 HP -- TODO: Allow starvation at higher difficulty levels if hp-1 > 0 then - if mod_death_messages then - mcl_death_messages.player_damage(player, S("@1 starved to death.", name)) - end - player:set_hp(hp-1) + mcl_util.deal_damage(player, 1, {type = "starve"}) end end end @@ -172,9 +169,9 @@ minetest.register_globalstep(function(dtime) end end end - if timer > 0.5 then + if timer > 0.25 then timer = 0 - timerMult = timerMult + 1 + timerMult = timerMult + 2 if timerMult > 7 then timerMult = 0 end diff --git a/mods/PLAYER/mcl_hunger/mod.conf b/mods/PLAYER/mcl_hunger/mod.conf index 7795da7a..99ab71ff 100644 --- a/mods/PLAYER/mcl_hunger/mod.conf +++ b/mods/PLAYER/mcl_hunger/mod.conf @@ -2,4 +2,3 @@ name = mcl_hunger author = BlockMen description = Adds a simple hunger meachanic with satiation, food poisoning and different healing. depends = hudbars -optional_depends = mcl_death_messages diff --git a/mods/PLAYER/mcl_hunger/screenshot.png b/mods/PLAYER/mcl_hunger/screenshot.png deleted file mode 100644 index 5af65836..00000000 Binary files a/mods/PLAYER/mcl_hunger/screenshot.png and /dev/null differ diff --git a/mods/PLAYER/mcl_hunger/textures/hbhunger_bgicon.png b/mods/PLAYER/mcl_hunger/textures/hbhunger_bgicon.png index e02778a2..d21b1684 100644 Binary files a/mods/PLAYER/mcl_hunger/textures/hbhunger_bgicon.png and b/mods/PLAYER/mcl_hunger/textures/hbhunger_bgicon.png differ diff --git a/mods/PLAYER/mcl_hunger/textures/hbhunger_icon.png b/mods/PLAYER/mcl_hunger/textures/hbhunger_icon.png index 9c1bb63e..3830fdfc 100644 Binary files a/mods/PLAYER/mcl_hunger/textures/hbhunger_icon.png and b/mods/PLAYER/mcl_hunger/textures/hbhunger_icon.png differ diff --git a/mods/PLAYER/mcl_hunger/textures/mcl_hunger_icon_foodpoison.png b/mods/PLAYER/mcl_hunger/textures/mcl_hunger_icon_foodpoison.png index 141b4b44..130601c8 100644 Binary files a/mods/PLAYER/mcl_hunger/textures/mcl_hunger_icon_foodpoison.png and b/mods/PLAYER/mcl_hunger/textures/mcl_hunger_icon_foodpoison.png differ diff --git a/mods/PLAYER/mcl_meshhand/init.lua b/mods/PLAYER/mcl_meshhand/init.lua index cdd5da94..93f22c32 100644 --- a/mods/PLAYER/mcl_meshhand/init.lua +++ b/mods/PLAYER/mcl_meshhand/init.lua @@ -34,7 +34,8 @@ for _,texture in pairs(list) do end, groups = { dig_immediate = 3, not_in_creative_inventory = 1 }, range = def.range, - }) + _mcl_hand_id = texture, + }) minetest.register_node("mcl_meshhand:"..texture.. "_female", { description = "", @@ -57,13 +58,13 @@ for _,texture in pairs(list) do end, groups = { dig_immediate = 3, not_in_creative_inventory = 1 }, range = def.range, - }) + _mcl_hand_id = texture .. "_female", + }) end if has_mcl_skins == true then --change the player's hand to their skin mcl_skins.register_on_set_skin(function(player, skin) - local name = player:get_player_name() local meta = mcl_skins.meta[skin] if meta.gender == "female" then player:get_inventory():set_stack("hand", 1, "mcl_meshhand:"..skin.."_female") diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index 210e2d19..6cf2f001 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(player:get_wielded_item():get_name(), "mcl_bows:bow") or controls.LMB then + if controls.RMB and not string.find(get_wielded_item_name, "mcl_bows:bow") or controls.LMB then return true else return false @@ -88,29 +88,48 @@ function mcl_player.player_set_model(player, model_name) player_model[name] = model_name end -function mcl_player.player_set_textures(player, textures, preview) - local name = player:get_player_name() - player_textures[name] = textures - player:set_properties({textures = textures,}) - if preview then - player:get_meta():set_string("mcl_player:preview", preview) - end +local function set_texture(player, index, texture) + local textures = player_textures[player:get_player_name()] + textures[index] = texture + player:set_properties({textures = textures}) +end + +local function set_preview(player, field, preview) + player:get_meta():set_string("mcl_player:" .. field .. "_preview", preview) +end + +function mcl_player.player_set_skin(player, texture, preview) + set_texture(player, 1, texture) + set_preview(player, "skin", preview) +end + +function mcl_player.player_set_armor(player, texture, preview) + set_texture(player, 2, texture) + set_preview(player, "armor", preview) +end + +function mcl_player.player_set_wielditem(player, texture) + set_texture(player, 3, texture) end function mcl_player.player_get_preview(player) - local preview = player:get_meta():get_string("mcl_player:preview") - if preview == nil or preview == "" then - return "player.png" - else - return preview + local preview = player:get_meta():get_string("mcl_player:skin_preview") + if preview == "" then + preview = "player.png" end + local armor_preview = player:get_meta():set_string("mcl_player:armor_preview") + if armor_preview ~= "" then + preview = preview .. "^" .. armor_preview + end + return preview + end function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname) local name = player:get_player_name() local model = player_model[name] local anim = models[model].animations[player_anim[name]] - return "model[" .. x .. "," .. y .. ";" .. w .. "," .. h .. ";" .. fsname .. ";" .. model .. ";" .. table.concat(player_textures[name], ",") .. ";0," .. 180 .. ";false;false;" .. anim.x .. "," .. anim.y .. "]" + return "model["..x..","..y..";"..w..","..h..";"..fsname..";"..model..";"..table.concat(player_textures[name], ",")..";0,".. 180 ..";false;false;"..anim.x..","..anim.y.."]" end function mcl_player.player_set_animation(player, anim_name, speed) @@ -129,8 +148,10 @@ end -- Update appearance when the player joins minetest.register_on_joinplayer(function(player) - mcl_player.player_attached[player:get_player_name()] = false + local name = player:get_player_name() + mcl_player.player_attached[name] = false mcl_player.player_set_model(player, "character.b3d") + player_textures[name] = {"blank.png", "blank.png", "blank.png"} --player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30) player:set_fov(86.1) -- see >>> end) @@ -179,7 +200,10 @@ minetest.register_globalstep(function(dtime) -- Apply animations based on what the player is doing if player:get_hp() == 0 then player_set_animation(player, "die") - elseif walking and velocity.x > 0.35 or walking and velocity.x < -0.35 or walking and velocity.z > 0.35 or walking and velocity.z < -0.35 then + elseif walking and velocity.x > 0.35 + or walking and velocity.x < -0.35 + or walking and velocity.z > 0.35 + or walking and velocity.z < -0.35 then if player_sneak[name] ~= controls.sneak then player_anim[name] = nil player_sneak[name] = controls.sneak @@ -219,62 +243,3 @@ minetest.register_globalstep(function(dtime) end end end) - --- Don't change HP if the player falls in the water or through End Portal: -minetest.register_on_player_hpchange(function(player, hp_change, reason) - if reason and reason.type == "fall" and player then - local pos = player:get_pos() - local node = minetest.get_node(pos) - local velocity = player:get_velocity() or player:get_player_velocity() or {x=0,y=-10,z=0} - local v_axis_max = math.max(math.abs(velocity.x), math.abs(velocity.y), math.abs(velocity.z)) - local step = {x = velocity.x / v_axis_max, y = velocity.y / v_axis_max, z = velocity.z / v_axis_max} - for i = 1, math.ceil(v_axis_max/5)+1 do -- trace at least 1/5 of the way per second - if not node or node.name == "ignore" then - minetest.get_voxel_manip():read_from_map(pos, pos) - node = minetest.get_node(pos) - end - if node then - if minetest.registered_nodes[node.name].walkable then - return hp_change - end - if minetest.get_item_group(node.name, "water") ~= 0 then - return 0 - end - if node.name == "mcl_portals:portal_end" then - if mcl_portals and mcl_portals.end_teleport then - mcl_portals.end_teleport(player) - end - return 0 - end - end - pos = vector.add(pos, step) - node = minetest.get_node(pos) - end - end - return hp_change -end, true) - -minetest.register_on_respawnplayer(function(player) - local pos = player:get_pos() - minetest.add_particlespawner({ - amount = 50, - time = 0.001, - minpos = vector.add(pos, 0), - maxpos = vector.add(pos, 0), - minvel = vector.new(-5,-5,-5), - maxvel = vector.new(5,5,5), - minexptime = 1.1, - maxexptime = 1.5, - minsize = 1, - maxsize = 2, - collisiondetection = false, - vertical = false, - texture = "mcl_particles_mob_death.png^[colorize:#000000:255", - }) - - minetest.sound_play("mcl_mobs_mob_poof", { - pos = pos, - gain = 1.0, - max_hear_distance = 8, - }, true) -end) diff --git a/mods/PLAYER/mcl_playerinfo/init.lua b/mods/PLAYER/mcl_playerinfo/init.lua index 5086f319..9c5d1433 100644 --- a/mods/PLAYER/mcl_playerinfo/init.lua +++ b/mods/PLAYER/mcl_playerinfo/init.lua @@ -1,3 +1,5 @@ +local table = table + -- Player state for public API mcl_playerinfo = {} @@ -21,7 +23,7 @@ end local time = 0 -local get_player_nodes = function(player_pos) +local function get_player_nodes(player_pos) local work_pos = table.copy(player_pos) -- what is around me? diff --git a/mods/PLAYER/mcl_playerinfo/mod.conf b/mods/PLAYER/mcl_playerinfo/mod.conf index 9f2b0c4a..25c05f03 100644 --- a/mods/PLAYER/mcl_playerinfo/mod.conf +++ b/mods/PLAYER/mcl_playerinfo/mod.conf @@ -1,4 +1,4 @@ name = mcl_playerinfo author = TenPlus1 description = This is a helper mod for other mod to query the nodes around the player. -depends = mcl_init, mcl_core, mcl_particles, mcl_death_messages +depends = mcl_init, mcl_core, mcl_particles diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index de346256..fc8dbcd5 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -1,5 +1,8 @@ -local S = minetest.get_translator("mcl_playerplus") +mcl_playerplus = { + elytra = {}, +} +local player_velocity_old = {x=0, y=0, z=0} local get_connected_players = minetest.get_connected_players local dir_to_yaw = minetest.dir_to_yaw local get_item_group = minetest.get_item_group @@ -19,13 +22,13 @@ local math = math -- Internal player state local mcl_playerplus_internal = {} -local def = {} local time = 0 +local look_pitch = 0 -local player_collision = function(player) +local function player_collision(player) local pos = player:get_pos() - local vel = player:get_velocity() + --local vel = player:get_velocity() local x = 0 local z = 0 local width = .75 @@ -45,8 +48,7 @@ local player_collision = function(player) z = z + (vec.z * force) end end - - return({x,z}) + return {x,z} end -- converts yaw to degrees @@ -54,18 +56,8 @@ local function degrees(rad) return rad * 180.0 / math.pi end -local pi = math.pi -local atann = math.atan -local atan = function(x) - if not x or x ~= x then - return 0 - else - return atann(x) - end -end - -local dir_to_pitch = function(dir) - local dir2 = vector.normalize(dir) +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 @@ -117,38 +109,7 @@ function limit_vel_yaw(player_vel_yaw, yaw) return player_vel_yaw end -local pitch, name, node_stand, node_stand_below, node_head, node_feet, pos - - -minetest.register_on_punchplayer(function(player, hitter, damage) - if hitter:is_player() then - if hitter:get_player_control().aux1 then - player:add_velocity(hitter:get_velocity()) - end - if hitter:get_velocity().y < -6 then - player:set_hp(player:get_hp() - (damage * math.random(0.50 , 0.75))) - local pos = player:get_pos() - 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 -end) - +local node_stand, node_stand_below, node_head, node_feet minetest.register_globalstep(function(dtime) @@ -156,13 +117,6 @@ minetest.register_globalstep(function(dtime) for _,player in pairs(get_connected_players()) do - c_x, c_y = unpack(player_collision(player)) - - if player:get_velocity().x + player:get_velocity().y < .5 and c_x + c_y > 0 then - --minetest.chat_send_player(player:get_player_name(), "pushed at " .. c_x + c_y .. " parsecs.") - player:add_velocity({x=c_x, y=0, z=c_y}) - end - --[[ _ _ _ __ _ _ __ (_)_ __ ___ __ _| |_(_) ___ _ __ ___ @@ -172,14 +126,23 @@ minetest.register_globalstep(function(dtime) ]]-- - local controls = player:get_player_control() + local control = player:get_player_control() local name = player:get_player_name() - local meta = player:get_meta() + --local meta = player:get_meta() local parent = player:get_attach() local wielded = player:get_wielded_item() local player_velocity = player:get_velocity() or player:get_player_velocity() + local wielded_def = wielded:get_definition() - -- controls head bone + local c_x, c_y = unpack(player_collision(player)) + + if player_velocity.x + player_velocity.y < .5 and c_x + c_y > 0 then + local add_velocity = player.add_player_velocity or player.add_velocity + add_velocity(player, {x = c_x, y = 0, z = c_y}) + player_velocity = player:get_velocity() or player:get_player_velocity() + end + + -- control head bone local pitch = - degrees(player:get_look_vertical()) local yaw = degrees(player:get_look_horizontal()) @@ -190,12 +153,83 @@ minetest.register_globalstep(function(dtime) player_vel_yaw = limit_vel_yaw(player_vel_yaw, yaw) player_vel_yaws[name] = player_vel_yaw + local fly_pos = player:get_pos() + local fly_node = minetest.get_node({x = fly_pos.x, y = fly_pos.y - 0.5, z = fly_pos.z}).name + local elytra = mcl_playerplus.elytra[player] + + elytra.active = player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" + and not player:get_attach() + and (elytra.active or control.jump and player_velocity.y < -6) + and (fly_node == "air" or fly_node == "ignore") + + if elytra.active then + if player_velocity.x < (player_velocity_old.x - 10) or player_velocity.x > (player_velocity_old.x + 10) and fly_node ~= "ignore" then + mcl_util.deal_damage(player, math.abs(player_velocity_old.x) * 0.2, {type = "fly_into_wall"}) + end + if player_velocity.z < (player_velocity_old.z - 10) or player_velocity.z > (player_velocity_old.z + 10) and fly_node ~= "ignore" then + mcl_util.deal_damage(player, math.abs(player_velocity_old.z) * 0.2, {type = "fly_into_wall"}) + end + mcl_player.player_set_animation(player, "fly") + if player_velocity.y < -1.5 then + player:add_velocity({x=0, y=0.17, z=0}) + end + if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then + local dir = minetest.yaw_to_dir(player:get_look_horizontal()) + if degrees(player:get_look_vertical()) * -.01 < .1 then + look_pitch = degrees(player:get_look_vertical()) * -.01 + else + look_pitch = .1 + end + player:add_velocity({x=dir.x, y=look_pitch, z=dir.z}) + end + playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1) + + if elytra.rocketing > 0 then + elytra.rocketing = elytra.rocketing - dtime + if vector.length(player_velocity) < 40 then + local add_velocity = player.add_velocity or player.add_player_velocity + add_velocity(player, vector.multiply(player:get_look_dir(), 4)) + minetest.add_particlespawner({ + amount = 1, + time = 0.1, + minpos = fly_pos, + maxpos = fly_pos, + 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.3, + maxexptime = 0.5, + minsize = 1, + maxsize = 2.5, + collisiondetection = false, + vertical = false, + texture = "mcl_particles_crit.png^[colorize:#bc7a57:127", + glow = 5, + }) + end + end + else + elytra.rocketing = 0 + playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra") + end + + if wielded_def and wielded_def._mcl_toollike_wield then + 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)) + 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 controls.RMB and not controls.LMB and not controls.up and not controls.down and not controls.left and not controls.right then + 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 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)) -- when punching - elseif controls.LMB and not parent then + 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)) player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0)) -- when holding an item. @@ -208,21 +242,28 @@ minetest.register_globalstep(function(dtime) player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(0,0,0)) end - if parent then + if elytra.active then + -- set head pitch and yaw when flying + player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) + -- sets eye height, and nametag color accordingly + player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) + -- control body bone when flying + player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0)) + elseif parent then local parent_yaw = degrees(parent:get_yaw()) player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) - player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0)) + player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0)) - elseif controls.sneak then + elseif control.sneak then -- controls head pitch when sneaking - player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+36,0,0)) + player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, player_vel_yaw - yaw)) -- sets eye height, and nametag color accordingly player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.35, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) -- sneaking body conrols - player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0)) + player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0)) elseif get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 and is_sprinting(name) == true then -- set head pitch and yaw when swimming - player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) + player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) -- sets eye height, and nametag color accordingly player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,0.8,0.312}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) -- control body bone when swimming @@ -231,7 +272,7 @@ minetest.register_globalstep(function(dtime) -- sets eye height, and nametag color accordingly player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) - player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0)) + player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0)) end @@ -242,9 +283,9 @@ minetest.register_globalstep(function(dtime) mcl_playerplus_internal[name].jump_cooldown = mcl_playerplus_internal[name].jump_cooldown - dtime end - if controls.jump and mcl_playerplus_internal[name].jump_cooldown <= 0 then + if control.jump and mcl_playerplus_internal[name].jump_cooldown <= 0 then - pos = player:get_pos() + --pos = player:get_pos() node_stand = mcl_playerinfo[name].node_stand node_stand_below = mcl_playerinfo[name].node_stand_below @@ -316,9 +357,6 @@ minetest.register_globalstep(function(dtime) return end - -- set defaults - def.speed = 1 - -- Standing on soul sand? If so, walk slower (unless player wears Soul Speed boots) if node_stand == "mcl_nether:soul_sand" then -- TODO: Tweak walk speed @@ -359,8 +397,7 @@ minetest.register_globalstep(function(dtime) -- Check privilege, too and (not check_player_privs(name, {noclip = true})) then if player:get_hp() > 0 then - mcl_death_messages.player_damage(player, S("@1 suffocated to death.", name)) - player:set_hp(player:get_hp() - 1) + mcl_util.deal_damage(player, 1, {type = "in_wall"}) end end @@ -375,8 +412,7 @@ minetest.register_globalstep(function(dtime) local dist_feet = vector.distance({x=pos.x, y=pos.y-1, z=pos.z}, near) if dist < 1.1 or dist_feet < 1.1 then if player:get_hp() > 0 then - mcl_death_messages.player_damage(player, S("@1 was prickled to death by a cactus.", name)) - player:set_hp(player:get_hp() - 1, { type = "punch", from = "mod" }) + mcl_util.deal_damage(player, 1, {type = "cactus"}) end end end @@ -473,6 +509,7 @@ minetest.register_on_joinplayer(function(player) swimDistance = 0, jump_cooldown = -1, -- Cooldown timer for jumping, we need this to prevent the jump exhaustion to increase rapidly } + mcl_playerplus.elytra[player] = {active = false, rocketing = 0} end) -- clear when player leaves @@ -480,4 +517,69 @@ minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() mcl_playerplus_internal[name] = nil + mcl_playerplus.elytra[player] = nil +end) + +-- Don't change HP if the player falls in the water or through End Portal: +mcl_damage.register_modifier(function(obj, damage, reason) + if reason.type == "fall" then + local pos = obj:get_pos() + local node = minetest.get_node(pos) + local velocity = obj:get_velocity() or obj:get_player_velocity() or {x=0,y=-10,z=0} + local v_axis_max = math.max(math.abs(velocity.x), math.abs(velocity.y), math.abs(velocity.z)) + local step = {x = velocity.x / v_axis_max, y = velocity.y / v_axis_max, z = velocity.z / v_axis_max} + for i = 1, math.ceil(v_axis_max/5)+1 do -- trace at least 1/5 of the way per second + if not node or node.name == "ignore" then + minetest.get_voxel_manip():read_from_map(pos, pos) + node = minetest.get_node(pos) + end + if node then + if minetest.registered_nodes[node.name].walkable then + return + end + if minetest.get_item_group(node.name, "water") ~= 0 then + return 0 + end + if node.name == "mcl_portals:portal_end" then + if mcl_portals and mcl_portals.end_teleport then + mcl_portals.end_teleport(obj) + end + return 0 + end + if node.name == "mcl_core:cobweb" then + return 0 + end + if node.name == "mcl_core:vine" then + return 0 + end + end + pos = vector.add(pos, step) + node = minetest.get_node(pos) + end + end +end, -200) + +minetest.register_on_respawnplayer(function(player) + local pos = player:get_pos() + minetest.add_particlespawner({ + amount = 50, + time = 0.001, + minpos = vector.add(pos, 0), + maxpos = vector.add(pos, 0), + minvel = vector.new(-5,-5,-5), + maxvel = vector.new(5,5,5), + minexptime = 1.1, + maxexptime = 1.5, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "mcl_particles_mob_death.png^[colorize:#000000:255", + }) + + minetest.sound_play("mcl_mobs_mob_poof", { + pos = pos, + gain = 1.0, + max_hear_distance = 8, + }, true) end) diff --git a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.de.tr b/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.de.tr deleted file mode 100644 index 44d486d0..00000000 --- a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.de.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.=@1 erstickte zu Tode. -@1 was prickled to death by a cactus.=@1 wurde von einem Kaktus zu Tode gepiekst. diff --git a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.es.tr b/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.es.tr deleted file mode 100644 index ef7705bc..00000000 --- a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.es.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.=@1 ahogado hasta la muerte. -@1 was prickled to death by a cactus.=@1 fue herido de muerte por un cactus. diff --git a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.fr.tr b/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.fr.tr deleted file mode 100644 index 6482bd73..00000000 --- a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.fr.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.=@1 étouffé à mort. -@1 was prickled to death by a cactus.=@1 a été piqué à mort par un cactus. diff --git a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.ru.tr b/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.ru.tr deleted file mode 100644 index a75bd4bd..00000000 --- a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.ru.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.=@1 задохнулся(ась). -@1 was prickled to death by a cactus.=@1 был(а) до смерти заколот(а) кактусом. diff --git a/mods/PLAYER/mcl_playerplus/locale/template.txt b/mods/PLAYER/mcl_playerplus/locale/template.txt deleted file mode 100644 index 49b1f96a..00000000 --- a/mods/PLAYER/mcl_playerplus/locale/template.txt +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.= -@1 was prickled to death by a cactus.= diff --git a/mods/PLAYER/mcl_playerplus/mod.conf b/mods/PLAYER/mcl_playerplus/mod.conf index 95121f8e..6989957d 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, mcl_death_messages, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting +depends = mcl_init, mcl_core, mcl_particles, mcl_hunger, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting, mcl_damage diff --git a/mods/PLAYER/mcl_skins/init.lua b/mods/PLAYER/mcl_skins/init.lua index 5956aab7..6d5461a9 100644 --- a/mods/PLAYER/mcl_skins/init.lua +++ b/mods/PLAYER/mcl_skins/init.lua @@ -1,13 +1,14 @@ -- Skins for MineClone 2 +local modname = minetest.get_current_modname() + mcl_skins = { skins = {}, list = {}, previews = {}, meta = {}, has_preview = {}, - modpath = minetest.get_modpath("mcl_skins"), + modpath = minetest.get_modpath(modname), skin_count = 0, -- counter of _custom_ skins (all skins except character.png) } -local S = minetest.get_translator("mcl_skins") -local has_mcl_armor = minetest.get_modpath("mcl_armor") +local S = minetest.get_translator(modname) local has_mcl_inventory = minetest.get_modpath("mcl_inventory") -- load skin list and metadata @@ -54,7 +55,7 @@ while true do data = nil if f then - data = minetest.deserialize("return {" .. f:read('*all') .. "}") + data = minetest.deserialize("return {" .. f:read("*all") .. "}") f:close() end @@ -71,7 +72,7 @@ while true do id = id + 1 end -mcl_skins.cycle_skin = function(player) +function mcl_skins.cycle_skin(player) local skin_id = tonumber(player:get_meta():get_string("mcl_skins:skin_id")) if not skin_id then skin_id = 0 @@ -83,12 +84,12 @@ mcl_skins.cycle_skin = function(player) mcl_skins.set_player_skin(player, skin_id) end -mcl_skins.set_player_skin = function(player, skin_id) +function mcl_skins.set_player_skin(player, skin_id) if not player then return false end local playername = player:get_player_name() - local skin, skin_file, preview + local skin, preview if skin_id == nil or type(skin_id) ~= "number" or skin_id < 0 or skin_id > mcl_skins.skin_count then return false elseif skin_id == 0 then @@ -110,15 +111,11 @@ mcl_skins.set_player_skin = function(player, skin_id) preview = "mcl_skins_player_dummy" end end - skin_file = skin .. ".png" + --local skin_file = skin .. ".png" mcl_skins.skins[playername] = skin mcl_skins.previews[playername] = preview player:get_meta():set_string("mcl_skins:skin_id", tostring(skin_id)) mcl_skins.update_player_skin(player) - if has_mcl_armor then - armor.textures[playername].skin = skin_file - armor:update_player_visuals(player) - end if has_mcl_inventory then mcl_inventory.update_inventory_formspec(player) end @@ -129,22 +126,21 @@ mcl_skins.set_player_skin = function(player, skin_id) return true end -mcl_skins.update_player_skin = function(player) +function mcl_skins.update_player_skin(player) if not player then return end local playername = player:get_player_name() - mcl_player.player_set_textures(player, { mcl_skins.skins[playername] .. ".png" }, mcl_skins.previews[playername] .. ".png" ) + mcl_player.player_set_skin(player, mcl_skins.skins[playername] .. ".png", mcl_skins.previews[playername] .. ".png") end -- load player skin on join minetest.register_on_joinplayer(function(player) - local name = player:get_player_name() local skin_id = player:get_meta():get_string("mcl_skins:skin_id") local set_skin -- do we already have a skin in player attributes? - if skin_id ~= nil and skin_id ~= "" then + if skin_id and skin_id ~= "" then set_skin = tonumber(skin_id) -- otherwise use random skin if not set end @@ -161,7 +157,7 @@ end) mcl_skins.registered_on_set_skins = {} -mcl_skins.register_on_set_skin = function(func) +function mcl_skins.register_on_set_skin(func) table.insert(mcl_skins.registered_on_set_skins, func) end @@ -198,7 +194,6 @@ minetest.register_chatcommand("setskin", { end end - local skin local ok = mcl_skins.set_player_skin(player, skin_id) if not ok then return false, S("Invalid skin number! Valid numbers: 0 to @1", mcl_skins.skin_count) @@ -227,7 +222,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if mcl_skins.skin_count <= 6 then -- Change skin immediately if there are not many skins mcl_skins.cycle_skin(player) - if player:get_attach() ~= nil then + if player:get_attach() then mcl_player.player_set_animation(player, "sit") end else @@ -237,10 +232,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end) -mcl_skins.show_formspec = function(playername) +function mcl_skins.show_formspec(playername) local formspec = "size[7,8.5]" - formspec = formspec .. "label[2,2;" .. minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Select player skin:"))) .. "]" + formspec = formspec .. "label[2,2;" .. minetest.formspec_escape(minetest.colorize("#383838", S("Select player skin:"))) .. "]" .. "textlist[0,2.5;6.8,6;skins_set;" local meta @@ -268,7 +263,7 @@ mcl_skins.show_formspec = function(playername) if meta then if meta.name and meta.name ~= "" then - formspec = formspec .. "label[2,0.5;" .. minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Name: @1", meta.name))) .. "]" + formspec = formspec .. "label[2,0.5;" .. minetest.formspec_escape(minetest.colorize("#383838", S("Name: @1", meta.name))) .. "]" end end diff --git a/mods/PLAYER/mcl_skins/intllib.lua b/mods/PLAYER/mcl_skins/intllib.lua deleted file mode 100644 index 6669d720..00000000 --- a/mods/PLAYER/mcl_skins/intllib.lua +++ /dev/null @@ -1,45 +0,0 @@ - --- Fallback functions for when `intllib` is not installed. --- Code released under Unlicense . - --- Get the latest version of this file at: --- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua - -local function format(str, ...) - local args = { ... } - local function repl(escape, open, num, close) - if escape == "" then - local replacement = tostring(args[tonumber(num)]) - if open == "" then - replacement = replacement..close - end - return replacement - else - return "@"..open..num..close - end - end - return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl)) -end - -local gettext, ngettext -if minetest.get_modpath("intllib") then - if intllib.make_gettext_pair then - -- New method using gettext. - gettext, ngettext = intllib.make_gettext_pair() - else - -- Old method using text files. - gettext = intllib.Getter() - end -end - --- Fill in missing functions. - -gettext = gettext or function(msgid, ...) - return format(msgid, ...) -end - -ngettext = ngettext or function(msgid, msgid_plural, n, ...) - return format(n==1 and msgid or msgid_plural, ...) -end - -return gettext, ngettext diff --git a/mods/PLAYER/mcl_skins/mod.conf b/mods/PLAYER/mcl_skins/mod.conf index 6ccbe98f..657d3cc0 100644 --- a/mods/PLAYER/mcl_skins/mod.conf +++ b/mods/PLAYER/mcl_skins/mod.conf @@ -2,4 +2,4 @@ name = mcl_skins author = TenPlus1 description = Mod that allows players to set their individual skins. depends = mcl_player -optional_depends = mcl_inventory, intllib, mcl_armor +optional_depends = mcl_inventory, intllib diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index fe88cf3d..113a4d27 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -1,6 +1,6 @@ mcl_spawn = {} -local S = minetest.get_translator("mcl_spawn") +local S = minetest.get_translator(minetest.get_current_modname()) local mg_name = minetest.get_mapgen_setting("mg_name") local storage = minetest.get_mod_storage() @@ -379,7 +379,7 @@ function mcl_spawn.search() end -mcl_spawn.get_world_spawn_pos = function() +function mcl_spawn.get_world_spawn_pos() local ssp = minetest.setting_get_pos("static_spawnpoint") if ssp then return ssp @@ -395,11 +395,11 @@ end -- If player is nil or not a player, a world spawn point is returned. -- The second return value is true if returned spawn point is player-chosen, -- false otherwise. -mcl_spawn.get_bed_spawn_pos = function(player) +function mcl_spawn.get_bed_spawn_pos(player) local spawn, custom_spawn = nil, false - if player ~= nil and player:is_player() then + if player and player:is_player() then local attr = player:get_meta():get_string("mcl_beds:spawn") - if attr ~= nil and attr ~= "" then + if attr and attr ~= "" then spawn = minetest.string_to_pos(attr) custom_spawn = true end @@ -415,7 +415,7 @@ end -- Set pos to nil to clear the spawn position. -- If message is set, informs the player with a chat message when the spawn position -- changed. -mcl_spawn.set_spawn_pos = function(player, pos, message) +function mcl_spawn.set_spawn_pos(player, pos, message) local spawn_changed = false local meta = player:get_meta() if pos == nil then @@ -443,7 +443,7 @@ mcl_spawn.set_spawn_pos = function(player, pos, message) return spawn_changed end -mcl_spawn.get_player_spawn_pos = function(player) +function mcl_spawn.get_player_spawn_pos(player) local pos, custom_spawn = mcl_spawn.get_bed_spawn_pos(player) if pos and custom_spawn then -- Check if bed is still there @@ -451,7 +451,7 @@ mcl_spawn.get_player_spawn_pos = function(player) local bgroup = minetest.get_item_group(node_bed.name, "bed") if bgroup ~= 1 and bgroup ~= 2 then -- Bed is destroyed: - if player ~= nil and player:is_player() then + if player and player:is_player() then player:get_meta():set_string("mcl_beds:spawn", "") end minetest.chat_send_player(player:get_player_name(), S("Your spawn bed was missing or blocked.")) @@ -482,7 +482,7 @@ mcl_spawn.get_player_spawn_pos = function(player) return mcl_spawn.get_world_spawn_pos(), false end -mcl_spawn.spawn = function(player) +function mcl_spawn.spawn(player) local pos, in_bed = mcl_spawn.get_player_spawn_pos(player) player:set_pos(pos) return in_bed or success @@ -500,10 +500,8 @@ function mcl_spawn.shadow_worker() if success then local wsp_node = minetest.get_node(wsp) - if wsp_node and wsp_node.name == "ignore" then - -- special case - respawn area unloaded from memory - it's okay, skip for now - - elseif ((not good_for_respawn(wsp)) or ((no_trees_area_counter >= 0) and not can_find_tree(wsp))) then + if not (wsp_node and wsp_node.name == "ignore") + and ((not good_for_respawn(wsp)) or ((no_trees_area_counter >= 0) and not can_find_tree(wsp))) then success = false minetest.log("action", "[mcl_spawn] World spawn position isn't safe anymore: "..minetest.pos_to_string(wsp)) mcl_spawn.search() diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 9dc67800..73a518c4 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -7,6 +7,22 @@ to this software to the public domain worldwide. This software is distributed without any warranty. ]] +local math = math +local vector = vector + +local pairs = pairs + +local get_node = minetest.get_node +local get_gametime = minetest.get_gametime +local add_particlespawner = minetest.add_particlespawner +local get_player_by_name = minetest.get_player_by_name + +local registered_nodes = minetest.registered_nodes + +local get_hunger = mcl_hunger.get_hunger +local exhaust = mcl_hunger.exhaust + + --Configuration variables, these are all explained in README.md mcl_sprint = {} @@ -16,7 +32,7 @@ local players = {} -- Returns true if the player with the given name is sprinting, false if not. -- Returns nil if player does not exist. -mcl_sprint.is_sprinting = function(playername) +function mcl_sprint.is_sprinting(playername) if players[playername] then return players[playername].sprinting else @@ -53,7 +69,10 @@ 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 - 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 + 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 @@ -65,7 +84,10 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player if sprinting == true then playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) end - elseif sprinting == false 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 + elseif sprinting == false + 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) if sprinting == false then @@ -127,12 +149,12 @@ end) minetest.register_globalstep(function(dtime) --Get the gametime - local gameTime = minetest.get_gametime() + local gameTime = get_gametime() --Loop through all connected players - for playerName,playerInfo in pairs(players) do - local player = minetest.get_player_by_name(playerName) - if player ~= nil then + for playerName, playerInfo in pairs(players) do + local player = get_player_by_name(playerName) + if player then local ctrl = player:get_player_control() --Check if the player should be sprinting if players[playerName]["clientSprint"] or ctrl.aux1 and ctrl.up and not ctrl.sneak then @@ -144,22 +166,21 @@ minetest.register_globalstep(function(dtime) local playerPos = player:get_pos() --If the player is sprinting, create particles behind and cause exhaustion if playerInfo["sprinting"] == true and not player:get_attach() and gameTime % 0.1 == 0 then - -- Exhaust player for sprinting local lastPos = players[playerName].lastPos local dist = vector.distance({x=lastPos.x, y=0, z=lastPos.z}, {x=playerPos.x, y=0, z=playerPos.z}) players[playerName].sprintDistance = players[playerName].sprintDistance + dist if players[playerName].sprintDistance >= 1 then local superficial = math.floor(players[playerName].sprintDistance) - mcl_hunger.exhaust(playerName, mcl_hunger.EXHAUST_SPRINT * superficial) + exhaust(playerName, mcl_hunger.EXHAUST_SPRINT * superficial) players[playerName].sprintDistance = players[playerName].sprintDistance - superficial end -- Sprint node particles - local playerNode = minetest.get_node({x=playerPos["x"], y=playerPos["y"]-1, z=playerPos["z"]}) - local def = minetest.registered_nodes[playerNode.name] + local playerNode = get_node({x=playerPos["x"], y=playerPos["y"]-1, z=playerPos["z"]}) + local def = registered_nodes[playerNode.name] if def and def.walkable then - minetest.add_particlespawner({ + add_particlespawner({ amount = math.random(1, 2), time = 1, minpos = {x=-0.5, y=0.1, z=-0.5}, @@ -186,7 +207,8 @@ minetest.register_globalstep(function(dtime) if players[playerName]["shouldSprint"] == true then --Stopped local sprinting -- Prevent sprinting if hungry or sleeping - if (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then + if (mcl_hunger.active and get_hunger(player) <= 6) + or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then sprinting = false cancelClientSprinting(playerName) else diff --git a/mods/PLAYER/wieldview/LICENSE.txt b/mods/PLAYER/mcl_wieldview/LICENSE.txt similarity index 100% rename from mods/PLAYER/wieldview/LICENSE.txt rename to mods/PLAYER/mcl_wieldview/LICENSE.txt diff --git a/mods/PLAYER/wieldview/README.txt b/mods/PLAYER/mcl_wieldview/README.txt similarity index 100% rename from mods/PLAYER/wieldview/README.txt rename to mods/PLAYER/mcl_wieldview/README.txt diff --git a/mods/PLAYER/mcl_wieldview/init.lua b/mods/PLAYER/mcl_wieldview/init.lua new file mode 100644 index 00000000..7200f618 --- /dev/null +++ b/mods/PLAYER/mcl_wieldview/init.lua @@ -0,0 +1,122 @@ +local get_connected_players = minetest.get_connected_players +local get_item_group = minetest.get_item_group + +mcl_wieldview = { + players = {} +} + +function mcl_wieldview.get_item_texture(itemname) + if itemname == "" then + return + end + + local def = minetest.registered_items[itemname] + if not def then + return + end + + local inv_image = def.inventory_image + if inv_image == "" then + return + end + + local texture = inv_image + + local transform = get_item_group(itemname, "wieldview_transform") + if transform then + -- This actually works with groups ratings because transform1, transform2, etc. + -- have meaning and transform0 is used for identidy, so it can be ignored + texture = texture .. "^[transform" .. transform + end + + return texture +end + +function mcl_wieldview.update_wielded_item(player) + if not player then + return + end + local itemstack = player:get_wielded_item() + local itemname = itemstack:get_name() + + local def = mcl_wieldview.players[player] + + if def.item == itemname then + return + end + + def.item = itemname + def.texture = mcl_wieldview.get_item_texture(itemname) or "blank.png" + + mcl_player.player_set_wielditem(player, def.texture) +end + +minetest.register_on_joinplayer(function(player) + mcl_wieldview.players[player] = {item = "", texture = "blank.png"} + + minetest.after(0, function() + if not player:is_player() then + return + end + + mcl_wieldview.update_wielded_item(player) + + local itementity = minetest.add_entity(player:get_pos(), "mcl_wieldview:wieldnode") + itementity:set_attach(player, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 0, 45)) + itementity:get_luaentity().wielder = player + end) +end) + +minetest.register_on_leaveplayer(function(player) + mcl_wieldview.players[player] = nil +end) + +minetest.register_globalstep(function() + local players = get_connected_players() + for i = 1, #players do + mcl_wieldview.update_wielded_item(players[i]) + end +end) + +minetest.register_entity("mcl_wieldview:wieldnode", { + initial_properties = { + hp_max = 1, + visual = "wielditem", + physical = false, + textures = {""}, + automatic_rotate = 1.5, + is_visible = true, + pointable = false, + collide_with_objects = false, + static_save = false, + collisionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21}, + selectionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21}, + visual_size = {x = 0.21, y = 0.21}, + }, + + itemstring = "", + + on_step = function(self) + if self.wielder:is_player() then + local def = mcl_wieldview.players[self.wielder] + local itemstring = def.item + + if self.itemstring ~= itemstring then + local itemdef = minetest.registered_items[itemstring] + self.object:set_properties({glow = itemdef and itemdef.light_source or 0}) + + -- wield item as cubic + if def.texture == "blank.png" then + self.object:set_properties({textures = {itemstring}}) + -- wield item as flat + else + self.object:set_properties({textures = {""}}) + end + + self.itemstring = itemstring + end + else + self.object:remove() + end + end, +}) diff --git a/mods/PLAYER/wieldview/mod.conf b/mods/PLAYER/mcl_wieldview/mod.conf similarity index 66% rename from mods/PLAYER/wieldview/mod.conf rename to mods/PLAYER/mcl_wieldview/mod.conf index 4cd2a693..4b309787 100644 --- a/mods/PLAYER/wieldview/mod.conf +++ b/mods/PLAYER/mcl_wieldview/mod.conf @@ -1,5 +1,4 @@ -name = wieldview +name = mcl_wieldview author = stujones11 description = Makes hand wielded items visible to other players. -depends = mcl_armor - +depends = mcl_player diff --git a/mods/PLAYER/wieldview/init.lua b/mods/PLAYER/wieldview/init.lua deleted file mode 100644 index 7a349f2f..00000000 --- a/mods/PLAYER/wieldview/init.lua +++ /dev/null @@ -1,132 +0,0 @@ -local time = 0 -local update_time = tonumber(minetest.settings:get("wieldview_update_time")) -if not update_time then - update_time = 2 - minetest.settings:set("wieldview_update_time", tostring(update_time)) -end -local node_tiles = minetest.settings:get_bool("wieldview_node_tiles") -if not node_tiles then - node_tiles = false - minetest.settings:set("wieldview_node_tiles", "false") -end - -wieldview = { - wielded_item = {}, - transform = {}, -} - -dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua") - -wieldview.get_item_texture = function(self, item) - local texture = "blank.png" - if item ~= "" then - if minetest.registered_items[item] then - if minetest.registered_items[item].inventory_image ~= "" then - texture = minetest.registered_items[item].inventory_image - elseif node_tiles == true and minetest.registered_items[item].tiles - and type(minetest.registered_items[item].tiles[1]) == "string" - and minetest.registered_items[item].tiles[1] ~= "" then - texture = minetest.inventorycube(minetest.registered_items[item].tiles[1]) - end - end - -- Get item image transformation, first from group, then from transform.lua - local transform = minetest.get_item_group(item, "wieldview_transform") - if transform == 0 then - transform = wieldview.transform[item] - end - if transform then - -- This actually works with groups ratings because transform1, transform2, etc. - -- have meaning and transform0 is used for identidy, so it can be ignored - texture = texture.."^[transform"..tostring(transform) - end - end - return texture -end - -wieldview.update_wielded_item = function(self, player) - if not player then - return - end - local name = player:get_player_name() - local stack = player:get_wielded_item() - local item = stack:get_name() - if not item then - return - end - if self.wielded_item[name] then - if self.wielded_item[name] == item then - return - end - if not armor.textures[name] then - return - end - armor.textures[name].wielditem = self:get_item_texture(item) - armor:update_player_visuals(player) - end - self.wielded_item[name] = item -end - -minetest.register_on_joinplayer(function(player) - local name = player:get_player_name() - wieldview.wielded_item[name] = "" - minetest.after(0, function(player) - -- if the player left :is_player() will return nil - if not player:is_player() then - return - end - wieldview:update_wielded_item(player) - local itementity = minetest.add_entity(player:get_pos(), "wieldview:wieldnode") - itementity:set_attach(player, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 0, 45)) - itementity:get_luaentity().wielder = name - end, player) -end) - -minetest.register_globalstep(function() - for _,player in pairs(minetest.get_connected_players()) do - wieldview:update_wielded_item(player) - end -end) - -minetest.register_entity("wieldview:wieldnode", { - initial_properties = { - hp_max = 1, - visual = "wielditem", - physical = false, - textures = {""}, - automatic_rotate = 1.5, - is_visible = true, - pointable = false, - collide_with_objects = false, - static_save = false, - collisionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21}, - selectionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21}, - visual_size = {x = 0.21, y = 0.21}, - }, - - itemstring = "", - - on_step = function(self) - local player = minetest.get_player_by_name(self.wielder) - if player then - local wielded = player:get_wielded_item() - local itemstring = wielded:get_name() - - if self.itemstring ~= itemstring then - local def = minetest.registered_items[itemstring] - self.object:set_properties({glow = def and def.light_source or 0}) - - -- wield item as cubic - if armor.textures[self.wielder].wielditem == "blank.png" then - self.object:set_properties({textures = {itemstring}}) - -- wield item as flat - else - self.object:set_properties({textures = {""}}) - end - - self.itemstring = itemstring - end - else - self.object:remove() - end - end, -}) diff --git a/mods/PLAYER/wieldview/transform.lua b/mods/PLAYER/wieldview/transform.lua deleted file mode 100644 index a1995679..00000000 --- a/mods/PLAYER/wieldview/transform.lua +++ /dev/null @@ -1,10 +0,0 @@ --- Wielded Item Transformations - http://dev.minetest.net/texture - -wieldview.transform = { - ["screwdriver:screwdriver"]="R90", - ["screwdriver:screwdriver1"]="R90", - ["screwdriver:screwdriver2"]="R90", - ["screwdriver:screwdriver3"]="R90", - ["screwdriver:screwdriver4"]="R90", -} - diff --git a/settingtypes.txt b/settingtypes.txt index bfda9b3b..78a8122b 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -98,7 +98,7 @@ animated_chests (Animated chests) bool true 3d_player_preview (3D Player preview) bool true # The maximum number of boss bars to simultaniously display on the screen -max_bossbars (Maximum Boss bars) int 4 +max_bossbars (Maximum Boss bars) int 5 [Experimental] # Whether ice is translucent. If disabled, ice is fully opaque. @@ -150,3 +150,6 @@ basic_pseudobiome_villages (Enables very basic, and experimental "pseudobiome-ba # If enabled, will run an LBM to fix the top 1/2 of double plants in mcimported worlds; defaults to true. fix_doubleplants (Mcimport double plant fixes) bool true + +# Allow players to create Minecraft-like maps. +enable_real_maps (Enable Real Maps) bool true diff --git a/tools/README.md b/tools/README.md index abcc73ae..4dc378bc 100644 --- a/tools/README.md +++ b/tools/README.md @@ -27,3 +27,17 @@ Usage: - Convert the textures - Put the new texture directory in the Minetest texture pack directory, just like any other Minetest texture pack + +## Luacheck Globals Generators +This is a Python script which list every single global tables in mineclone2 source code. +It outputs a list to be used in luacheck conf files. + +Modes of operation: +- List global tables + +Requirements: +- Know how to use the console +- Python 3 + +Usage: +- In the console, run `python3 ./tools/create_luacheck.py` in the MineClone2 directory diff --git a/tools/Texture_Converter.py b/tools/Texture_Converter.py index c23bc9fc..820fa9c0 100755 --- a/tools/Texture_Converter.py +++ b/tools/Texture_Converter.py @@ -196,6 +196,11 @@ def convert_textures(): if verbose: print(src_file + " → " + dst_file) + # Convert map background + map_background_file = tex_dir + "/map/map_background.png" + if os.path.isfile(map_background_file): + os.system("convert " + map_background_file + " -interpolate Integer -filter point -resize \"140x140\" " + target_dir("/mods/ITEMS/mcl_maps/textures") + "/mcl_maps_map_background.png") + # Convert armor textures (requires ImageMagick) armor_files = [ [ tex_dir + "/models/armor/leather_layer_1.png", tex_dir + "/models/armor/leather_layer_2.png", target_dir("/mods/ITEMS/mcl_armor/textures"), "mcl_armor_helmet_leather.png", "mcl_armor_chestplate_leather.png", "mcl_armor_leggings_leather.png", "mcl_armor_boots_leather.png" ], diff --git a/tools/create_luacheck.py b/tools/create_luacheck.py new file mode 100755 index 00000000..8b55c137 --- /dev/null +++ b/tools/create_luacheck.py @@ -0,0 +1,44 @@ +import os +import re +from pathlib import Path + +# Just run this script from mineclone2 directory to get a list of every global vars to use in luacheck configuration files + +path = "./mods/" + +pattern = re.compile(r'^(?P[A-Za-z_0-9]+)[ ]*=[ ]*\{') +pattern_local = re.compile(r'local (?P[A-Za-z_0-9]+)') + +global_vars = [] + + +print("---Copy/Paste output in your luacheck conf file---\n") + + +pathlist = Path(path).rglob('*.lua') +for path in pathlist: + path_in_str = str(path) + # print(path_in_str) + trouve = False + with open(path_in_str) as f: + local_vars = [] + for i, line in enumerate(f.readlines()): + m = pattern.match(line) + if m: + global_name = m.group('global_var') + if global_name not in local_vars: + #print(path_in_str, ":", i+1, ":", m.group('global_var').strip()) + global_vars.append(m.group('global_var').strip()) + found = True + break + + else: + n = pattern_local.match(line) + if n: + local_vars.append(n.group('local_var')) + + if not found: + nb_varloc = len(variables_locales) + #print(path_in_str, ": -", "({} variables locales)".format(nb_varloc) if nb_varloc > 0 else '') + +print(', '.join(['"{}"'.format(v) for v in global_vars])) diff --git a/tools/create_map_color_file.py b/tools/create_map_color_file.py new file mode 100644 index 00000000..b6486b8e --- /dev/null +++ b/tools/create_map_color_file.py @@ -0,0 +1,59 @@ +import json, os +from PIL import Image + +colors = {} +palettes = {} + +for root, directories, files in os.walk(".."): + if root.endswith("/textures"): + for name in files: + try: + img = Image.open(os.path.join(root, name)).convert("RGBA") + pixels = img.load() + + if "palette" in name: + palette = [] + + for y in range(0, img.size[1]): + for x in range(0, img.size[0]): + r, g, b, a = pixels[x, y] + palette.append((r, g, b)) + + palettes[name] = palette + else: + r_total = 0 + g_total = 0 + b_total = 0 + + count = 0 + + for x in range(0, img.size[0]): + for y in range(0, img.size[1]): + r, g, b, a = pixels[x, y] + if a > 0: + r_total += r / 255 * a + g_total += g / 255 * a + b_total += b / 255 * a + count += a / 255 + + average_color = None + + if count > 0: + average_color = (int(r_total / count), int(g_total / count), int(b_total / count)) + else: + average_color = (255, 255, 255) + + colors[name] = average_color + + img.close() + except IOError: + pass + +path = "../mods/ITEMS/mcl_maps/" + +with open(path + "colors.json", "w") as colorfile: + colorfile.write(json.dumps(colors)) + +with open(path + "palettes.json", "w") as palettefile: + palettefile.write(json.dumps(palettes)) +