Compare commits
1 Commits
master
...
flatconfig
Author | SHA1 | Date |
---|---|---|
Wuzzy | c25d3e574a |
98
API.md
|
@ -1,90 +1,36 @@
|
|||
# API
|
||||
## Groups
|
||||
MineClone 2 makes very extensive use of groups. Making sure your items and objects have the correct group memberships is very important.
|
||||
MineClone 2 makes very extensive use of groups. Making sure your items and objects are members of the correct group is a good and easy way to ensure compability without using any function calls.
|
||||
Groups are explained in `GROUPS.md`.
|
||||
|
||||
## Mod naming convention
|
||||
Mods mods in MineClone 2 follow a simple naming convention: Mods with the prefix “`mcl_`” are specific to MineClone 2, although they may be based on an existing standalone. Mods which lack this prefix are *usually* verbatim copies of a standalone mod. Some modifications may still have been applied, but the APIs are held compatible.
|
||||
## APIs for adding simple things
|
||||
You can add simple things by calling functions in the various MineClone 2 mods.
|
||||
|
||||
## Adding items
|
||||
### Special fields
|
||||
* Fences and fence gates: See `mods/ITEMS/mcl_fences/API.md`.
|
||||
* Walls: See `mods/ITEMS/mcl_walls/API.md`
|
||||
|
||||
Items can have these fields:
|
||||
* `_mcl_generate_description(itemstack)`: Required for any items which manipulate their
|
||||
description in any way. This function takes an itemstack of its own type and must set
|
||||
the proper advanced description for this itemstack. If you don't do this, anvils will
|
||||
fail at properly restoring the description when their custom name gets cleared at an
|
||||
anvil.
|
||||
See `mcl_banners` for an example.
|
||||
### Undocumented APIs
|
||||
You can also add stuff for the following thins, but the APIs are currently undocumented. These mods are very similar to Minetest Game.
|
||||
|
||||
All nodes can have these fields:
|
||||
* Doors: See `mods/ITEMS/doors`
|
||||
* Stairs and slabs: See `mods/ITEMS/stairs` and `mods/ITEMS/mcstair`
|
||||
* Beds: See `mods/ITEMS/beds`
|
||||
* Buckets (for new liquids): See `mods/ITEMS/bucket`
|
||||
* Panes (like glass panes and iron bars): See `mods/ITEMS/xpanes`
|
||||
|
||||
* `_mcl_hardness`: Hardness of the block, ranges from 0 to infinity (represented by -1). Determines digging times. Default: 0
|
||||
* `_mcl_blast_resistance`: How well this block blocks and resists explosions. Default: 0
|
||||
* `_mcl_falling_node_alternative`: If set to an itemstring, the node will turn into this node before it starts to fall.
|
||||
* `_mcl_after_falling(pos)`: Called after a falling node finished falling and turned into a node.
|
||||
|
||||
Use the `mcl_sounds` mod for the sounds.
|
||||
|
||||
## APIs
|
||||
A lot of things are possible by using one of the APIs in the mods. Note that not all APIs are documented yet, but it is planned. The following APIs should be more or less stable but keep in mind that MineClone 2 is still unfinished. All directory names are relative to `mods/`
|
||||
|
||||
### Items
|
||||
* Doors: `ITEMS/mcl_doors`
|
||||
* Fences and fence gates: `ITEMS/mcl_fences`
|
||||
* Stairs and slabs: `ITEM/mcl_stairs`
|
||||
* Walls: `ITEMS/mcl_walls`
|
||||
* Beds: `ITEMS/mcl_beds`
|
||||
* Buckets: `ITEMS/mcl_buckets`
|
||||
* Dispenser support: `ITEMS/REDSTONE/mcl_dispensers`
|
||||
WARNING! These 5 mods may be renamed or changed in future releases, and compability could be broken.
|
||||
|
||||
## Mobs
|
||||
* Mobs: `ENTITIES/mcl_mods`
|
||||
|
||||
MineClone 2 uses its own mobs framework, called “Mobs Redo: MineClone 2 Edition” or “MRM” for short.
|
||||
This is a fork of Mobs Redo [`mobs`] by TenPlus1.
|
||||
|
||||
This mod uses Mobs Redo [`mobs`] by TenPlus1, a very powerful mod for adding mods of various kinds.
|
||||
There are minor modificiations for MineClone 2 compability and some items have been removed or moved to other mods, but the API is identical to the original.
|
||||
You can add your own mobs, spawn eggs and spawning rules with this mod.
|
||||
API documnetation is included in `ENTITIES/mcl_mobs/api.txt`.
|
||||
API documnetation is included in `mods/ENTITIES/mobs/api.txt`.
|
||||
|
||||
This mod includes modificiations from the original Mobs Redo. Some items have been removed or moved to other mods.
|
||||
The API is mostly identical, but a few features have been added. Compability is not really a goal,
|
||||
but function and attribute names of Mobs Redo 1.41 are kept.
|
||||
If you have code for a mod which works fine under Mobs Redo, it should be easy to make it work in MineClone 2,
|
||||
chances are good that it works out of the box.
|
||||
Note that mobs in MineClone 2 are still very experimental, everything about mobs may change radically at any time!
|
||||
|
||||
### Help
|
||||
* Item help texts: `HELP/doc/doc_items`
|
||||
* Low-level help entry and category framework: `HELP/doc/doc`
|
||||
* Support for lookup tool (required for all entities): `HELP/doc/doc_identifier`
|
||||
## Other APIs
|
||||
* Statbars / HUD bars: See `mods/HUD/hudbars`
|
||||
* Hunger: See `mods/PLAYER/mcl_hunger/API.md`
|
||||
|
||||
### HUD
|
||||
* Statbars: `HUD/hudbars`
|
||||
|
||||
### Utility APIs
|
||||
* Change player physics: `PLAYER/playerphysics`
|
||||
* Select random treasures: `CORE/mcl_loot`
|
||||
* Get flowing direction of liquids: `CORE/flowlib`
|
||||
* `on_walk_over` callback for nodes: `CORE/walkover`
|
||||
* Get node names close to player (to reduce constant querying): `PLAYER/mcl_playerinfo`
|
||||
|
||||
### Unstable APIs
|
||||
The following APIs may be subject to change in future. You could already use these APIs but there will probably be breaking changes in the future, or the API is not as fleshed out as it should be. Use at your own risk!
|
||||
|
||||
* Panes (like glass panes and iron bars): `ITEMS/xpanes`
|
||||
* `_on_ignite` callback: `ITEMS/mcl_fire`
|
||||
* Farming: `ITEMS/mcl_farming`
|
||||
* Anything related to redstone: Don't touch (yet)
|
||||
* Any other mod not explicitly mentioned above
|
||||
|
||||
### Planned APIs
|
||||
|
||||
* Flowers
|
||||
* Saplings and trees
|
||||
* Custom banner patterns
|
||||
* Custom dimensions
|
||||
* Custom portals
|
||||
* Music discs
|
||||
* Dispenser and dropper support
|
||||
* Proper sky and weather APIs
|
||||
* Explosion API
|
||||
## Other things of interest
|
||||
Mods found in `mods/CORE` contain important core APIs and utility functions, used throughout the subgame.
|
||||
|
|
|
@ -5,7 +5,7 @@ Wow, thank you! :-)
|
|||
But first, some things to note:
|
||||
|
||||
MineClone 2's development target is to make a free software clone of Minecraft,
|
||||
***version 1.11***, ***PC edition***.
|
||||
***version 1.11*** (later: 1.12), ***PC edition***.
|
||||
|
||||
MineClone 2 is maintained by one person. Namely, Wuzzy. You can find me,
|
||||
Wuzzy, in the Minetest forums (forums.minetest.net), in IRC in the #minetest
|
||||
|
@ -14,7 +14,7 @@ channel on irc.freenode.net. And finally, you can send e-mails to
|
|||
|
||||
There is **no** guarantee I will accept anything from anybody.
|
||||
|
||||
By sending me patches or asking me to include your changes in this game,
|
||||
By sending me patches or asking me to include your changes in this subgame,
|
||||
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 +26,8 @@ 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 me
|
||||
* Upload the repository somewhere where it can be accessed from the Internet
|
||||
* Ask me to pull in your changes (and briefly say what you're changed)
|
||||
|
||||
For small changes, sending me a patch is also good.
|
||||
|
||||
|
@ -35,7 +35,7 @@ For big changes: Same as above, but consider notifying me first to avoid
|
|||
duplicate work and possible tears of rejection. ;-)
|
||||
|
||||
## Quality remarks
|
||||
Again: There is ***no*** guarantee I will accept anything from anybody.
|
||||
Again: There is ***no*** guarantee I will accept anything from anything.
|
||||
But I will gladly take in code from others when I feel it saves me work
|
||||
in the long run.
|
||||
|
||||
|
@ -64,10 +64,10 @@ Depending on what you add, the chances for inclusion vary:
|
|||
|
||||
## Coding style guide
|
||||
* Indentations should reflect the code flow
|
||||
* Use tabs, not spaces for indentation (tab size = 8)
|
||||
* Use tabs, not spaces for indentation
|
||||
* Never use `minetest.env`
|
||||
|
||||
## Reporting bugs
|
||||
Report all bugs and missing Minecraft features here:
|
||||
|
||||
<https://git.minetest.land/Wuzzy/MineClone2/issues>
|
||||
<https://github.com/Wuzzy2/MineClone2-Bugs>
|
||||
|
|
83
GROUPS.md
|
@ -1,5 +1,5 @@
|
|||
## Groups
|
||||
This document explains all the groups used in this game.
|
||||
This document explains all the groups used in this subgame.
|
||||
|
||||
### Special groups
|
||||
|
||||
|
@ -29,47 +29,17 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
|||
|
||||
### Groups for interactions
|
||||
|
||||
* `crush_after_fall=1`: For falling nodes. These will crush whatever they hit after falling, not dropping as an item
|
||||
* `falling_node_damage=1`: For falling nodes. Hurts any objects it hits while falling. Damage is based on anvils
|
||||
* `dig_by_water=1`: Blocks with this group will drop when they are near flowing water
|
||||
* `destroy_by_lava_flow=1`: Blocks with this group will be destroyed by flowing lava
|
||||
* `dig_by_piston=1`: Blocks which will drop as an item when pushed by a piston. They also cannot be pulled by sticky pistons
|
||||
* `cultivatable=2`: Block will be turned into Farmland by using a hoe on it
|
||||
* `cultivatable=1`: Block will be turned into Dirt by using a hoe on it
|
||||
* `flammable`: Block spreads fire
|
||||
* `flammable>0`: Gets destroyed by fire
|
||||
* `flammable=-1` Does not get destroyed by fire
|
||||
* `fire_encouragement`: How quickly this block catches fire
|
||||
* `fire_flammability`: How fast the block will burn away
|
||||
* `spreading_dirt_type=1`: A dirt-type block with a cover (e.g. grass) which may spread to neighbor dirt blocks
|
||||
* `dirtifies_below_solid=1`: This node turns into dirt immediately when a solid or dirtifier node is placed on top
|
||||
* `dirtifier=1`: This node turns nodes the above group into dirt when placed above
|
||||
* `non_mycelium_plant=1`: A plant which can't grow on mycelium. Placing it on mycelium fails and if mycelium spreads below it, it uproots
|
||||
* `flammable`: Block helps spreading fire and gets destroyed by nearby fire (rating doesn't matter)
|
||||
* `soil=1`: Saplings and other small plants can grow on it
|
||||
* `soil_sapling=2`: Soil for saplings. Intended to be natural soil. All saplings will grow on this
|
||||
* `soil_sapling=1`: Artificial soil (such as farmland) for saplings. Some saplings will not grow on this
|
||||
* `soil_sugarcane=1`: Sugar canes will grow on this near water
|
||||
* `soil_nether_wart=1`: Nether wart will grow on this
|
||||
* `enderman_takable=1`: Block can be taken and placed by endermen
|
||||
* `disable_suffocation=1`: Disables suffocation for full solid cubes (1)
|
||||
* `destroys_items=1`: If an item happens to be *inside* this node, the item will be destroyed
|
||||
* `no_eat_delay=1`: Only for foodstuffs. When eating this, all eating delays are ignored.
|
||||
* `can_eat_when_full=1`: Only for foodstuffs. This item can be eaten when the user has a full hunger bar
|
||||
* `attached_node_facedir=1`: Like `attached_node`, but for facedir nodes
|
||||
* `cauldron`: Cauldron. 1: Empty. 2-4: Water height
|
||||
* `anvil`: Anvil. 1: No damage. 2-3: Higher damage levels
|
||||
* `no_rename=1`: Item cannot be renamed by anvil
|
||||
* `comparator_signal=X`: If set, this node outputs a constant (!) comparator signal output of strength X.
|
||||
* `piston=X`: Piston (main body) (1 = normal, 2 = sticky)
|
||||
* `piston_pusher=X`: Piston pusher (1 = normal, 2 = sticky)
|
||||
* `hopper=X`: Hopper (1 = downwards, 2 = sideways)
|
||||
* `portal=1`: Portal (node that teleports players and things by standing inside)
|
||||
* `end_portal_frame=X`: End portal frame (1 = no eye, 2 = with eye)
|
||||
* `coral=X`: Coral (any type) (1 = alive, 2 = dead)
|
||||
* `coral_plant=X`: Coral in the "plant" shape (1 = alive, 2 = dead)
|
||||
* `coral_fan=X`: Coral fan (1 = alive, 2 = dead)
|
||||
* `coral_block=X`: Coral block (1 = alive, 2 = dead)
|
||||
* `coral_species=X`: Specifies the species of a coral; equal X means equal species
|
||||
|
||||
#### Footnotes
|
||||
|
||||
|
@ -80,10 +50,8 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
|||
### Groups (mostly) used for crafting recipes
|
||||
|
||||
* `sand=1`: Sand (any color)
|
||||
* `sandstone=1`: Sandstone (any color) and related nodes (chiseled and the like) (only full blocks)
|
||||
* `normal_sandstone=1`: “Normal” (yellow) sandstone and related nodes (chiseled and the like) (only full blocks)
|
||||
* `red_sandstone=1`: Red sandstone and related nodes (chiseled and the like) (only full blocks)
|
||||
* `hardened_clay=1`: Terracotta (any color)
|
||||
* `sandstone=1`: (Yellow) sandstone and related nodes (chiseled and the like) (only full blocks)
|
||||
* `redsandstone=1`: Red sandstone and related nodes (chiseled and the like) (only full blocks)
|
||||
* `quartz_block=1`: Quartz Block and variants (chiseled, pillar, etc.) (only full blocks)
|
||||
* `stonebrick=1`: Stone Bricks and related nodes (only full blocks)
|
||||
* `shulker_box=1`: Block is a shulker box
|
||||
|
@ -95,7 +63,6 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
|||
* `wool=1`: Wool (only full blocks)
|
||||
* `carpet=1:` (Wool) carpet
|
||||
* `stick=1`: Stick
|
||||
* `water_bucket=1`: Bucket containing a liquid of group “water”
|
||||
|
||||
### Material groups
|
||||
|
||||
|
@ -114,12 +81,9 @@ These groups are used mostly for informational purposes
|
|||
|
||||
* `solid=1`: Solid full-cube block (automatically assigned)
|
||||
* `opaque=1`: Opaque block (automatically assigned)
|
||||
* `not_solid=1`: Block is not solid (only assign this group for nodes which are automatically detected as “solid” in error
|
||||
* `not_opaque=1`: Block is not opaque (only assign this group for nodes which are automatically detected as “opaque” in error
|
||||
* `fire=1`: Fire
|
||||
* `not_solid=1`: Block is sold (only assign this group for nodes which are automatically detected as “solid” in error
|
||||
* `water=1`: Water
|
||||
* `lava=1`: Lava
|
||||
* `top_snow=X`: Top snow with X layers (1-8)
|
||||
* `torch`: Torch or torch-like node
|
||||
* `torch=1`: Torch on floor
|
||||
* `torch=2`: Torch at wall
|
||||
|
@ -134,16 +98,11 @@ These groups are used mostly for informational purposes
|
|||
* `flower_pot`: Flower pot
|
||||
* `flower_pot=1`: Empty flower pot
|
||||
* `flower_pot=2`: Flower pot with a plant or flower
|
||||
* `flower=1`: Flower
|
||||
* `place_flowerlike=1`: Node has placement rules like that of a flower
|
||||
* `place_flowerlike=2`: Node has placement rules like tall grass
|
||||
* `cake`: Cake (rating = slices left)
|
||||
* `book=1`: Book
|
||||
* `pane=1`: Node is a “pane”-like node glass pane or iron bars
|
||||
* `bed=1`: Bed
|
||||
* `door=1`: Door
|
||||
* `trapdoor=1`: Closed trapdoor
|
||||
* `trapdoor=2`: Open trapdoor
|
||||
* `door=2`: Trapdoor
|
||||
* `glass=1`: Glass (full cubes only)
|
||||
* `rail=1`: Rail
|
||||
* `music_record`: Music Disc (rating is track ID)
|
||||
|
@ -158,37 +117,13 @@ These groups are used mostly for informational purposes
|
|||
* `cocoa`: Node is a cocoa pod (rating is growth stage, ranging from 1 to 3)
|
||||
* `ammo=1`: Item is used as ammo for a weapon
|
||||
* `ammo_bow=1`: Item is used as ammo for bows
|
||||
* `non_combat_armor=1`: Item can be equipped as armor, but is not made for combat (e.g. zombie head, pumpkin)
|
||||
* `container`: Node is a container which physically stores items within and has at least 1 inventory
|
||||
* `container=2`: Has one inventory with list name `"main"`. Items can be placed and taken freely
|
||||
* `container=3`: Same as `container=2`, but shulker boxes can not be inserted
|
||||
* `container=4`: Furnace-like, has lists `"src"`, `"fuel"` and `"dst"`.
|
||||
It is expected that this also reacts on `on_timer`;
|
||||
the node timer must be started from other mods when they add into `"src"` or `"fuel"`
|
||||
* `container=5`: Left part of a 2-part horizontal connected container. Both parts have a `"main"` inventory
|
||||
list. Both inventories are considered to belong together. This is used for large chests.
|
||||
* `container=6`: Same as above, but for the right part.
|
||||
* `container=7`: Has inventory list "`main`", no movement allowed
|
||||
* `container=4`: Furnace-like, has lists `"src"`, `"fuel"` and `"dst"`
|
||||
* `container=1`: Other/unspecified container type
|
||||
* `spawn_egg=1`: Spawn egg
|
||||
|
||||
* `pressure_plate=1`: Pressure plate (off)
|
||||
* `pressure_plate=2`: Wooden pressure (on)
|
||||
* `button=1`: Button (off)
|
||||
* `button=2`: Button (on)
|
||||
* `redstone_torch=1`: Redstone Torch (lit)
|
||||
* `redstone_torch=2`: Redstone Torch (unlit)
|
||||
|
||||
* `plant=1`: Plant or part of a plant
|
||||
* `double_plant`: Part of a double-sized plant. 1 = lower part, 2 = upper part
|
||||
|
||||
* `pickaxe=1`: Pickaxe
|
||||
* `shovel=1`: Shovel
|
||||
* `axe=1`: Axe
|
||||
* `sword=1`: Sword
|
||||
* `hoe=1`: Hoe (farming tool)
|
||||
* `shears=1`: Shears
|
||||
|
||||
* `weapon=1`: Item is primarily (!) a weapon
|
||||
* `tool=1`: Item is primarily (!) a tool
|
||||
* `craftitem=1`: Item is primarily (!) used for crafting
|
||||
|
@ -201,8 +136,8 @@ These groups are used mostly for informational purposes
|
|||
These groups put similar items together which should all be treated by the gameplay or the GUI as a single item.
|
||||
You should not add custom items to these groups for no good reason, this is likely to cause a ton of conflicts.
|
||||
|
||||
* `clock`: Clock (rating indicates the “frame”)
|
||||
* `compass`: Compass (rating indicates the “frame”)
|
||||
* `clock=1`: Clock
|
||||
* `compass`: Compass (rating doesn't matter)
|
||||
|
||||
This has the following implication: If you want to use a compass or clock in a crafting recipe, you *must*
|
||||
use `group:compass` or `group:clock`, respectively.
|
||||
|
|
|
@ -8,6 +8,8 @@ For these features, no easy Lua workaround could be found.
|
|||
|
||||
### Lua API
|
||||
#### Tools/wielded item
|
||||
- Allow **much** faster liquid flowing ([#2810](https://github.com/minetest/minetest/issues/2810))
|
||||
|
||||
- “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)
|
||||
|
@ -19,6 +21,7 @@ For these features, no easy Lua workaround could be found.
|
|||
|
||||
## 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
|
||||
- **Much** more informative item tooltips
|
||||
- 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 on inventory slot should be able to put items into additional “fallback inventories” if the first inventory is full. Required for large chests
|
||||
- Sneak+click puts items in different inventories depending on the item type (maybe group-based)? Required for sneak-clicking to armor slots
|
||||
|
@ -36,5 +39,8 @@ For these features, a workaround (or hack ;-)) by using Lua is theoretically pos
|
|||
- 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
|
||||
|
||||
#### Crafting
|
||||
- Require tools to be intact in crafting
|
||||
|
||||
#### 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
|
||||
|
|
206
README.md
|
@ -1,8 +1,8 @@
|
|||
# MineClone 2
|
||||
An unofficial Minecraft-like game for Minetest. Forked from MineClone by davedevils.
|
||||
An unofficial Minecraft-like game for Minetest. Forked from MineClone by daredevils.
|
||||
Developed by Wuzzy and contributors. Not developed or endorsed by Mojang AB.
|
||||
|
||||
Version: 0.65.2
|
||||
Version: 0.16.0
|
||||
|
||||
### Gameplay
|
||||
You start in a randomly-generated world made entirely of cubes. You can explore
|
||||
|
@ -27,6 +27,7 @@ Or you can play in “creative mode” in which you can build almost anything in
|
|||
|
||||
## How to play (quick start)
|
||||
### Getting started
|
||||
* **Use the world generator “v6”!**
|
||||
* **Punch a tree** trunk until it breaks and collect wood
|
||||
* Place the **wood into the 2×2 grid** (your “crafting grid” in your inventory menu and craft 4 wood planks
|
||||
* Place the 4 wood planks in a 2×2 shape in the crafting grid to **make a crafting table**
|
||||
|
@ -55,134 +56,99 @@ Or you can play in “creative mode” in which you can build almost anything in
|
|||
More help about the gameplay, blocks items and much more can be found from inside
|
||||
the game. You can access the help from your inventory menu.
|
||||
|
||||
### Special items
|
||||
The following items are interesting for Creative Mode and for adventure
|
||||
map builders. They can not be obtained in-game or in the creative inventory.
|
||||
|
||||
* Barrier: `mcl_core:barrier`
|
||||
|
||||
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
|
||||
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.
|
||||
This game requires [Minetest](http://minetest.net) 0.4.15 (or later) to run,
|
||||
so you need to install Minetest first. To install MineClone 2, move this
|
||||
directory into the “games” directory of your Minetest data directory.
|
||||
Consult the help of Minetest to learn more.
|
||||
|
||||
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.
|
||||
|
||||
## 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.11** (later known as “Java Edition”)
|
||||
* 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)
|
||||
* 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
|
||||
The logo of MineClone 2 has two grass blocks.
|
||||
|
||||
## 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 very unfinished at this moment. Expect bugs! Expect chaos
|
||||
and destruction to rain down on your worlds whenever you update! ;-)
|
||||
|
||||
The following main features are available:
|
||||
|
||||
* Tools, weapons
|
||||
* Armor (unbalanced)
|
||||
* Tools, weapons and armor
|
||||
* Crafting system: 2×2 grid, crafting table (3×3 grid), furnace, including a crafting guide
|
||||
* Chests, large chests, ender chests, shulker boxes
|
||||
* Furnaces, hoppers
|
||||
* Hunger
|
||||
* Most monsters and animals
|
||||
* Hunger (incomplete)
|
||||
* All ores from Minecraft
|
||||
* Most blocks in the overworld
|
||||
* Water and lava
|
||||
* Weather
|
||||
* 28 biomes
|
||||
* The Nether, a fiery underworld in another dimension
|
||||
* Redstone circuits (partially)
|
||||
* Redstone circuits (partially): Redstone ore, redstone, redstone repeater, levers, buttons, redstone blocks, redstone lamps
|
||||
* Minecarts (partial)
|
||||
* Boats
|
||||
* Fire
|
||||
* Buidling blocks: Stairs, slabs, doors, trapdoors, fences, fence gates, walls
|
||||
* Clock
|
||||
* Compass
|
||||
* Sponge
|
||||
* Slime block (does not interact with redstone)
|
||||
* Small plants and saplings
|
||||
* Slime block (incomplete)
|
||||
* A variety of flowers
|
||||
* Dyes
|
||||
* Banners
|
||||
* Deco blocks: Glass, stained glass, glass panes, iron bars, hardened clay (and colors), heads and more
|
||||
* Item frames
|
||||
* Jukeboxes
|
||||
* Beds
|
||||
* Inventory menu
|
||||
* Creative inventory
|
||||
* Farming
|
||||
* Writable books
|
||||
* A few server commands
|
||||
* Farming (needs balancing)
|
||||
* Bookshelves
|
||||
* Books
|
||||
* More server commands
|
||||
* 3D torches
|
||||
* And more!
|
||||
|
||||
The following features are incomplete:
|
||||
|
||||
* Generated structures (especially villages)
|
||||
* NPCs
|
||||
* Some monsters and animals
|
||||
* Redstone-related things
|
||||
* Monsters and NPCs
|
||||
* Some redstone-related things
|
||||
* The Nether
|
||||
* The End
|
||||
* Enchanting
|
||||
* Experience
|
||||
* Status effects
|
||||
* Brewing, potions, tipped arrows
|
||||
* Special minecarts
|
||||
* Anvil
|
||||
* Trees, biomes, generated structures
|
||||
* A couple of non-trivial blocks and items
|
||||
|
||||
Bonus features (not found in Minecraft 1.11):
|
||||
Bonus features (not found in Minecraft):
|
||||
|
||||
* 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
|
||||
* Temporary crafting recipes. They only exist to make some otherwise unaccessible items available when you're not in creative mode. These recipes will be removed as development goes on an more features become available
|
||||
* Saplings in chests in mapgen v6
|
||||
* Fully moddable (thanks to Minetest's powerful Lua API)
|
||||
* New blocks and items:
|
||||
* Lookup tool, shows you the help for whatever it touches
|
||||
* More slabs and stairs
|
||||
* Nether Brick Fence Gate
|
||||
* Red Nether Brick Fence
|
||||
* Red Nether Brick Fence Gate
|
||||
* New temporary crafting recipes. They only exist to make some otherwise unaccessible items available when you're not in creative mode. These recipes will be removed as development goes on an more features become available
|
||||
|
||||
Technical differences from Minecraft:
|
||||
|
||||
* Height limit of ca. 31000 blocks (much higher than in Minecraft)
|
||||
* Horizontal world size is ca. 62000×62000 blocks (much smaller than in Minecraft, but it is still very large)
|
||||
* Still very incomplete and buggy
|
||||
* Blocks, items, enemies and other features are missing
|
||||
* Still very, very incomplete and buggy
|
||||
* Many blocks, items, enemies and other features are missing
|
||||
* A few items have slightly different names to make them easier to distinguish
|
||||
* Free software (“free” as in freedom *and* free beer)
|
||||
* Different music for jukebox
|
||||
* Different textures (Pixel Perfection)
|
||||
* Different sounds (various sources)
|
||||
* Different engine (Minetest)
|
||||
* Different textures (Faithful 1.11)
|
||||
* Different engine
|
||||
* Height limit of ca. 31000 blocks
|
||||
* Horizontal world size is ca. 62000×62000 blocks
|
||||
|
||||
… and finally, MineClone 2 is free software (“free” as in “freedom”)!
|
||||
|
||||
## Project description
|
||||
The main goal of **MineClone 2** is to be a clone of Minecraft and to be released as free software.
|
||||
The focus on this clone lies especially on gameplay and to reflect it as good as possible.
|
||||
Ideally, no gameplay features will be added or removed.
|
||||
A secondary goal is to make modding easy as pie. Minetest is of great help here!
|
||||
Trying to stay faithful to the original look and feel is a side goal, but not an important one.
|
||||
If deemed neccessary, MineClone 2 *will* deviate from Minecraft in interface issues.
|
||||
There's already a built-in crafting guide and a full-blown in-game help system.
|
||||
Finally, any limitations found in Minetest (the game engine) will be written down in the course
|
||||
of development.
|
||||
|
||||
## Reporting bugs
|
||||
Please report all bugs and missing Minecraft features here:
|
||||
Report all bugs and missing Minecraft features here:
|
||||
|
||||
<https://git.minetest.land/Wuzzy/MineClone2/issues>
|
||||
<https://github.com/Wuzzy2/MineClone2-Bugs>
|
||||
|
||||
## Other readme files
|
||||
|
||||
|
@ -192,49 +158,22 @@ Please report all bugs and missing Minecraft features here:
|
|||
* `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.
|
||||
There are so many people to list (sorry).
|
||||
|
||||
### Coding
|
||||
* [Wuzzy](https://forum.minetest.net/memberlist.php?mode=viewprofile&u=3082): Main programmer of most mods
|
||||
* 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
|
||||
* Lots of other people: TO BE WRITTEN (see mod directories for details)
|
||||
|
||||
### 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 <tanakinci2002@gmail.com>: MineClone 2 logo
|
||||
* Other authors: GUI images
|
||||
|
||||
### Translations
|
||||
* Wuzzy: German
|
||||
* Rocher Laurent <rocherl@club-internet.fr>: French
|
||||
* wuniversales: Spanish
|
||||
|
||||
### 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.
|
||||
### Mods
|
||||
TO BE WRITTEN.
|
||||
|
||||
### Special thanks
|
||||
|
||||
* davedevils for starting MineClone, the original version of this game
|
||||
* daredevils for starting this project
|
||||
* Tox82, MinetestForFun & Calinou for help in dev
|
||||
* GravGun & Obani for Help in Build struct
|
||||
* celeron55 for creating Minetest
|
||||
* Bob Lennon because it's a pyro-barbare
|
||||
* 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
|
||||
* The workaholics who spent hours writing for the Minecraft Wiki. It's an invaluable resource for creating this game
|
||||
* Notch and Jeb for being the bigg
|
||||
|
||||
## Info for programmers
|
||||
You find interesting and useful infos in `API.md`.
|
||||
|
@ -244,35 +183,28 @@ This project is currently mostly a one-person project.
|
|||
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:
|
||||
But, oh well, if you insist, here is the legalese for you:
|
||||
|
||||
### License of source code
|
||||
MineClone 2 is a clean-room implementation of Minecraft
|
||||
and licensed under the
|
||||
GNU LGPL v2.1 (Wuzzy, davedevils and countless others) (see `LICENSE.txt`).
|
||||
|
||||
MineClone 2 is a direct continuation of the discontinued MineClone
|
||||
project by davedevils which fell under the same license.
|
||||
MineClone source code:
|
||||
LGPL v2.1 (daredevils and others) (see `LICENSE.txt`)
|
||||
|
||||
Mods credit:
|
||||
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 taken from the Faithful 1.11 resource pack for Minecraft,
|
||||
authored by Vattic, xMrVizzy and many others.
|
||||
|
||||
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: <https://www.planetminecraft.com/texture_pack/131pixel-perfection/>
|
||||
License: [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)
|
||||
Source:
|
||||
http://www.minecraftforum.net/topic/72747-/
|
||||
|
||||
The main menu images are release under: [CC0](https://creativecommons.org/publicdomain/zero/1.0/)
|
||||
The license of this texture pack is the MIT license.
|
||||
|
||||
License of all main menu images: WTFPL
|
||||
|
||||
All other files, unless mentioned otherwise, fall under:
|
||||
Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 4.0)
|
||||
http://creativecommons.org/licenses/by-sa/4.0/
|
||||
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.
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
A survival sandbox game. Survive, gather, hunt, mine, build, explore, and do much more. Faithful clone of Minecraft 1.11. This is a work in progress! Expect bugs!
|
|
@ -1,2 +1 @@
|
|||
name = MineClone 2
|
||||
description = A survival sandbox game. Survive, gather, hunt, build, explore, and do much more.
|
||||
|
|
BIN
menu/footer.png
Before Width: | Height: | Size: 628 B After Width: | Height: | Size: 1.0 KiB |
BIN
menu/header.png
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 68 KiB |
BIN
menu/icon.png
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 119 KiB |
Before Width: | Height: | Size: 121 KiB |
Before Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 122 KiB |
BIN
menu/overlay.png
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 196 KiB |
|
@ -1,33 +1,23 @@
|
|||
# This is a game specific minetest.conf file, do not edit
|
||||
# This is a game specify minetest.conf file, do not edit
|
||||
|
||||
# Basic game rules
|
||||
time_speed = 72
|
||||
|
||||
# Player physics
|
||||
movement_acceleration_default = 2.4
|
||||
movement_acceleration_air = 1.2
|
||||
#movement_acceleration_fast = 10
|
||||
|
||||
movement_speed_walk = 4.317
|
||||
movement_speed_crouch = 1.295
|
||||
movement_speed_fast = 25.0
|
||||
movement_speed_fast = 10.89
|
||||
|
||||
movement_speed_jump = 6.6
|
||||
movement_speed_climb = 2.35
|
||||
# TODO: Add descend speed (3.0) when available
|
||||
movement_speed_climb = 2
|
||||
movement_speed_descend = 6
|
||||
|
||||
movement_liquid_fluidity = 1.13
|
||||
movement_liquid_fluidity_smooth = 0.5
|
||||
movement_liquid_sink = 23
|
||||
#movement_liquid_fluidity = 1
|
||||
#movement_liquid_fluidity_smooth = 0.5
|
||||
movement_liquid_sink = 15
|
||||
|
||||
movement_gravity = 10.4
|
||||
|
||||
# Mapgen stuff
|
||||
|
||||
# altitude_chill and altitude_dry doesn't go well together with MCL2 biomes
|
||||
# which already include "snowed" variants as you go higher.
|
||||
# humid_rivers would cause the MushroomIsland biome to appear frequently around rivers.
|
||||
mgvalleys_spflags = noaltitude_chill,noaltitude_dry,nohumid_rivers,vary_river_depth
|
||||
|
||||
# MCL2-specific stuff
|
||||
keepInventory = false
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
This mod automatically adds groups to items based on item metadata.
|
||||
|
||||
Specifically, this mod has 2 purposes:
|
||||
1) Automatically adding the group “solid” for blocks considered “solid” in Minecraft.
|
||||
2) Generating digging time group for all nodes based on node metadata (it's complicated)
|
||||
|
||||
See init.lua for more infos.
|
||||
|
||||
The leading underscore in the name “_mcl_autogroup” was added to force Minetest to load this mod as late as possible.
|
||||
As of 0.4.16, Minetest loads mods in reverse alphabetical order.
|
|
@ -1 +0,0 @@
|
|||
MineClone 2 core mod which automatically adds groups to all items. Very important for digging times.
|
|
@ -1,151 +0,0 @@
|
|||
--[[ Mining times. Yeah, mining times … Alright, this is going to be FUN!
|
||||
|
||||
This mod does include a HACK to make 100% sure the digging times of all tools match Minecraft's perfectly.
|
||||
The digging times system of Minetest is very different, so this weird group trickery has to be used.
|
||||
In Minecraft, each block has a hardness and the actual Minecraft digging time is determined by this:
|
||||
1) The block's hardness
|
||||
2) The tool being used
|
||||
3) Whether the tool is considered as “eligible” for the block
|
||||
(e.g. only diamond pick eligible for obsidian)
|
||||
See Minecraft Wiki <http://minecraft.gamepedia.com/Minecraft_Wiki> for more information.
|
||||
|
||||
In MineClone 2, all diggable node have the hardness set in the custom field “_mcl_hardness” (0 by default).
|
||||
The nodes are also required to specify the “eligible” tools in groups like “pickaxey”, “shovely”, etc.
|
||||
This mod then calculates the real digging time based on the node meta data. The real digging times
|
||||
are then added into mcl_autogroup.digtimes where the table indices are group rating and the values are the
|
||||
digging times in seconds. These digging times can be then added verbatim into the tool definitions.
|
||||
|
||||
Example:
|
||||
mcl_autogroup.digtimes.pickaxey_dig_diamond[1] = 0.2
|
||||
|
||||
→ This menas that when a node has been assigned the group “pickaxey_dig_diamond=1”, it can be dug by the
|
||||
diamond pickaxe in 0.2 seconds.
|
||||
|
||||
|
||||
|
||||
This strange setup with mcl_autogroup has been done to minimize the amount of required digging times
|
||||
a single tool needs to use. If this is not being done, the loading time will increase considerably
|
||||
(>10s).
|
||||
|
||||
]]
|
||||
|
||||
local materials = { "wood", "gold", "stone", "iron", "diamond" }
|
||||
local basegroups = { "pickaxey", "axey", "shovely" }
|
||||
local minigroups = { "handy", "shearsy", "swordy", "shearsy_wool", "swordy_cobweb" }
|
||||
local divisors = {
|
||||
["wood"] = 2,
|
||||
["gold"] = 12,
|
||||
["stone"] = 4,
|
||||
["iron"] = 6,
|
||||
["diamond"] = 8,
|
||||
["handy"] = 1,
|
||||
["shearsy"] = 15,
|
||||
["swordy"] = 1.5,
|
||||
["shearsy_wool"] = 5,
|
||||
["swordy_cobweb"] = 15,
|
||||
}
|
||||
|
||||
mcl_autogroup = {}
|
||||
mcl_autogroup.digtimes = {}
|
||||
mcl_autogroup.creativetimes = {} -- Copy of digtimes, except that all values are 0. Used for creative mode
|
||||
|
||||
for m=1, #materials do
|
||||
for g=1, #basegroups do
|
||||
mcl_autogroup.digtimes[basegroups[g].."_dig_"..materials[m]] = {}
|
||||
mcl_autogroup.creativetimes[basegroups[g].."_dig_"..materials[m]] = {}
|
||||
end
|
||||
end
|
||||
for g=1, #minigroups do
|
||||
mcl_autogroup.digtimes[minigroups[g].."_dig"] = {}
|
||||
mcl_autogroup.creativetimes[minigroups[g].."_dig"] = {}
|
||||
end
|
||||
|
||||
local overwrite = function()
|
||||
for nname, ndef in pairs(minetest.registered_nodes) do
|
||||
local groups_changed = false
|
||||
local newgroups = table.copy(ndef.groups)
|
||||
if (nname ~= "ignore" and ndef.diggable) then
|
||||
-- Automatically assign the “solid” group for solid nodes
|
||||
if (ndef.walkable == nil or ndef.walkable == true)
|
||||
and (ndef.collision_box == nil or ndef.collision_box.type == "regular")
|
||||
and (ndef.node_box == nil or ndef.node_box.type == "regular")
|
||||
and (ndef.groups.not_solid == 0 or ndef.groups.not_solid == nil) then
|
||||
newgroups.solid = 1
|
||||
groups_changed = true
|
||||
end
|
||||
-- Automatically assign the “opaque” group for opaque nodes
|
||||
if (not (ndef.paramtype == "light" or ndef.sunlight_propagates)) and
|
||||
(ndef.groups.not_opaque == 0 or ndef.groups.not_opaque == nil) then
|
||||
newgroups.opaque = 1
|
||||
groups_changed = true
|
||||
end
|
||||
|
||||
local function calculate_group(hardness, material, diggroup, newgroups, actual_rating, expected_rating)
|
||||
local time, validity_factor
|
||||
if actual_rating >= expected_rating then
|
||||
-- Valid tool
|
||||
validity_factor = 1.5
|
||||
else
|
||||
-- Wrong tool (higher digging time)
|
||||
validity_factor = 5
|
||||
end
|
||||
time = (hardness * validity_factor) / divisors[material]
|
||||
if time <= 0.05 then
|
||||
time = 0
|
||||
else
|
||||
time = math.ceil(time * 20) / 20
|
||||
end
|
||||
table.insert(mcl_autogroup.digtimes[diggroup], time)
|
||||
table.insert(mcl_autogroup.creativetimes[diggroup], 0)
|
||||
newgroups[diggroup] = #mcl_autogroup.digtimes[diggroup]
|
||||
return newgroups
|
||||
end
|
||||
|
||||
-- Hack in digging times
|
||||
local hardness = ndef._mcl_hardness
|
||||
if not hardness then
|
||||
hardness = 0
|
||||
end
|
||||
|
||||
-- Handle pickaxey, axey and shovely
|
||||
for _, basegroup in pairs(basegroups) do
|
||||
if (hardness ~= -1 and ndef.groups[basegroup]) then
|
||||
for g=1,#materials do
|
||||
local diggroup = basegroup.."_dig_"..materials[g]
|
||||
newgroups = calculate_group(hardness, materials[g], diggroup, newgroups, g, ndef.groups[basegroup])
|
||||
groups_changed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
for m=1, #minigroups do
|
||||
local minigroup = minigroups[m]
|
||||
if hardness ~= -1 then
|
||||
local diggroup = minigroup.."_dig"
|
||||
-- actual rating
|
||||
local ar = ndef.groups[minigroup]
|
||||
if ar == nil then
|
||||
ar = 0
|
||||
end
|
||||
if (minigroup == "handy")
|
||||
or
|
||||
(ndef.groups.shearsy_wool and minigroup == "shearsy_wool" and ndef.groups.wool)
|
||||
or
|
||||
(ndef.groups.swordy_cobweb and minigroup == "swordy_cobweb" and nname == "mcl_core:cobweb")
|
||||
or
|
||||
(ndef.groups[minigroup] and minigroup ~= "swordy_cobweb" and minigroup ~= "shearsy_wool") then
|
||||
newgroups = calculate_group(hardness, minigroup, diggroup, newgroups, ar, 1)
|
||||
groups_changed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if groups_changed then
|
||||
minetest.override_item(nname, {
|
||||
groups = newgroups
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
overwrite()
|
|
@ -1 +0,0 @@
|
|||
name = _mcl_autogroup
|
|
@ -1,42 +0,0 @@
|
|||
# Biome Info API
|
||||
This document explains the API of this mod.
|
||||
|
||||
## v6 mapgen functions
|
||||
These are functions for the v6 mapgen only.
|
||||
|
||||
Use these functions only in worlds in which the v6 mapgen is used.
|
||||
If you use these in any other mapgen, bad things might happen.
|
||||
|
||||
### `biomeinfo.get_v6_humidity(pos)`
|
||||
Get the biome humidity at pos (for v6 mapgen).
|
||||
|
||||
### `biomeinfo.get_v6_heat(pos)`
|
||||
Get the biome heat/temperature at pos (for v6 mapgen).
|
||||
|
||||
### `biomeinfo.get_v6_biome(pos)`
|
||||
Get the v6 biome at pos.
|
||||
Returns a string, which is the unique biome name.
|
||||
|
||||
Note: This function currently ignores the `biomeblend` v6 mapgen flag,
|
||||
it just pretends this setting is disabled.
|
||||
This is normally not a problem, but at areas where biomes blend,
|
||||
the result is not perfectly accurate and just an estimate.
|
||||
|
||||
### `biomeinfo.get_active_v6_biomes()`
|
||||
Returns a table containing the names of all v6 biomes that are actively
|
||||
used in the current world, e.g. those that have been activated
|
||||
by the use of the mapgen v6 flags (`mgv6_spflags`).
|
||||
|
||||
### `biomeinfo.all_v6_biomes`
|
||||
This is a table containing all v6 biomes (as strings), even those that
|
||||
might not be used in the current world.
|
||||
|
||||
### v6 biome names
|
||||
|
||||
These are the biome names used in this mod:
|
||||
|
||||
* Normal
|
||||
* Desert
|
||||
* Jungle
|
||||
* Tundra
|
||||
* Taiga
|
|
@ -1,11 +0,0 @@
|
|||
# Biome Info API [`biomeinfo`]
|
||||
This is an API mod for mod developers to add a couple of missing
|
||||
biome-related functions.
|
||||
Currently, this mod only adds v6-related functions.
|
||||
Most importantly, you can get the heat, humidity and biome in the v6 mapgen.
|
||||
|
||||
See `API.md` for the API documentation.
|
||||
|
||||
Current version: 1.0.3 (this is a [SemVer](https://semver.org/))
|
||||
|
||||
License: MIT License
|
|
@ -1,211 +0,0 @@
|
|||
biomeinfo = {}
|
||||
|
||||
-- Copied from mapgen_v6.h
|
||||
local MGV6_FREQ_HOT = 0.4
|
||||
local MGV6_FREQ_SNOW = -0.4
|
||||
local MGV6_FREQ_TAIGA = 0.5
|
||||
local MGV6_FREQ_JUNGLE = 0.5
|
||||
|
||||
-- Biome types
|
||||
local BT_NORMAL = "Normal"
|
||||
local BT_TUNDRA = "Tundra"
|
||||
local BT_TAIGA = "Taiga"
|
||||
local BT_DESERT = "Desert"
|
||||
local BT_JUNGLE = "Jungle"
|
||||
|
||||
-- Get mapgen settings
|
||||
|
||||
local seed = tonumber(minetest.get_mapgen_setting("seed")) or 0
|
||||
|
||||
local mgv6_perlin_biome, mgv6_perlin_humidity, mgv6_np_biome
|
||||
|
||||
-- v6 default noiseparams are hardcoded here because Minetest doesn't give us those
|
||||
local mgv6_np_biome_default = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = { x = 500, y = 500, z = 500},
|
||||
seed = 9130,
|
||||
octaves = 3,
|
||||
persistence = 0.50,
|
||||
lacunarity = 2.0,
|
||||
flags = "eased",
|
||||
}
|
||||
local mgv6_np_humidity_default = {
|
||||
offset = 0.5,
|
||||
scale = 0.5,
|
||||
spread = { x = 500, y = 500, z = 500},
|
||||
seed = 72384,
|
||||
octaves = 3,
|
||||
persistence = 0.50,
|
||||
lacunarity = 2.0,
|
||||
flags = "eased",
|
||||
}
|
||||
|
||||
local v6_flags_str = minetest.get_mapgen_setting("mgv6_spflags")
|
||||
if v6_flags_str == nil then
|
||||
v6_flags_str = ""
|
||||
end
|
||||
local v6_flags = string.split(v6_flags_str)
|
||||
local v6_use_snow_biomes = true
|
||||
local v6_use_jungles = true
|
||||
-- TODO: Implement biome blend.
|
||||
-- Currently we pretend biome blend is disabled.
|
||||
-- This just makes the calculations inaccurate near biome boundaries,
|
||||
-- but should be fine otherwise.
|
||||
local v6_use_biome_blend = false
|
||||
for f=1, #v6_flags do
|
||||
local flag = v6_flags[f]:trim()
|
||||
if flag == "nosnowbiomes" then
|
||||
v6_use_snow_biomes = false
|
||||
end
|
||||
if flag == "snowbiomes" then
|
||||
v6_use_snow_biomes = true
|
||||
end
|
||||
if flag == "nojungles" then
|
||||
v6_use_jungles = false
|
||||
end
|
||||
if flag == "jungles" then
|
||||
v6_use_jungles = true
|
||||
end
|
||||
if flag == "nobiomeblend" then
|
||||
v6_use_biome_blend = false
|
||||
end
|
||||
-- TODO
|
||||
-- if flag == "biomeblend" then
|
||||
-- v6_use_biome_blend = true
|
||||
-- end
|
||||
end
|
||||
-- Force-enable jungles when snowbiomes flag is set
|
||||
if v6_use_snow_biomes then
|
||||
v6_use_jungles = true
|
||||
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)
|
||||
-- TODO: implement noise2d function for biome blend
|
||||
return 0
|
||||
--[[
|
||||
local n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y
|
||||
+ NOISE_MAGIC_SEED * seed) & 0x7fffffff;
|
||||
n = (n >> 13) ^ n;
|
||||
n = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
|
||||
return 1.0 - n / 0x40000000;
|
||||
]]
|
||||
end
|
||||
|
||||
biomeinfo.all_v6_biomes = {
|
||||
BT_NORMAL,
|
||||
BT_DESERT,
|
||||
BT_JUNGLE,
|
||||
BT_TUNDRA,
|
||||
BT_TAIGA
|
||||
}
|
||||
|
||||
local function init_perlins()
|
||||
if not mgv6_perlin_biome then
|
||||
mgv6_np_biome = minetest.get_mapgen_setting_noiseparams("mgv6_np_biome")
|
||||
if not mgv6_np_biome then
|
||||
mgv6_np_biome = mgv6_np_biome_default
|
||||
minetest.log("action", "[biomeinfo] Using hardcoded mgv6_np_biome default")
|
||||
end
|
||||
mgv6_perlin_biome = minetest.get_perlin(mgv6_np_biome)
|
||||
end
|
||||
if not mgv6_perlin_humidity then
|
||||
local np_humidity = minetest.get_mapgen_setting_noiseparams("mgv6_np_humidity")
|
||||
if not np_humidity then
|
||||
np_humidity = mgv6_np_humidity_default
|
||||
minetest.log("action", "[biomeinfo] Using hardcoded mgv6_np_humidity default")
|
||||
end
|
||||
mgv6_perlin_humidity = minetest.get_perlin(np_humidity)
|
||||
end
|
||||
end
|
||||
|
||||
function biomeinfo.get_active_v6_biomes()
|
||||
local biomes = { BT_NORMAL, BT_DESERT }
|
||||
if v6_use_jungles then
|
||||
table.insert(biomes, BT_JUNGLE)
|
||||
end
|
||||
if v6_use_snow_biomes then
|
||||
table.insert(biomes, BT_TUNDRA)
|
||||
table.insert(biomes, BT_TAIGA)
|
||||
end
|
||||
return biomes
|
||||
end
|
||||
|
||||
function biomeinfo.get_v6_heat(pos)
|
||||
init_perlins()
|
||||
if not mgv6_perlin_biome then
|
||||
return nil
|
||||
end
|
||||
local bpos = vector.floor(pos)
|
||||
-- The temperature noise needs a special offset (see calculateNoise in mapgen_v6.cpp)
|
||||
return mgv6_perlin_biome:get_2d({x=bpos.x + mgv6_np_biome.spread.x*0.6, y=bpos.z + mgv6_np_biome.spread.z*0.2})
|
||||
end
|
||||
|
||||
function biomeinfo.get_v6_humidity(pos)
|
||||
init_perlins()
|
||||
if not mgv6_perlin_humidity then
|
||||
return nil
|
||||
end
|
||||
local bpos = vector.floor(pos)
|
||||
return mgv6_perlin_humidity:get_2d({x=bpos.x, y=bpos.z})
|
||||
end
|
||||
|
||||
-- Returns the v6 biome at pos.
|
||||
-- Returns a string representing the biome name.
|
||||
function biomeinfo.get_v6_biome(pos)
|
||||
init_perlins()
|
||||
local bpos = vector.floor(pos)
|
||||
-- Based on the algorithm MapgenV6::getBiome in mapgen_v6.cpp
|
||||
|
||||
local pos2d = {x=bpos.x, y=bpos.z}
|
||||
if not mgv6_perlin_biome or not mgv6_perlin_humidity then
|
||||
return "???"
|
||||
end
|
||||
local d = biomeinfo.get_v6_heat(bpos)
|
||||
local h = biomeinfo.get_v6_humidity(bpos)
|
||||
|
||||
if (v6_use_snow_biomes) then
|
||||
local blend
|
||||
if v6_use_biome_blend then
|
||||
blend = noise2d(pos2d.x, pos2d.y, seed) / 40
|
||||
else
|
||||
blend = 0
|
||||
end
|
||||
|
||||
if (d > MGV6_FREQ_HOT + blend) then
|
||||
if (h > MGV6_FREQ_JUNGLE + blend) then
|
||||
return BT_JUNGLE
|
||||
end
|
||||
return BT_DESERT
|
||||
end
|
||||
if (d < MGV6_FREQ_SNOW + blend) then
|
||||
if (h > MGV6_FREQ_TAIGA + blend) then
|
||||
return BT_TAIGA
|
||||
end
|
||||
return BT_TUNDRA
|
||||
end
|
||||
return BT_NORMAL
|
||||
end
|
||||
|
||||
if (d > v6_freq_desert) then
|
||||
return BT_DESERT
|
||||
end
|
||||
|
||||
if ((v6_use_biome_blend) and (d > v6_freq_desert - 0.10) and
|
||||
((noise2d(pos2d.x, pos2d.y, seed) + 1.0) > (v6_freq_desert - d) * 20.0)) then
|
||||
return BT_DESERT
|
||||
end
|
||||
|
||||
if ((v6_use_jungles) and (h > 0.75)) then
|
||||
return BT_JUNGLE
|
||||
end
|
||||
|
||||
return BT_NORMAL
|
||||
end
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
name = biomeinfo
|
||||
description = Simple API to get data about biomes.
|
|
@ -1,504 +0,0 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random
|
||||
Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
|
@ -1,2 +0,0 @@
|
|||
Controls framework by Arcelmi.
|
||||
https://github.com/Arcelmi/minetest-controls
|
|
@ -1,63 +0,0 @@
|
|||
controls = {}
|
||||
controls.players = {}
|
||||
|
||||
controls.registered_on_press = {}
|
||||
function controls.register_on_press(func)
|
||||
controls.registered_on_press[#controls.registered_on_press+1] = func
|
||||
end
|
||||
|
||||
controls.registered_on_release = {}
|
||||
function controls.register_on_release(func)
|
||||
controls.registered_on_release[#controls.registered_on_release+1] = func
|
||||
end
|
||||
|
||||
controls.registered_on_hold = {}
|
||||
function controls.register_on_hold(func)
|
||||
controls.registered_on_hold[#controls.registered_on_hold+1]=func
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
controls.players[name] = {
|
||||
jump={false},
|
||||
right={false},
|
||||
left={false},
|
||||
LMB={false},
|
||||
RMB={false},
|
||||
sneak={false},
|
||||
aux1={false},
|
||||
down={false},
|
||||
up={false}
|
||||
}
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
controls.players[name] = nil
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local player_name = player:get_player_name()
|
||||
local player_controls = player:get_player_control()
|
||||
for cname, cbool in pairs(player_controls) do
|
||||
--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, os.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, os.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, os.clock()-controls.players[player_name][cname][2])
|
||||
end
|
||||
controls.players[player_name][cname] = {false}
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
|
@ -1 +0,0 @@
|
|||
name=controls
|
|
@ -64,15 +64,9 @@ flowlib.node_is_liquid = node_is_liquid
|
|||
--This code is more efficient
|
||||
local function quick_flow_logic(node,pos_testing,direction)
|
||||
local name = node.name
|
||||
if not minetest.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
|
||||
return 0
|
||||
end
|
||||
if minetest.registered_nodes[node_testing.name].liquidtype
|
||||
~= "flowing" then
|
||||
return 0
|
||||
|
@ -82,9 +76,6 @@ local function quick_flow_logic(node,pos_testing,direction)
|
|||
elseif minetest.registered_nodes[name].liquidtype == "flowing" then
|
||||
local node_testing = minetest.get_node(pos_testing)
|
||||
local param2_testing = node_testing.param2
|
||||
if not minetest.registered_nodes[node_testing.name] then
|
||||
return 0
|
||||
end
|
||||
if minetest.registered_nodes[node_testing.name].liquidtype
|
||||
== "source" then
|
||||
return -direction
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Adds additional ways for nodes to be attached.
|
|
@ -1,26 +0,0 @@
|
|||
local original_function = minetest.check_single_for_falling
|
||||
|
||||
minetest.check_single_for_falling = function(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 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)
|
||||
local drops = minetest.get_node_drops(node.name, "")
|
||||
for dr=1, #drops do
|
||||
minetest.add_item(pos, drops[dr])
|
||||
end
|
||||
ret = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return ret_o or ret
|
||||
end
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
--[[ This mod automatically adds groups to items based on item metadata.
|
||||
|
||||
Specifically, this mod has 2 purposes:
|
||||
1) Automatically adding the group “solid” for blocks considered “solid” in Minecraft.
|
||||
2) Generating digging time group for all nodes based on node metadata (it's complicated)
|
||||
|
||||
]]
|
||||
|
||||
--[[ Mining times. Yeah, mining times … Alright, this is going to be FUN!
|
||||
|
||||
This mod does include a HACK to make 100% sure the digging times of all tools match Minecraft's perfectly.
|
||||
The digging times system of Minetest is very different, so this weird group trickery has to be used.so this weird group trickery has to be used.so this weird group trickery has to be used.so this weird group trickery has to be used.
|
||||
In Minecraft, each block has a hardness and the actual Minecraft digging time is determined by this:
|
||||
1) The block's hardness
|
||||
2) The tool being used
|
||||
3) Whether the tool is considered as “eligible” for the block
|
||||
(e.g. only diamond pick eligible for obsidian)
|
||||
See Minecraft Wiki <http://minecraft.gamepedia.com/Minecraft_Wiki> for more information.
|
||||
|
||||
In MineClone 2, all diggable node have the hardness set in the custom field “_mcl_hardness” (0 by default).
|
||||
The nodes are also required to specify the “eligible” tools in groups like “pickaxey”, “shovely”, etc.
|
||||
This mod then calculates the real digging time based on the node meta data. The real digging times
|
||||
are then added into mcl_autogroup.digtimes where the table indices are group rating and the values are the
|
||||
digging times in seconds. These digging times can be then added verbatim into the tool definitions.
|
||||
|
||||
Example:
|
||||
mcl_autogroup.digtimes.pickaxey_dig_diamond[1] = 0.2
|
||||
|
||||
→ This menas that when a node has been assigned the group “pickaxey_dig_diamond=1”, it can be dug by the
|
||||
diamond pickaxe in 0.2 seconds.
|
||||
|
||||
|
||||
|
||||
This strange setup with mcl_autogroup has been done to minimize the amount of required digging times
|
||||
a single tool needs to use. If this is not being done, the loading time will increase considerably
|
||||
(>10s).
|
||||
|
||||
]]
|
||||
|
||||
local materials = { "wood", "gold", "stone", "iron", "diamond" }
|
||||
local basegroups = { "pickaxey", "axey", "shovely" }
|
||||
local minigroups = { "handy", "shearsy", "swordy", "shearsy_wool", "swordy_cobweb" }
|
||||
local divisors = {
|
||||
["wood"] = 2,
|
||||
["gold"] = 12,
|
||||
["stone"] = 4,
|
||||
["iron"] = 6,
|
||||
["diamond"] = 8,
|
||||
["handy"] = 1,
|
||||
["shearsy"] = 15,
|
||||
["swordy"] = 1.5,
|
||||
["shearsy_wool"] = 5,
|
||||
["swordy_cobweb"] = 15,
|
||||
}
|
||||
|
||||
mcl_autogroup = {}
|
||||
mcl_autogroup.digtimes = {}
|
||||
mcl_autogroup.creativetimes = {} -- Copy of digtimes, except that all values are 0. Used for creative mode
|
||||
|
||||
for m=1, #materials do
|
||||
for g=1, #basegroups do
|
||||
mcl_autogroup.digtimes[basegroups[g].."_dig_"..materials[m]] = {}
|
||||
mcl_autogroup.creativetimes[basegroups[g].."_dig_"..materials[m]] = {}
|
||||
end
|
||||
end
|
||||
for g=1, #minigroups do
|
||||
mcl_autogroup.digtimes[minigroups[g].."_dig"] = {}
|
||||
mcl_autogroup.creativetimes[minigroups[g].."_dig"] = {}
|
||||
end
|
||||
|
||||
local overwrite = function()
|
||||
for nname, ndef in pairs(minetest.registered_nodes) do
|
||||
local groups_changed = false
|
||||
local newgroups = table.copy(ndef.groups)
|
||||
if (nname ~= "ignore") then
|
||||
-- Automatically assign the “solid” group for solid nodes
|
||||
if (ndef.walkable == nil or ndef.walkable == true)
|
||||
and (ndef.collision_box == nil or ndef.collision_box.type == "regular")
|
||||
and (ndef.node_box == nil or ndef.node_box.type == "regular")
|
||||
and (ndef.groups.not_solid == 0 or ndef.groups.not_solid == nil) then
|
||||
newgroups.solid = 1
|
||||
groups_changed = true
|
||||
end
|
||||
-- Automatically assign the “opaque” group for opaque nodes
|
||||
if not (ndef.paramtype == "light" or ndef.sunlight_propagates) then
|
||||
newgroups.opaque = 1
|
||||
groups_changed = true
|
||||
end
|
||||
|
||||
local function calculate_group(hardness, material, diggroup, newgroups, actual_rating, expected_rating)
|
||||
local time, validity_factor
|
||||
if actual_rating >= expected_rating then
|
||||
-- Valid tool
|
||||
validity_factor = 1.5
|
||||
else
|
||||
-- Wrong tool (higher digging time)
|
||||
validity_factor = 5
|
||||
end
|
||||
time = (hardness * validity_factor) / divisors[material]
|
||||
if time <= 0.05 then
|
||||
time = 0
|
||||
else
|
||||
time = math.ceil(time * 20) / 20
|
||||
end
|
||||
table.insert(mcl_autogroup.digtimes[diggroup], time)
|
||||
table.insert(mcl_autogroup.creativetimes[diggroup], 0)
|
||||
newgroups[diggroup] = #mcl_autogroup.digtimes[diggroup]
|
||||
return newgroups
|
||||
end
|
||||
|
||||
-- Hack in digging times
|
||||
local hardness = ndef._mcl_hardness
|
||||
if not hardness then
|
||||
hardness = 0
|
||||
end
|
||||
|
||||
-- Handle pickaxey, axey and shovely
|
||||
for _, basegroup in pairs(basegroups) do
|
||||
if (hardness ~= -1 and ndef.groups[basegroup]) then
|
||||
for g=1,#materials do
|
||||
local diggroup = basegroup.."_dig_"..materials[g]
|
||||
newgroups = calculate_group(hardness, materials[g], diggroup, newgroups, g, ndef.groups[basegroup])
|
||||
groups_changed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
for m=1, #minigroups do
|
||||
local minigroup = minigroups[m]
|
||||
if hardness ~= -1 then
|
||||
local diggroup = minigroup.."_dig"
|
||||
-- actual rating
|
||||
local ar = ndef.groups[minigroup]
|
||||
if ar == nil then
|
||||
ar = 0
|
||||
end
|
||||
if (minigroup == "handy")
|
||||
or
|
||||
(ndef.groups.shearsy_wool and minigroup == "shearsy_wool" and ndef.groups.wool)
|
||||
or
|
||||
(ndef.groups.swordy_cobweb and minigroup == "swordy_cobweb" and nname == "mcl_core:cobweb")
|
||||
or
|
||||
(ndef.groups[minigroup] and minigroup ~= "swordy_cobweb" and minigroup ~= "shearsy_wool") then
|
||||
newgroups = calculate_group(hardness, minigroup, diggroup, newgroups, ar, 1)
|
||||
groups_changed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if groups_changed then
|
||||
minetest.override_item(nname, {
|
||||
groups = newgroups
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
overwrite()
|
|
@ -0,0 +1 @@
|
|||
name = mcl_autogroup
|
|
@ -1,383 +0,0 @@
|
|||
--[[
|
||||
Explosion API mod for Minetest (adapted to MineClone 2)
|
||||
|
||||
This mod is based on the Minetest explosion API mod, but has been changed
|
||||
to have the same explosion mechanics as Minecraft and work with MineClone.
|
||||
The computation-intensive parts of the mod has been optimized to allow for
|
||||
larger explosions and faster world updating.
|
||||
|
||||
This mod was created by Elias Astrom <ryvnf@riseup.net> and is released
|
||||
under the LGPLv2.1 license.
|
||||
--]]
|
||||
|
||||
mcl_explosions = {}
|
||||
|
||||
local creative_mode = minetest.settings:get_bool("creative_mode")
|
||||
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 S = minetest.get_translator("mcl_explosions")
|
||||
|
||||
-- Saved sphere explosion shapes for various radiuses
|
||||
local sphere_shapes = {}
|
||||
|
||||
-- Saved node definitions in table using cid-keys for faster look-up.
|
||||
local node_blastres = {}
|
||||
local node_on_blast = {}
|
||||
local node_walkable = {}
|
||||
|
||||
-- The step length for the rays (Minecraft uses 0.3)
|
||||
local STEP_LENGTH = 0.3
|
||||
|
||||
-- How many rays to compute entity exposure to explosion
|
||||
local N_EXPOSURE_RAYS = 16
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
-- Store blast resistance values by content ids to improve performance.
|
||||
for name, def in pairs(minetest.registered_nodes) do
|
||||
node_blastres[minetest.get_content_id(name)] = def._mcl_blast_resistance or 0
|
||||
node_on_blast[minetest.get_content_id(name)] = def.on_blast
|
||||
node_walkable[minetest.get_content_id(name)] = def.walkable
|
||||
end
|
||||
end)
|
||||
|
||||
-- Compute the rays which make up a sphere with radius. Returns a list of rays
|
||||
-- which can be used to trace explosions. This function is not efficient
|
||||
-- (especially for larger radiuses), so the generated rays for various radiuses
|
||||
-- should be cached and reused.
|
||||
--
|
||||
-- Should be possible to improve by using a midpoint circle algorithm multiple
|
||||
-- times to create the sphere, currently uses more of a brute-force approach.
|
||||
local function compute_sphere_rays(radius)
|
||||
local rays = {}
|
||||
local sphere = {}
|
||||
|
||||
for i=1, 2 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[minetest.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[minetest.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[minetest.hash_node_position(pos)] = pos
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, pos in pairs(sphere) do
|
||||
rays[#rays + 1] = vector.normalize(pos)
|
||||
end
|
||||
|
||||
return rays
|
||||
end
|
||||
|
||||
-- Add particles from explosion
|
||||
--
|
||||
-- Parameters:
|
||||
-- pos - The position of the explosion
|
||||
-- radius - The radius of the explosion
|
||||
local function add_particles(pos, radius)
|
||||
minetest.add_particlespawner({
|
||||
amount = 64,
|
||||
time = 0.125,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = {x = -radius, y = -radius, z = -radius},
|
||||
maxvel = {x = radius, y = radius, z = radius},
|
||||
minacc = vector.new(),
|
||||
maxacc = vector.new(),
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1.0,
|
||||
minsize = radius * 0.5,
|
||||
maxsize = radius * 1.0,
|
||||
texture = "tnt_smoke.png",
|
||||
})
|
||||
end
|
||||
|
||||
-- Traces the rays of an explosion, and updates the environment.
|
||||
--
|
||||
-- Parameters:
|
||||
-- pos - Where the rays in the explosion should start from
|
||||
-- strength - The strength of each ray
|
||||
-- raydirs - The directions for each ray
|
||||
-- radius - The maximum distance each ray will go
|
||||
-- drop_chance - The chance that destroyed nodes will drop their items
|
||||
-- fire - If true, 1/3 of destroyed nodes become fire
|
||||
-- puncher - object that punches other objects (optional)
|
||||
--
|
||||
-- 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, drop_chance, fire, puncher)
|
||||
local vm = minetest.get_voxel_manip()
|
||||
|
||||
local emin, emax = vm:read_from_map(vector.subtract(pos, radius),
|
||||
vector.add(pos, radius))
|
||||
local emin_x = emin.x
|
||||
local emin_y = emin.y
|
||||
local emin_z = emin.z
|
||||
|
||||
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 {
|
||||
MinEdge = emin,
|
||||
MaxEdge = emax
|
||||
}
|
||||
local data = vm:get_data()
|
||||
local destroy = {}
|
||||
|
||||
-- Trace rays for environment destruction
|
||||
for i = 1, #raydirs do
|
||||
local rpos_x = pos.x
|
||||
local rpos_y = pos.y
|
||||
local rpos_z = pos.z
|
||||
local rdir_x = raydirs[i].x
|
||||
local rdir_y = raydirs[i].y
|
||||
local rdir_z = raydirs[i].z
|
||||
local rstr = (0.7 + math.random() * 0.6) * strength
|
||||
|
||||
for r = 0, math.ceil(radius * (1.0 / STEP_LENGTH)) do
|
||||
local npos_x = math.floor(rpos_x + 0.5)
|
||||
local npos_y = math.floor(rpos_y + 0.5)
|
||||
local npos_z = math.floor(rpos_z + 0.5)
|
||||
local idx = (npos_z - emin_z) * zstride + (npos_y - emin_y) * ystride +
|
||||
npos_x - emin_x + 1
|
||||
|
||||
local cid = data[idx]
|
||||
local br = node_blastres[cid]
|
||||
local hash = (npos_z + 32768) * 65536 * 65536 +
|
||||
(npos_y + 32768) * 65536 +
|
||||
npos_x + 32768
|
||||
|
||||
rpos_x = rpos_x + STEP_LENGTH * rdir_x
|
||||
rpos_y = rpos_y + STEP_LENGTH * rdir_y
|
||||
rpos_z = rpos_z + STEP_LENGTH * rdir_z
|
||||
|
||||
rstr = rstr - 0.75 * STEP_LENGTH - (br + 0.3) * STEP_LENGTH
|
||||
|
||||
if rstr <= 0 then
|
||||
break
|
||||
end
|
||||
|
||||
if cid ~= minetest.CONTENT_AIR then
|
||||
destroy[hash] = idx
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Entities in radius of explosion
|
||||
local punch_radius = 2 * strength
|
||||
local objs = minetest.get_objects_inside_radius(pos, punch_radius)
|
||||
|
||||
-- Trace rays for entity damage
|
||||
for _, obj in pairs(objs) do
|
||||
local ent = obj:get_luaentity()
|
||||
|
||||
-- Ignore items to lower lag
|
||||
if obj:is_player() or (ent and ent.name ~= '__builtin.item') then
|
||||
local opos = obj:get_pos()
|
||||
local collisionbox = nil
|
||||
|
||||
if obj:is_player() then
|
||||
collisionbox = { -0.3, 0.0, -0.3, 0.3, 1.77, 0.3 }
|
||||
elseif ent.name then
|
||||
local def = minetest.registered_entities[ent.name]
|
||||
collisionbox = def.collisionbox
|
||||
end
|
||||
|
||||
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 x_len = math.abs(x2 - x1)
|
||||
local y_len = math.abs(y2 - y1)
|
||||
local z_len = math.abs(z2 - z1)
|
||||
|
||||
-- Move object position to the center of its bounding box
|
||||
opos.x = opos.x + x1 + x2
|
||||
opos.y = opos.y + y1 + y2
|
||||
opos.z = opos.z + z1 + z2
|
||||
|
||||
-- Count number of rays from collision box which are unobstructed
|
||||
local count = N_EXPOSURE_RAYS
|
||||
|
||||
for i = 1, N_EXPOSURE_RAYS do
|
||||
local rpos_x = opos.x + math.random() * x_len - x_len / 2
|
||||
local rpos_y = opos.y + math.random() * y_len - y_len / 2
|
||||
local rpos_z = opos.z + math.random() * z_len - z_len / 2
|
||||
local rdir_x = pos.x - rpos_x
|
||||
local rdir_y = pos.y - rpos_y
|
||||
local rdir_z = pos.z - rpos_z
|
||||
local rdir_len = math.hypot(rdir_x, math.hypot(rdir_y, rdir_z))
|
||||
rdir_x = rdir_x / rdir_len
|
||||
rdir_y = rdir_y / rdir_len
|
||||
rdir_z = rdir_z / rdir_len
|
||||
|
||||
for i=0, rdir_len / STEP_LENGTH do
|
||||
rpos_x = rpos_x + rdir_x * STEP_LENGTH
|
||||
rpos_y = rpos_y + rdir_y * STEP_LENGTH
|
||||
rpos_z = rpos_z + rdir_z * STEP_LENGTH
|
||||
local npos_x = math.floor(rpos_x + 0.5)
|
||||
local npos_y = math.floor(rpos_y + 0.5)
|
||||
local npos_z = math.floor(rpos_z + 0.5)
|
||||
local idx = (npos_z - emin_z) * zstride + (npos_y - emin_y) * ystride +
|
||||
npos_x - emin_x + 1
|
||||
|
||||
|
||||
local cid = data[idx]
|
||||
local walkable = node_walkable[cid]
|
||||
|
||||
if walkable then
|
||||
count = count - 1
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Punch entity with damage depending on explosion exposure and
|
||||
-- distance to explosion
|
||||
local exposure = count / N_EXPOSURE_RAYS
|
||||
local punch_vec = vector.subtract(opos, pos)
|
||||
local punch_dir = vector.normalize(punch_vec)
|
||||
local impact = (1 - vector.length(punch_vec) / punch_radius) * exposure
|
||||
if impact < 0 then
|
||||
impact = 0
|
||||
end
|
||||
local damage = math.floor((impact * impact + impact) * 7 * strength + 1)
|
||||
if mod_death_messages and obj:is_player() then
|
||||
mcl_death_messages.player_damage(obj, S("@1 was caught in an explosion.", obj:get_player_name()))
|
||||
end
|
||||
local source = puncher
|
||||
if not source then
|
||||
source = obj
|
||||
end
|
||||
obj:punch(source, 10, { damage_groups = { full_punch_interval = 1,
|
||||
fleshy = damage, knockback = impact * 20.0 } }, punch_dir)
|
||||
|
||||
if obj:is_player() then
|
||||
obj:add_player_velocity(vector.multiply(punch_dir, impact * 20))
|
||||
elseif ent.tnt_knockback then
|
||||
obj:add_velocity(vector.multiply(punch_dir, impact * 20))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove destroyed blocks and drop items
|
||||
for hash, idx in pairs(destroy) do
|
||||
local do_drop = not creative_mode and math.random() <= drop_chance
|
||||
local on_blast = node_on_blast[data[idx]]
|
||||
local remove = true
|
||||
|
||||
if do_drop or on_blast ~= nil then
|
||||
local npos = minetest.get_position_from_hash(hash)
|
||||
if on_blast ~= nil then
|
||||
remove = on_blast(npos, 1.0)
|
||||
else
|
||||
local name = minetest.get_name_from_content_id(data[idx])
|
||||
local drop = minetest.get_node_drops(name, "")
|
||||
|
||||
for _, item in ipairs(drop) do
|
||||
if type(item) ~= "string" then
|
||||
item = item:get_name() .. item:get_count()
|
||||
end
|
||||
minetest.add_item(npos, item)
|
||||
end
|
||||
end
|
||||
end
|
||||
if remove then
|
||||
if mod_fire and fire and math.random(1, 3) == 1 then
|
||||
data[idx] = CONTENT_FIRE
|
||||
else
|
||||
data[idx] = minetest.CONTENT_AIR
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Log explosion
|
||||
minetest.log('action', 'Explosion at ' .. minetest.pos_to_string(pos) ..
|
||||
' with strength ' .. strength .. ' and radius ' .. radius)
|
||||
|
||||
-- Update environment
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_liquids()
|
||||
end
|
||||
|
||||
-- Create an explosion with strength at pos.
|
||||
--
|
||||
-- Parameters:
|
||||
-- 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)
|
||||
--
|
||||
-- Values in info:
|
||||
-- drop_chance - If specified becomes the drop chance of all nodes in the
|
||||
-- explosion (defaults to 1.0 / strength)
|
||||
-- no_sound - If true then the explosion will not play a sound
|
||||
-- no_particle - If true then the explosion will not create particles
|
||||
-- fire - If true, 1/3 nodes become fire (default: false)
|
||||
function mcl_explosions.explode(pos, strength, info, puncher)
|
||||
-- The maximum blast radius (in the air)
|
||||
local radius = math.ceil(1.3 * strength / (0.3 * 0.75) * 0.3)
|
||||
|
||||
if not sphere_shapes[radius] then
|
||||
sphere_shapes[radius] = compute_sphere_rays(radius)
|
||||
end
|
||||
local shape = sphere_shapes[radius]
|
||||
|
||||
trace_explode(pos, strength, shape, radius, (info and info.drop_chance) or 1 / strength, info.fire == true, puncher)
|
||||
|
||||
if not (info and info.no_sound) then
|
||||
add_particles(pos, radius)
|
||||
end
|
||||
if not (info and info.no_particle) then
|
||||
minetest.sound_play("tnt_explode", {
|
||||
pos = pos, gain = 1.0,
|
||||
max_hear_distance = strength * 16
|
||||
}, true)
|
||||
end
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
# textdomain:mcl_explosions
|
||||
@1 was caught in an explosion.=@1 wurde Opfer einer Explosion.
|
|
@ -1,2 +0,0 @@
|
|||
# textdomain:mcl_explosions
|
||||
@1 was caught in an explosion.=
|
|
@ -1,3 +0,0 @@
|
|||
name = mcl_explosions
|
||||
description = A common API to create explosions.
|
||||
optional_depends = mcl_fire
|
|
@ -1,103 +1,65 @@
|
|||
-- Some global variables (don't overwrite them!)
|
||||
mcl_vars = {}
|
||||
|
||||
--- GUI / inventory menu settings
|
||||
--- GUI / inventory menu colors
|
||||
mcl_vars.gui_slots = "listcolors[#9990;#FFF7;#FFF0;#000;#FFF]"
|
||||
-- nonbg is added as formspec prepend in mcl_formspec_prepend
|
||||
mcl_vars.gui_nonbg = mcl_vars.gui_slots ..
|
||||
"style_type[image_button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]"..
|
||||
"style_type[button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]"..
|
||||
"style_type[field;textcolor=#323232]"..
|
||||
"style_type[label;textcolor=#323232]"..
|
||||
"style_type[textarea;textcolor=#323232]"..
|
||||
"style_type[checkbox;textcolor=#323232]"
|
||||
mcl_vars.gui_bg = "bgcolor[#080808BB;true]"
|
||||
mcl_vars.gui_bg_img = ""
|
||||
|
||||
-- Background stuff must be manually added by mods (no formspec prepend)
|
||||
mcl_vars.gui_bg_color = "bgcolor[#00000000]"
|
||||
mcl_vars.gui_bg_img = "background9[1,1;1,1;mcl_base_textures_background9.png;true;7]"
|
||||
|
||||
-- Legacy
|
||||
mcl_vars.inventory_header = ""
|
||||
mcl_vars.inventory_header = mcl_vars.gui_slots .. mcl_vars.gui_bg
|
||||
|
||||
-- Mapgen variables
|
||||
local mg_name = minetest.get_mapgen_setting("mg_name")
|
||||
local minecraft_height_limit = 256
|
||||
local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true"
|
||||
|
||||
if not superflat then
|
||||
-- Normal mode
|
||||
--[[ Realm stacking (h is for height)
|
||||
- Overworld (h>=256)
|
||||
- Void (h>=1000)
|
||||
- Realm Barrier (h=11), to allow escaping the End
|
||||
- End (h>=256)
|
||||
- Void (h>=1000)
|
||||
- Nether (h=128)
|
||||
- Void (h>=1000)
|
||||
]]
|
||||
|
||||
-- Overworld
|
||||
if mg_name ~= "flat" then
|
||||
mcl_vars.mg_overworld_min = -62
|
||||
mcl_vars.mg_overworld_max_official = mcl_vars.mg_overworld_min + minecraft_height_limit
|
||||
mcl_vars.mg_overworld_max = mcl_vars.mg_overworld_min + minecraft_height_limit
|
||||
|
||||
-- 1 flat bedrock layer with 4 rough layers above
|
||||
mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min
|
||||
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min + 4
|
||||
mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min + 10
|
||||
mcl_vars.mg_lava = true
|
||||
mcl_vars.mg_bedrock_is_rough = true
|
||||
|
||||
else
|
||||
-- Classic superflat
|
||||
local ground = minetest.get_mapgen_setting("mgflat_ground_level")
|
||||
ground = tonumber(ground)
|
||||
if not ground then
|
||||
ground = 8
|
||||
end
|
||||
mcl_vars.mg_overworld_min = ground - 3
|
||||
mcl_vars.mg_overworld_max_official = mcl_vars.mg_overworld_min + minecraft_height_limit
|
||||
mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min
|
||||
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min
|
||||
mcl_vars.mg_lava = false
|
||||
mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min
|
||||
mcl_vars.mg_bedrock_is_rough = false
|
||||
end
|
||||
|
||||
mcl_vars.mg_overworld_max = 31000
|
||||
|
||||
-- The Nether (around Y = -29000)
|
||||
mcl_vars.mg_nether_min = -29067 -- Carefully chosen to be at a mapchunk border
|
||||
mcl_vars.mg_nether_max = mcl_vars.mg_nether_min + 128
|
||||
mcl_vars.mg_bedrock_nether_bottom_min = mcl_vars.mg_nether_min
|
||||
mcl_vars.mg_bedrock_nether_top_max = mcl_vars.mg_nether_max
|
||||
if not superflat then
|
||||
mcl_vars.mg_bedrock_nether_bottom_max = mcl_vars.mg_bedrock_nether_bottom_min + 4
|
||||
mcl_vars.mg_bedrock_nether_top_min = mcl_vars.mg_bedrock_nether_top_max - 4
|
||||
mcl_vars.mg_lava_nether_max = mcl_vars.mg_nether_min + 31
|
||||
else
|
||||
-- Thin bedrock in classic superflat mapgen
|
||||
mcl_vars.mg_bedrock_nether_bottom_max = mcl_vars.mg_bedrock_nether_bottom_min
|
||||
mcl_vars.mg_bedrock_nether_top_min = mcl_vars.mg_bedrock_nether_top_max
|
||||
mcl_vars.mg_lava_nether_max = mcl_vars.mg_nether_min + 2
|
||||
end
|
||||
if mg_name == "flat" then
|
||||
if superflat then
|
||||
mcl_vars.mg_flat_nether_floor = mcl_vars.mg_bedrock_nether_bottom_max + 4
|
||||
mcl_vars.mg_flat_nether_ceiling = mcl_vars.mg_bedrock_nether_bottom_max + 52
|
||||
else
|
||||
mcl_vars.mg_flat_nether_floor = mcl_vars.mg_lava_nether_max + 4
|
||||
mcl_vars.mg_flat_nether_ceiling = mcl_vars.mg_lava_nether_max + 52
|
||||
local layer_setting = minetest.get_mapgen_setting("mcl_superflat_layers")
|
||||
local layers
|
||||
if layer_setting then
|
||||
layers = {}
|
||||
local s_version, s_layers, _, _ = string.split(layer_setting, ";", true, 4)
|
||||
if tonumber(s_version) == 3 then
|
||||
local split_layers = string.split(s_layers, ",")
|
||||
if split_layers then
|
||||
for s=1, #split_layers do
|
||||
local node, repetitions = string.match(split_layers[s], "([0-9a-zA-Z:]+)%*([0-9]+)")
|
||||
if not node then
|
||||
node = string.match(split_layers[s], "([0-9a-zA-Z:]+)")
|
||||
repetitions = 1
|
||||
end
|
||||
for r=1, repetitions do
|
||||
table.insert(layers, node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not layers then
|
||||
layers = {
|
||||
"mcl_core:bedrock",
|
||||
"mcl_core:dirt",
|
||||
"mcl_core:dirt",
|
||||
"mcl_core:dirt_with_grass",
|
||||
}
|
||||
end
|
||||
|
||||
mcl_vars.mg_flat_layers = layers
|
||||
|
||||
mcl_vars.mg_overworld_min = ground - #layers + 1
|
||||
mcl_vars.mg_overworld_max = mcl_vars.mg_overworld_min + minecraft_height_limit
|
||||
end
|
||||
|
||||
-- The End (surface at ca. Y = -27000)
|
||||
mcl_vars.mg_end_min = -27073 -- Carefully chosen to be at a mapchunk border
|
||||
mcl_vars.mg_end_max_official = mcl_vars.mg_end_min + minecraft_height_limit
|
||||
mcl_vars.mg_end_max = mcl_vars.mg_overworld_min - 2000
|
||||
mcl_vars.mg_end_platform_pos = { x = 100, y = mcl_vars.mg_end_min + 74, z = 0 }
|
||||
|
||||
-- Realm barrier used to safely separate the End from the void below the Overworld
|
||||
mcl_vars.mg_realm_barrier_overworld_end_max = mcl_vars.mg_end_max
|
||||
mcl_vars.mg_realm_barrier_overworld_end_min = mcl_vars.mg_end_max - 11
|
||||
|
||||
-- Set default stack sizes
|
||||
minetest.nodedef_default.stack_max = 64
|
||||
minetest.craftitemdef_default.stack_max = 64
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
API for filling a chest with random treasures.
|
|
@ -1,151 +0,0 @@
|
|||
mcl_loot = {}
|
||||
|
||||
--[[
|
||||
Select a number of itemstacks out of a pool of treasure definitions randomly.
|
||||
|
||||
Parameters:
|
||||
* loot_definitions: Probabilities and information about the loot to select. Syntax:
|
||||
|
||||
{
|
||||
stacks_min = 1, -- Minimum number of item stacks to get. Default: 1
|
||||
stacks_max = 3, -- Maximum number of item stacks to get. Default: 1
|
||||
items = { -- Table of possible loot items. This function selects between stacks_min and stacks_max of these.
|
||||
{
|
||||
itemstring = "example:item1", -- Which item to select
|
||||
amount_min = 1, -- Minimum size of itemstack. Must not be larger than 6553. Optional (default: 1)
|
||||
amount_max = 10, -- Maximum size of item stack. Must not be larger than item definition's stack_max or 6553. Optional (default: 1)
|
||||
wear_min = 1, -- Minimum wear value. Must be at least 1. Optional (default: no wear)
|
||||
wear_max = 1, -- Maxiumum wear value. Must be at least 1. Optional (default: no wear)
|
||||
weight = 5, -- Likelihood of this item being selected (see below). Optional (default: 1)
|
||||
},
|
||||
{ -- more tables like above, one table per item stack }
|
||||
}
|
||||
}
|
||||
* pr: PseudoRandom object used for the randomness
|
||||
|
||||
How weight works: The probability of a single item stack being selected is weight/total_weight, with
|
||||
total_weight being the sum of all weight values in the items table. If you leave out the weight for
|
||||
all items, the likelihood of each item being selected is equal.
|
||||
|
||||
Returns: Table of itemstrings
|
||||
]]
|
||||
function mcl_loot.get_loot(loot_definitions, pr)
|
||||
local items = {}
|
||||
|
||||
local total_weight = 0
|
||||
for i=1, #loot_definitions.items do
|
||||
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 = pr:next(loot_definitions.stacks_min, loot_definitions.stacks_max)
|
||||
for s=1, stacks do
|
||||
local r = pr:next(1, total_weight)
|
||||
|
||||
local accumulated_weight = 0
|
||||
local item
|
||||
for i=1, #loot_definitions.items do
|
||||
accumulated_weight = accumulated_weight + (loot_definitions.items[i].weight or 1)
|
||||
if accumulated_weight >= r then
|
||||
item = loot_definitions.items[i]
|
||||
break
|
||||
end
|
||||
end
|
||||
if item then
|
||||
local itemstring = item.itemstring
|
||||
if item.amount_min and item.amount_max then
|
||||
itemstring = itemstring .. " " .. pr:next(item.amount_min, item.amount_max)
|
||||
end
|
||||
if item.wear_min and item.wear_max then
|
||||
-- Sadly, PseudoRandom only allows very narrow ranges, so we set wear in steps of 10
|
||||
local wear_min = math.floor(item.wear_min / 10)
|
||||
local wear_max = math.floor(item.wear_max / 10)
|
||||
local wear = pr:next(wear_min, wear_max) * 10
|
||||
|
||||
if not item.amount_min and not item.amount_max then
|
||||
itemstring = itemstring .. " 1"
|
||||
end
|
||||
|
||||
itemstring = itemstring .. " " .. tostring(wear)
|
||||
end
|
||||
table.insert(items, itemstring)
|
||||
else
|
||||
minetest.log("error", "[mcl_loot] INTERNAL ERROR! Failed to select random loot item!")
|
||||
end
|
||||
end
|
||||
|
||||
return items
|
||||
end
|
||||
|
||||
--[[
|
||||
Repeat mcl_loot.get_loot multiple times for various loot_definitions.
|
||||
Useful for filling chests.
|
||||
|
||||
* multi_loot_definitions: Table of loot_definitions (see mcl_loot.get_loot)
|
||||
* pr: PseudoRandom object used for the randomness
|
||||
|
||||
Returns: Table of itemstrings ]]
|
||||
function mcl_loot.get_multi_loot(multi_loot_definitions, pr)
|
||||
local items = {}
|
||||
for m=1, #multi_loot_definitions do
|
||||
local group = mcl_loot.get_loot(multi_loot_definitions[m], pr)
|
||||
for g=1, #group do
|
||||
table.insert(items, group[g])
|
||||
end
|
||||
end
|
||||
return items
|
||||
end
|
||||
|
||||
--[[
|
||||
Returns a table of length `max_slot` and all natural numbers between 1 and `max_slot`
|
||||
in a random order.
|
||||
]]
|
||||
local function get_random_slots(max_slot)
|
||||
local slots = {}
|
||||
for s=1, max_slot do
|
||||
slots[s] = s
|
||||
end
|
||||
local slots_out = {}
|
||||
while #slots > 0 do
|
||||
local r = math.random(1, #slots)
|
||||
table.insert(slots_out, slots[r])
|
||||
table.remove(slots, r)
|
||||
end
|
||||
return slots_out
|
||||
end
|
||||
|
||||
--[[
|
||||
Puts items in an inventory list into random slots.
|
||||
* inv: InvRef
|
||||
* listname: Inventory list name
|
||||
* items: table of items to add
|
||||
|
||||
Items will be added from start of the table to end.
|
||||
If the inventory already has occupied slots, or is
|
||||
too small, placement of some items might fail.
|
||||
]]
|
||||
function mcl_loot.fill_inventory(inv, listname, items)
|
||||
local size = inv:get_size(listname)
|
||||
local slots = get_random_slots(size)
|
||||
local leftovers = {}
|
||||
-- 1st pass: Add items into random slots
|
||||
for i=1, math.min(#items, size) do
|
||||
local item = items[i]
|
||||
local slot = slots[i]
|
||||
local old_item = inv:get_stack(listname, slot)
|
||||
local leftover = old_item:add_item(item)
|
||||
inv:set_stack(listname, slot, old_item)
|
||||
if not leftover:is_empty() then
|
||||
table.insert(leftovers, item)
|
||||
end
|
||||
end
|
||||
-- 2nd pass: If some items couldn't be added in first pass,
|
||||
-- try again in a non-random fashion
|
||||
for l=1, math.min(#leftovers, size) do
|
||||
inv:add_item(listname, leftovers[l])
|
||||
end
|
||||
-- If there are still items left, tough luck!
|
||||
end
|
|
@ -1 +0,0 @@
|
|||
name = mcl_loot
|
|
@ -1 +0,0 @@
|
|||
Contains particle images of MineClone 2. No code.
|
|
@ -1 +0,0 @@
|
|||
name = mcl_particles
|
Before Width: | Height: | Size: 938 B |
Before Width: | Height: | Size: 101 B |
|
@ -1,20 +1,14 @@
|
|||
Licenses of sounds
|
||||
License of sounds
|
||||
-----------------
|
||||
|
||||
Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
http://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
Creative Commons Attribution 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by/3.0/
|
||||
|
||||
Glass breaking sounds (CC BY 3.0):
|
||||
1: http://www.freesound.org/people/cmusounddesign/sounds/71947/
|
||||
2: http://www.freesound.org/people/Tomlija/sounds/97669/
|
||||
3: http://www.freesound.org/people/lsprice/sounds/88808/
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
default_tool_breaks.ogg by EdgardEdition (CC BY 3.0), http://www.freesound.org/people/EdgardEdition
|
||||
|
||||
Mito551 (sounds) (CC BY-SA 3.0):
|
||||
|
@ -38,6 +32,8 @@ Mito551 (sounds) (CC BY-SA 3.0):
|
|||
default_place_node.3.ogg
|
||||
default_place_node_hard.1.ogg
|
||||
default_place_node_hard.2.ogg
|
||||
default_snow_footstep.1.ogg
|
||||
default_snow_footstep.2.ogg
|
||||
default_hard_footstep.1.ogg
|
||||
default_hard_footstep.2.ogg
|
||||
default_hard_footstep.3.ogg
|
||||
|
@ -49,49 +45,3 @@ Mito551 (sounds) (CC BY-SA 3.0):
|
|||
default_dirt_footstep.2.ogg
|
||||
default_glass_footstep.ogg
|
||||
|
||||
Metal sounds:
|
||||
default_dig_metal.ogg - yadronoff - CC-BY-3.0
|
||||
- https://www.freesound.org/people/yadronoff/sounds/320397/
|
||||
default_dug_metal.*.ogg - Iwan Gabovitch - qubodup - CC0
|
||||
- http://opengameart.org/users/qubodup
|
||||
default_metal_footstep.*.ogg - Ottomaani138 - CC0
|
||||
- https://www.freesound.org/people/Ottomaani138/sounds/232692/
|
||||
default_place_node_metal.*.ogg - Ogrebane - CC0
|
||||
- http://opengameart.org/content/wood-and-metal-sound-effects-volume-2
|
||||
|
||||
AGFX (CC BY 3.0)
|
||||
https://www.freesound.org/people/AGFX/packs/1253/
|
||||
default_water_footstep.1.ogg
|
||||
default_water_footstep.2.ogg
|
||||
default_water_footstep.3.ogg
|
||||
(default_water_footstep.4.ogg is silent)
|
||||
|
||||
blukotek (CC0 1.0)
|
||||
https://www.freesound.org/people/blukotek/sounds/251660/
|
||||
default_dig_snappy.ogg
|
||||
|
||||
sonictechtonic (CC BY 3.0)
|
||||
https://www.freesound.org/people/sonictechtonic/sounds/241872/
|
||||
player_damage.ogg
|
||||
|
||||
Voxelands project <http://www.voxelands.com/> (CC BY-SA 3.0)
|
||||
mcl_sounds_place_node_water.ogg
|
||||
mcl_sounds_dug_water.ogg
|
||||
|
||||
(Note: Artists from the Voxelands project include: sdzen, darkrose, sapier,
|
||||
Tom Peter, Telaron, juskiddink)
|
||||
|
||||
Michel Baradari <https://opengameart.org/content/lava-splash> (CC BY 3.0)
|
||||
|
||||
default_place_node_lava.ogg
|
||||
|
||||
Adam_N (CC0 1.0):
|
||||
player_falling_damage.ogg
|
||||
Source: <https://www.freesound.org/people/Adam_N/sounds/346692/>
|
||||
|
||||
Alecia Shepherd (CC BY-SA 4.0):
|
||||
mcl_sounds_cloth.ogg
|
||||
Source: SnowSong sound and music pack <https://opengameart.org/content/snowsong-sound-and-music-pack>
|
||||
|
||||
Unknown authors (WTFPL):
|
||||
pedology_snow_soft_footstep.*.ogg
|
||||
|
|
|
@ -29,19 +29,8 @@ function mcl_sounds.node_sound_stone_defaults(table)
|
|||
return table
|
||||
end
|
||||
|
||||
function mcl_sounds.node_sound_metal_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="default_metal_footstep", gain=0.5}
|
||||
table.dug = table.dug or
|
||||
{name="default_dug_metal", gain=1.0}
|
||||
table.dig = table.dig or
|
||||
{name="default_dig_metal", gain=1.0}
|
||||
table.place = table.place or
|
||||
{name="default_place_node_metal", gain=1.0}
|
||||
mcl_sounds.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
-- TODO: Maybe add custom metal sounds
|
||||
mcl_sounds.node_sound_metal_defaults = mcl_sounds.node_sound_stone_defaults
|
||||
|
||||
function mcl_sounds.node_sound_dirt_defaults(table)
|
||||
table = table or {}
|
||||
|
@ -74,9 +63,9 @@ end
|
|||
function mcl_sounds.node_sound_snow_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="pedology_snow_soft_footstep", gain=0.5}
|
||||
{name="default_snow_footstep", gain=0.5}
|
||||
table.dug = table.dug or
|
||||
{name="pedology_snow_soft_footstep", gain=1.0}
|
||||
{name="default_snow_footstep", gain=1.0}
|
||||
table.dig = table.dig or
|
||||
{name="default_dig_crumbly", gain=1.0}
|
||||
table.place = table.place or
|
||||
|
@ -97,20 +86,6 @@ function mcl_sounds.node_sound_wood_defaults(table)
|
|||
return table
|
||||
end
|
||||
|
||||
function mcl_sounds.node_sound_wool_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="mcl_sounds_cloth", gain=0.5}
|
||||
table.dug = table.dug or
|
||||
{name="mcl_sounds_cloth", gain=1.0}
|
||||
table.dig = table.dig or
|
||||
{name="mcl_sounds_cloth", gain=0.9}
|
||||
table.place = table.dig or
|
||||
{name="mcl_sounds_cloth", gain=1.0}
|
||||
mcl_sounds.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function mcl_sounds.node_sound_leaves_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
|
@ -118,7 +93,7 @@ function mcl_sounds.node_sound_leaves_defaults(table)
|
|||
table.dug = table.dug or
|
||||
{name="default_grass_footstep", gain=0.85}
|
||||
table.dig = table.dig or
|
||||
{name="default_dig_snappy", gain=0.4}
|
||||
{name="default_dig_crumbly", gain=0.4}
|
||||
table.place = table.place or
|
||||
{name="default_place_node", gain=1.0}
|
||||
mcl_sounds.node_sound_defaults(table)
|
||||
|
@ -136,33 +111,3 @@ function mcl_sounds.node_sound_glass_defaults(table)
|
|||
mcl_sounds.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function mcl_sounds.node_sound_water_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name = "default_water_footstep", gain = 0.2}
|
||||
table.place = table.place or
|
||||
{name = "mcl_sounds_place_node_water", gain = 1.0}
|
||||
table.dug = table.dug or
|
||||
{name = "mcl_sounds_dug_water", gain = 1.0}
|
||||
mcl_sounds.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function mcl_sounds.node_sound_lava_defaults(table)
|
||||
table = table or {}
|
||||
-- TODO: Footstep
|
||||
table.place = table.place or
|
||||
{name = "default_place_node_lava", gain = 1.0}
|
||||
table.dug = table.dug or
|
||||
{name = "default_place_node_lava", gain = 1.0}
|
||||
-- TODO: Different dug sound
|
||||
mcl_sounds.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
-- Player death sound
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
-- TODO: Add separate death sound
|
||||
minetest.sound_play({name="player_damage", gain = 1.0}, {pos=player:get_pos(), max_hear_distance=16}, true)
|
||||
end)
|
||||
|
|
|
@ -92,70 +92,12 @@ end
|
|||
-- Similar to minetest.rotate_node.
|
||||
function mcl_util.rotate_axis(itemstack, placer, pointed_thing)
|
||||
mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing,
|
||||
minetest.settings:get_bool("creative_mode"),
|
||||
core.setting_getbool("creative_mode"),
|
||||
placer:get_player_control().sneak)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Returns position of the neighbor of a double chest node
|
||||
-- or nil if node is invalid.
|
||||
-- This function assumes that the large chest is actually intact
|
||||
-- * pos: Position of the node to investigate
|
||||
-- * param2: param2 of that node
|
||||
-- * side: Which "half" the investigated node is. "left" or "right"
|
||||
function mcl_util.get_double_container_neighbor_pos(pos, param2, side)
|
||||
if side == "right" then
|
||||
if param2 == 0 then
|
||||
return {x=pos.x-1, y=pos.y, z=pos.z}
|
||||
elseif param2 == 1 then
|
||||
return {x=pos.x, y=pos.y, z=pos.z+1}
|
||||
elseif param2 == 2 then
|
||||
return {x=pos.x+1, y=pos.y, z=pos.z}
|
||||
elseif param2 == 3 then
|
||||
return {x=pos.x, y=pos.y, z=pos.z-1}
|
||||
end
|
||||
else
|
||||
if param2 == 0 then
|
||||
return {x=pos.x+1, y=pos.y, z=pos.z}
|
||||
elseif param2 == 1 then
|
||||
return {x=pos.x, y=pos.y, z=pos.z-1}
|
||||
elseif param2 == 2 then
|
||||
return {x=pos.x-1, y=pos.y, z=pos.z}
|
||||
elseif param2 == 3 then
|
||||
return {x=pos.x, y=pos.y, z=pos.z+1}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Iterates through all items in the given inventory and
|
||||
-- returns the slot of the first item which matches a condition.
|
||||
-- Returns nil if no item was found.
|
||||
--- source_inventory: Inventory to take the item from
|
||||
--- source_list: List name of the source inventory from which to take the item
|
||||
--- destination_inventory: Put item into this inventory
|
||||
--- destination_list: List name of the destination inventory to which to put the item into
|
||||
--- condition: Function which takes an itemstack and returns true if it matches the desired item condition.
|
||||
--- If set to nil, the slot of the first item stack will be taken unconditionally.
|
||||
-- dst_inventory and dst_list can also be nil if condition is nil.
|
||||
function mcl_util.get_eligible_transfer_item_slot(src_inventory, src_list, dst_inventory, dst_list, condition)
|
||||
local size = src_inventory:get_size(src_list)
|
||||
local stack
|
||||
for i=1, size do
|
||||
stack = src_inventory:get_stack(src_list, i)
|
||||
if not stack:is_empty() and (condition == nil or condition(stack, src_inventory, src_list, dst_inventory, dst_list)) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Returns true if itemstack is a shulker box
|
||||
local is_not_shulker_box = function(itemstack)
|
||||
local g = minetest.get_item_group(itemstack:get_name(), "shulker_box")
|
||||
return g == 0 or g == nil
|
||||
end
|
||||
|
||||
-- Moves a single item from one inventory to another.
|
||||
-- Moves a single item from one inventory to another
|
||||
--- source_inventory: Inventory to take the item from
|
||||
--- source_list: List name of the source inventory from which to take the item
|
||||
--- source_stack_id: The inventory position ID of the source inventory to take the item from (-1 for first occupied slot)
|
||||
|
@ -174,156 +116,62 @@ function mcl_util.move_item(source_inventory, source_list, source_stack_id, dest
|
|||
|
||||
if not source_inventory:is_empty(source_list) then
|
||||
local stack = source_inventory:get_stack(source_list, source_stack_id)
|
||||
local item = stack:get_name()
|
||||
if not stack:is_empty() then
|
||||
local new_stack = ItemStack(stack)
|
||||
new_stack:set_count(1)
|
||||
if not destination_inventory:room_for_item(destination_list, new_stack) then
|
||||
if not destination_inventory:room_for_item(destination_list, item) then
|
||||
return false
|
||||
end
|
||||
stack:take_item()
|
||||
source_inventory:set_stack(source_list, source_stack_id, stack)
|
||||
destination_inventory:add_item(destination_list, new_stack)
|
||||
destination_inventory:add_item(destination_list, item)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Moves a single item from one container node into another. Performs a variety of high-level
|
||||
-- checks to prevent invalid transfers such as shulker boxes into shulker boxes
|
||||
-- Moves a single item from one container node into another.
|
||||
--- source_pos: Position ({x,y,z}) of the node to take the item from
|
||||
--- source_list: List name of the source inventory from which to take the item
|
||||
--- source_stack_id: The inventory position ID of the source inventory to take the item from (-1 for first occupied slot)
|
||||
--- destination_pos: Position ({x,y,z}) of the node to put the item into
|
||||
--- source_list (optional): List name of the source inventory from which to take the item. Default is normally "main"; "dst" for furnace
|
||||
--- source_stack_id (optional): The inventory position ID of the source inventory to take the item from (-1 for slot of the first valid item; -1 is default)
|
||||
--- destination_list (optional): List name of the destination inventory. Default is normally "main"; "src" for furnace
|
||||
-- Returns true on success and false on failure.
|
||||
function mcl_util.move_item_container(source_pos, destination_pos, source_list, source_stack_id, destination_list)
|
||||
local dpos = table.copy(destination_pos)
|
||||
local spos = table.copy(source_pos)
|
||||
local snode = minetest.get_node(spos)
|
||||
local dnode = minetest.get_node(dpos)
|
||||
|
||||
local dctype = minetest.get_item_group(dnode.name, "container")
|
||||
local sctype = minetest.get_item_group(snode.name, "container")
|
||||
|
||||
-- Container type 7 does not allow any movement
|
||||
if sctype == 7 then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Normalize double container by forcing to always use the left segment first
|
||||
local normalize_double_container = function(pos, node, ctype)
|
||||
if ctype == 6 then
|
||||
pos = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right")
|
||||
if not pos then
|
||||
return false
|
||||
end
|
||||
node = minetest.get_node(pos)
|
||||
ctype = minetest.get_item_group(node.name, "container")
|
||||
-- The left segment seems incorrect? We better bail out!
|
||||
if ctype ~= 5 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return pos, node, ctype
|
||||
end
|
||||
|
||||
spos, snode, sctype = normalize_double_container(spos, snode, sctype)
|
||||
dpos, dnode, dctype = normalize_double_container(dpos, dnode, dctype)
|
||||
if not spos or not dpos then return false end
|
||||
|
||||
local smeta = minetest.get_meta(spos)
|
||||
local dmeta = minetest.get_meta(dpos)
|
||||
--- destination_list: (optional) list name of the destination inventory. If not set, the main or source list will be used
|
||||
-- Returns true on success and false on failure
|
||||
function mcl_util.move_item_container(source_pos, source_list, source_stack_id, destination_pos, destination_list)
|
||||
local smeta = minetest.get_meta(source_pos)
|
||||
local dmeta = minetest.get_meta(destination_pos)
|
||||
|
||||
local sinv = smeta:get_inventory()
|
||||
local dinv = dmeta:get_inventory()
|
||||
|
||||
-- Default source lists
|
||||
if not source_list then
|
||||
-- Main inventory for most container types
|
||||
if sctype == 2 or sctype == 3 or sctype == 5 or sctype == 6 or sctype == 7 then
|
||||
source_list = "main"
|
||||
-- Furnace: output
|
||||
elseif sctype == 4 then
|
||||
source_list = "dst"
|
||||
-- Unknown source container type. Bail out
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
local snodedef = minetest.registered_nodes[minetest.get_node(source_pos).name]
|
||||
local dnodedef = minetest.registered_nodes[minetest.get_node(destination_pos).name]
|
||||
|
||||
-- Automatically select stack slot ID if set to automatic
|
||||
if not source_stack_id then
|
||||
source_stack_id = -1
|
||||
end
|
||||
if source_stack_id == -1 then
|
||||
local cond = nil
|
||||
-- Prevent shulker box inception
|
||||
if dctype == 3 then
|
||||
cond = is_not_shulker_box
|
||||
end
|
||||
source_stack_id = mcl_util.get_eligible_transfer_item_slot(sinv, source_list, dinv, dpos, cond)
|
||||
if not source_stack_id then
|
||||
-- Try again if source is a double container
|
||||
if sctype == 5 then
|
||||
spos = mcl_util.get_double_container_neighbor_pos(spos, snode.param2, "left")
|
||||
smeta = minetest.get_meta(spos)
|
||||
sinv = smeta:get_inventory()
|
||||
|
||||
source_stack_id = mcl_util.get_eligible_transfer_item_slot(sinv, source_list, dinv, dpos, cond)
|
||||
if not source_stack_id then
|
||||
return false
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Abort transfer if shulker box wants to go into shulker box
|
||||
if dctype == 3 then
|
||||
local stack = sinv:get_stack(source_list, source_stack_id)
|
||||
if stack and minetest.get_item_group(stack:get_name(), "shulker_box") == 1 then
|
||||
source_stack_id = mcl_util.get_first_occupied_inventory_slot(sinv, source_list)
|
||||
if source_stack_id == nil then
|
||||
return false
|
||||
end
|
||||
end
|
||||
-- Container type 7 does not allow any placement
|
||||
if dctype == 7 then
|
||||
return false
|
||||
end
|
||||
|
||||
-- If it's a container, put it into the container
|
||||
if dctype ~= 0 then
|
||||
if dnodedef.groups.container then
|
||||
-- Automatically select a destination list if omitted
|
||||
if not destination_list then
|
||||
-- Main inventory for most container types
|
||||
if dctype == 2 or dctype == 3 or dctype == 5 or dctype == 6 or dctype == 7 then
|
||||
if dnodedef.groups.container == 2 or snodedef.groups.continer == 3 then
|
||||
destination_list = "main"
|
||||
-- Furnace source slot
|
||||
elseif dctype == 4 then
|
||||
elseif dnodedef.groups.container == 3 then
|
||||
local stack = sinv:get_stack(source_list, source_stack_id)
|
||||
local def = minetest.registered_nodes[stack:get_name()]
|
||||
if stack and (not stack:is_empty()) and (not (def and def.groups and def.groups.shulker_box)) then
|
||||
destination_list = "main"
|
||||
end
|
||||
elseif dnodedef.groups.container == 4 then
|
||||
destination_list = "src"
|
||||
end
|
||||
end
|
||||
if destination_list then
|
||||
-- Move item
|
||||
local ok = mcl_util.move_item(sinv, source_list, source_stack_id, dinv, destination_list)
|
||||
|
||||
-- Try transfer to neighbor node if transfer failed and double container
|
||||
if not ok and dctype == 5 then
|
||||
dpos = mcl_util.get_double_container_neighbor_pos(dpos, dnode.param2, "left")
|
||||
dmeta = minetest.get_meta(dpos)
|
||||
dinv = dmeta:get_inventory()
|
||||
|
||||
ok = mcl_util.move_item(sinv, source_list, source_stack_id, dinv, destination_list)
|
||||
end
|
||||
|
||||
-- Update furnace
|
||||
if ok and dctype == 4 then
|
||||
-- Start furnace's timer function, it will sort out whether furnace can burn or not.
|
||||
minetest.get_node_timer(dpos):start(1.0)
|
||||
end
|
||||
|
||||
return ok
|
||||
return mcl_util.move_item(sinv, source_list, source_stack_id, dinv, destination_list)
|
||||
end
|
||||
end
|
||||
return false
|
||||
|
@ -332,7 +180,13 @@ end
|
|||
-- Returns the ID of the first non-empty slot in the given inventory list
|
||||
-- or nil, if inventory is empty.
|
||||
function mcl_util.get_first_occupied_inventory_slot(inventory, listname)
|
||||
return mcl_util.get_eligible_transfer_item_slot(inventory, listname)
|
||||
for i=1, inventory:get_size(listname) do
|
||||
local stack = inventory:get_stack(listname, i)
|
||||
if not stack:is_empty() then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Returns true if item (itemstring or ItemStack) can be used as a furnace fuel.
|
||||
|
@ -341,58 +195,36 @@ function mcl_util.is_fuel(item)
|
|||
return minetest.get_craft_result({method="fuel", width=1, items={item}}).time ~= 0
|
||||
end
|
||||
|
||||
-- Returns a on_place function for plants
|
||||
-- * condition: function(pos, node, itemstack)
|
||||
-- * A function which is called by the on_place function to check if the node can be placed
|
||||
-- * Must return true, if placement is allowed, false otherwise.
|
||||
-- * If it returns a string, placement is allowed, but will place this itemstring as a node instead
|
||||
-- * pos, node: Position and node table of plant node
|
||||
-- * itemstack: Itemstack to place
|
||||
function mcl_util.generate_on_place_plant_function(condition)
|
||||
return function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
-- no interaction possible with entities
|
||||
return itemstack
|
||||
end
|
||||
-- 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
|
||||
function mcl_util.is_in_void(pos)
|
||||
local void, void_deadly
|
||||
void = pos.y < mcl_vars.mg_overworld_min
|
||||
void_deadly = pos.y < mcl_vars.mg_overworld_min - 64
|
||||
return void, void_deadly
|
||||
end
|
||||
|
||||
-- Call on_rightclick if the pointed node defines it
|
||||
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
|
||||
-- Here come 2 simple converter functions which are important for map generators and mob spawning
|
||||
|
||||
local place_pos
|
||||
local def_under = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name]
|
||||
local def_above = minetest.registered_nodes[minetest.get_node(pointed_thing.above).name]
|
||||
if not def_under or not def_above then
|
||||
return itemstack
|
||||
end
|
||||
if def_under.buildable_to then
|
||||
place_pos = pointed_thing.under
|
||||
elseif def_above.buildable_to then
|
||||
place_pos = pointed_thing.above
|
||||
else
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Check placement rules
|
||||
local result, param2 = condition(place_pos, node, itemstack)
|
||||
if result == true then
|
||||
local idef = itemstack:get_definition()
|
||||
local new_itemstack, success = minetest.item_place_node(itemstack, placer, pointed_thing, param2)
|
||||
|
||||
if success then
|
||||
if idef.sounds and idef.sounds.place then
|
||||
minetest.sound_play(idef.sounds.place, {pos=pointed_thing.above, gain=1}, true)
|
||||
end
|
||||
end
|
||||
itemstack = new_itemstack
|
||||
end
|
||||
|
||||
return itemstack
|
||||
-- Takes an Y coordinate as input and returns:
|
||||
-- 1) The corresponding Minecraft layer (can be nil if void)
|
||||
-- 2) The corresponding Minecraft dimension ("overworld", "nether" or "end") or "void" if it is in the void
|
||||
-- If the Y coordinate is not located in any dimension, it will return:
|
||||
-- nil, "void"
|
||||
function mcl_util.y_to_layer(y)
|
||||
if y >= mcl_vars.mg_overworld_min then
|
||||
return y - mcl_vars.mg_overworld_min, "overworld"
|
||||
else
|
||||
return nil, "void"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Takes a Minecraft layer and a “dimension” name
|
||||
-- and returns the corresponding Y coordinate for
|
||||
-- MineClone 2.
|
||||
-- minecraft_dimension parameter is ignored at the moment
|
||||
-- TODO: Implement dimensions
|
||||
function mcl_util.layer_to_y(layer, minecraft_dimension)
|
||||
return layer + mcl_vars.mg_overworld_min
|
||||
end
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
mcl_init
|
|
@ -1 +0,0 @@
|
|||
Utility functions for worlds and the “dimensions”.
|
|
@ -1,140 +0,0 @@
|
|||
mcl_worlds = {}
|
||||
|
||||
-- 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
|
||||
function mcl_worlds.is_in_void(pos)
|
||||
local void =
|
||||
not ((pos.y < mcl_vars.mg_overworld_max and pos.y > mcl_vars.mg_overworld_min) or
|
||||
(pos.y < mcl_vars.mg_nether_max and pos.y > mcl_vars.mg_nether_min) or
|
||||
(pos.y < mcl_vars.mg_end_max and pos.y > mcl_vars.mg_end_min))
|
||||
|
||||
local void_deadly = false
|
||||
local deadly_tolerance = 64 -- the player must be this many nodes “deep” into the void to be damaged
|
||||
if void then
|
||||
-- Overworld → Void → End → Void → Nether → Void
|
||||
if pos.y < mcl_vars.mg_overworld_min and pos.y > mcl_vars.mg_end_max then
|
||||
void_deadly = pos.y < mcl_vars.mg_overworld_min - deadly_tolerance
|
||||
elseif pos.y < mcl_vars.mg_end_min and pos.y > mcl_vars.mg_nether_max then
|
||||
-- The void between End and Nether. Like usual, but here, the void
|
||||
-- *above* the Nether also has a small tolerance area, so player
|
||||
-- can fly above the Nether without getting hurt instantly.
|
||||
void_deadly = (pos.y < mcl_vars.mg_end_min - deadly_tolerance) and (pos.y > mcl_vars.mg_nether_max + deadly_tolerance)
|
||||
elseif pos.y < mcl_vars.mg_nether_min then
|
||||
void_deadly = pos.y < mcl_vars.mg_nether_min - deadly_tolerance
|
||||
end
|
||||
end
|
||||
return void, void_deadly
|
||||
end
|
||||
|
||||
-- Takes an Y coordinate as input and returns:
|
||||
-- 1) The corresponding Minecraft layer (can be nil if void)
|
||||
-- 2) The corresponding Minecraft dimension ("overworld", "nether" or "end") or "void" if it is in the void
|
||||
-- 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 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
|
||||
|
||||
-- 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)
|
||||
return dim
|
||||
end
|
||||
|
||||
-- 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
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
-- Takes a position (pos) and returns true if clocks are working here
|
||||
mcl_worlds.clock_works = mcl_worlds.compass_works
|
||||
|
||||
--------------- CALLBACKS ------------------
|
||||
mcl_worlds.registered_on_dimension_change = {}
|
||||
|
||||
-- Register a callback function func(player, dimension).
|
||||
-- It will be called whenever a player changes between dimensions.
|
||||
-- The void counts as dimension.
|
||||
-- * player: The player who changed the dimension
|
||||
-- * dimension: The new dimension of the player ("overworld", "nether", "end", "void").
|
||||
function mcl_worlds.register_on_dimension_change(func)
|
||||
table.insert(mcl_worlds.registered_on_dimension_change, func)
|
||||
end
|
||||
|
||||
-- Playername-indexed table containig the name of the last known dimension the
|
||||
-- player was in.
|
||||
local last_dimension = {}
|
||||
|
||||
-- Notifies this mod about a dimension change of a player.
|
||||
-- * player: Player who changed the dimension
|
||||
-- * dimension: New dimension ("overworld", "nether", "end", "void")
|
||||
function mcl_worlds.dimension_change(player, dimension)
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
----------------------- INTERNAL STUFF ----------------------
|
||||
|
||||
-- Update the dimension callbacks every DIM_UPDATE seconds
|
||||
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())
|
||||
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 name = players[p]:get_player_name()
|
||||
if dim ~= last_dimension[name] then
|
||||
mcl_worlds.dimension_change(players[p], dim)
|
||||
end
|
||||
end
|
||||
dimtimer = 0
|
||||
end
|
||||
end)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
name = CORE
|
||||
description = Meta-modpack containing the core mods for MineClone 2 for core APIs, variables and definitions
|
|
@ -1,11 +1,11 @@
|
|||
Walkover
|
||||
WalkOver
|
||||
--------
|
||||
|
||||
Some mode developers have shown an interest in having an `on_walk_over` event. This is useful for pressure-plates and the like.
|
||||
Some mode developers have shown an interest in having an on_walk_over event. This is useful for pressure-plates and the like.
|
||||
|
||||
See this issue - https://github.com/minetest/minetest/issues/247
|
||||
|
||||
I have implemented a server-side version in Lua using globalstep which people might find useful. Of course this would better implemented via a client-based "on walk over", but it is sufficient for my needs now.
|
||||
I have implemented a server_side version in lua using globalstep which people might find useful. Of course this would better implemented via a client-based "on walk over", but it is sufficient for my needs now.
|
||||
|
||||
Example Usage
|
||||
-------------
|
||||
|
@ -19,6 +19,3 @@ Example Usage
|
|||
})
|
||||
|
||||
|
||||
Credits
|
||||
-------
|
||||
Mod created by lordfingle, licensed under Apache License 2.0.
|
||||
|
|
|
@ -4,9 +4,7 @@ minetest.register_globalstep(function(dtime)
|
|||
timer = timer + dtime;
|
||||
if timer >= 0.3 then
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
local pp = player:get_pos()
|
||||
pp.y = math.ceil(pp.y)
|
||||
local loc = vector.add(pp, {x=0,y=-1,z=0})
|
||||
local loc = vector.add(player:getpos(),{x=0,y=-1,z=0})
|
||||
if loc ~= nil then
|
||||
|
||||
local nodeiamon = minetest.get_node(loc)
|
||||
|
|
|
@ -7,39 +7,36 @@
|
|||
|
||||
--water
|
||||
|
||||
local water_tex = "default_water_source_animated.png^[verticalframe:16:0"
|
||||
minetest.register_entity("drippingwater:drop_water", {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025},
|
||||
pointable = false,
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
visual = "cube",
|
||||
visual_size = {x=0.05, y=0.1},
|
||||
textures = {water_tex, water_tex, water_tex, water_tex, water_tex, water_tex},
|
||||
textures = {"default_water.png","default_water.png","default_water.png","default_water.png", "default_water.png", "default_water.png"},
|
||||
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)
|
||||
self.object:setsprite({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()
|
||||
local ownpos = self.object:getpos()
|
||||
|
||||
if k==1 then
|
||||
self.object:set_acceleration({x=0, y=-5, z=0})
|
||||
self.object:setacceleration({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})
|
||||
self.object:setacceleration({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)
|
||||
minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@ -47,41 +44,37 @@ minetest.register_entity("drippingwater:drop_water", {
|
|||
|
||||
--lava
|
||||
|
||||
local lava_tex = "default_lava_source_animated.png^[verticalframe:16:0"
|
||||
minetest.register_entity("drippingwater:drop_lava", {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025},
|
||||
glow = math.max(7, minetest.registered_nodes["mcl_core:lava_source"].light_source - 3),
|
||||
pointable = false,
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
visual = "cube",
|
||||
visual_size = {x=0.05, y=0.1},
|
||||
textures = {lava_tex, lava_tex, lava_tex, lava_tex, lava_tex, lava_tex},
|
||||
textures = {"default_lava.png","default_lava.png","default_lava.png","default_lava.png", "default_lava.png", "default_lava.png"},
|
||||
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)
|
||||
self.object:setsprite({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()
|
||||
local ownpos = self.object:getpos()
|
||||
|
||||
if k==1 then
|
||||
self.object:set_acceleration({x=0, y=-5, z=0})
|
||||
self.object:setacceleration({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})
|
||||
self.object:setacceleration({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)
|
||||
minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@ -91,17 +84,15 @@ minetest.register_entity("drippingwater:drop_lava", {
|
|||
--Create drop
|
||||
|
||||
minetest.register_abm(
|
||||
{
|
||||
label = "Create water drops",
|
||||
nodenames = {"group:opaque", "group:leaves"},
|
||||
{nodenames = {"group:solid"},
|
||||
neighbors = {"group:water"},
|
||||
interval = 2,
|
||||
chance = 22,
|
||||
action = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0 and
|
||||
minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
||||
local i = math.random(-45,45) / 100
|
||||
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water")
|
||||
if minetest.get_node({x=pos.x, y=pos.y -1, z=pos.z}).name == "air" and
|
||||
minetest.get_node({x=pos.x, y=pos.y -2, 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,
|
||||
})
|
||||
|
@ -109,17 +100,15 @@ minetest.register_abm(
|
|||
--Create lava drop
|
||||
|
||||
minetest.register_abm(
|
||||
{
|
||||
label = "Create lava drops",
|
||||
nodenames = {"group:opaque"},
|
||||
{nodenames = {"group:solid"},
|
||||
neighbors = {"group:lava"},
|
||||
interval = 2,
|
||||
chance = 22,
|
||||
action = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0 and
|
||||
minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
||||
local i = math.random(-45,45) / 100
|
||||
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava")
|
||||
if minetest.get_node({x=pos.x, y=pos.y -1, z=pos.z}).name == "air" and
|
||||
minetest.get_node({x=pos.x, y=pos.y -2, 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,
|
||||
})
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# mcl_boats
|
||||
This mod adds drivable boats.
|
||||
|
||||
# Credits
|
||||
## Mesh
|
||||
Boat mesh (`models/mcl_boats_boat.b3d`) created by 22i.
|
||||
Source: https://github.com/22i/minecraft-voxel-blender-models
|
||||
|
||||
License of boat model:
|
||||
GNU GPLv3 <https://www.gnu.org/licenses/gpl-3.0.html>
|
||||
|
||||
## Textures
|
||||
See the main MineClone 2 README.md file to learn more.
|
||||
|
||||
## Code
|
||||
Code based on Minetest Game, licensed under the MIT License (MIT).
|
||||
|
||||
Authors include:
|
||||
* PilzAdam (2012-2016)
|
||||
* Various Minetest / Minetest Game developers and contributors (2012-2016)
|
||||
* maikerumine (2017)
|
||||
* Wuzzy (2017)
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
mcl_player
|
||||
mcl_core?
|
||||
doc_identifier?
|
|
@ -1 +0,0 @@
|
|||
Adds drivable boats.
|
|
@ -1,366 +0,0 @@
|
|||
local S = minetest.get_translator("mcl_boats")
|
||||
--
|
||||
-- Helper functions
|
||||
--
|
||||
|
||||
local function is_water(pos)
|
||||
local nn = minetest.get_node(pos).name
|
||||
return minetest.get_item_group(nn, "water") ~= 0
|
||||
end
|
||||
|
||||
|
||||
local function get_sign(i)
|
||||
if i == 0 then
|
||||
return 0
|
||||
else
|
||||
return i / math.abs(i)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
local function get_v(v)
|
||||
return math.sqrt(v.x ^ 2 + v.z ^ 2)
|
||||
end
|
||||
|
||||
local boat_visual_size = {x = 3, y = 3}
|
||||
-- Note: This mod assumes the default player visual_size is {x=1, y=1}
|
||||
local driver_visual_size = { x = 1/boat_visual_size.x, y = 1/boat_visual_size.y }
|
||||
local paddling_speed = 22
|
||||
local boat_y_offset = 0.35
|
||||
local boat_y_offset_ground = boat_y_offset + 0.6
|
||||
local boat_side_offset = 1.001
|
||||
|
||||
--
|
||||
-- Boat entity
|
||||
--
|
||||
|
||||
local boat = {
|
||||
physical = true,
|
||||
-- Warning: Do not change the position of the collisionbox top surface,
|
||||
-- lowering it causes the boat to fall through the world if underwater
|
||||
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
|
||||
visual = "mesh",
|
||||
mesh = "mcl_boats_boat.b3d",
|
||||
textures = {"mcl_boats_texture_oak_boat.png"},
|
||||
visual_size = boat_visual_size,
|
||||
|
||||
_driver = nil, -- Attached driver (player) or nil if none
|
||||
_v = 0, -- Speed
|
||||
_last_v = 0, -- Temporary speed variable
|
||||
_removed = false, -- If true, boat entity is considered removed (e.g. after punch) and should be ignored
|
||||
_itemstring = "mcl_boats:boat", -- Itemstring of the boat item (implies boat type)
|
||||
_animation = 0, -- 0: not animated; 1: paddling forwards; -1: paddling forwards
|
||||
}
|
||||
|
||||
function boat.on_rightclick(self, clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
local name = clicker:get_player_name()
|
||||
if self._driver and clicker == self._driver then
|
||||
self._driver = nil
|
||||
clicker:set_detach()
|
||||
clicker:set_properties({visual_size = {x=1, y=1}})
|
||||
mcl_player.player_attached[name] = false
|
||||
mcl_player.player_set_animation(clicker, "stand" , 30)
|
||||
local pos = clicker:get_pos()
|
||||
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
|
||||
clicker:set_pos(pos)
|
||||
elseif not self._driver then
|
||||
local attach = clicker:get_attach()
|
||||
if attach and attach:get_luaentity() then
|
||||
local luaentity = attach:get_luaentity()
|
||||
if luaentity._driver then
|
||||
luaentity._driver = nil
|
||||
end
|
||||
clicker:set_detach()
|
||||
clicker:set_properties({visual_size = {x=1, y=1}})
|
||||
end
|
||||
self._driver = clicker
|
||||
clicker:set_attach(self.object, "",
|
||||
{x = 0, y = 0.42, z = -1}, {x = 0, y = 0, z = 0})
|
||||
clicker:set_properties({ visual_size = driver_visual_size })
|
||||
mcl_player.player_attached[name] = true
|
||||
minetest.after(0.2, function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
mcl_player.player_set_animation(player, "sit" , 30)
|
||||
end
|
||||
end, name)
|
||||
clicker:set_look_horizontal(self.object:get_yaw())
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function boat.on_activate(self, staticdata, dtime_s)
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if type(data) == "table" then
|
||||
self._v = data.v
|
||||
self._last_v = self._v
|
||||
self._itemstring = data.itemstring
|
||||
self.object:set_properties({textures=data.textures})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function boat.get_staticdata(self)
|
||||
return minetest.serialize({
|
||||
v = self._v,
|
||||
itemstring = self._itemstring,
|
||||
textures = self.object:get_properties().textures
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
function boat.on_punch(self, puncher)
|
||||
if not puncher or not puncher:is_player() or self._removed then
|
||||
return
|
||||
end
|
||||
if self._driver and puncher == self._driver then
|
||||
self._driver = nil
|
||||
puncher:set_detach()
|
||||
puncher:set_properties({visual_size = {x=1, y=1}})
|
||||
mcl_player.player_attached[puncher:get_player_name()] = false
|
||||
end
|
||||
if not self._driver then
|
||||
self._removed = true
|
||||
-- Drop boat as item on the ground after punching
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
minetest.add_item(self.object:get_pos(), self._itemstring)
|
||||
else
|
||||
local inv = puncher:get_inventory()
|
||||
if not inv:contains_item("main", self._itemstring) then
|
||||
inv:add_item("main", self._itemstring)
|
||||
end
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
|
||||
function boat.on_step(self, dtime)
|
||||
self._v = get_v(self.object:get_velocity()) * get_sign(self._v)
|
||||
local on_water = true
|
||||
local in_water = false
|
||||
local v_factor = 1
|
||||
local v_slowdown = 0.02
|
||||
local p = self.object:get_pos()
|
||||
if (not is_water({x=p.x, y=p.y-boat_y_offset, z=p.z})) then
|
||||
on_water = false
|
||||
v_factor = 0.5
|
||||
v_slowdown = 0.04
|
||||
elseif (is_water({x=p.x, y=p.y-boat_y_offset+1, z=p.z})) then
|
||||
on_water = false
|
||||
in_water = true
|
||||
v_factor = 0.75
|
||||
v_slowdown = 0.05
|
||||
end
|
||||
|
||||
if self._driver then
|
||||
local ctrl = self._driver:get_player_control()
|
||||
local yaw = self.object:get_yaw()
|
||||
if ctrl.up then
|
||||
-- Forwards
|
||||
self._v = self._v + 0.1 * v_factor
|
||||
|
||||
-- Paddling animation
|
||||
if self._animation ~= 1 then
|
||||
self.object:set_animation({x=0, y=40}, paddling_speed, 0, true)
|
||||
self._animation = 1
|
||||
end
|
||||
elseif ctrl.down then
|
||||
-- Backwards
|
||||
self._v = self._v - 0.1 * v_factor
|
||||
|
||||
-- Paddling animation, reversed
|
||||
if self._animation ~= -1 then
|
||||
self.object:set_animation({x=0, y=40}, -paddling_speed, 0, true)
|
||||
self._animation = -1
|
||||
end
|
||||
else
|
||||
-- Stop paddling animation if no control pressed
|
||||
if self._animation ~= 0 then
|
||||
self.object:set_animation({x=0, y=40}, 0, 0, true)
|
||||
self._animation = 0
|
||||
end
|
||||
end
|
||||
if ctrl.left then
|
||||
if self._v < 0 then
|
||||
self.object:set_yaw(yaw - (1 + dtime) * 0.03 * v_factor)
|
||||
else
|
||||
self.object:set_yaw(yaw + (1 + dtime) * 0.03 * v_factor)
|
||||
end
|
||||
elseif ctrl.right then
|
||||
if self._v < 0 then
|
||||
self.object:set_yaw(yaw + (1 + dtime) * 0.03 * v_factor)
|
||||
else
|
||||
self.object:set_yaw(yaw - (1 + dtime) * 0.03 * v_factor)
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Stop paddling without driver
|
||||
if self._animation ~= 0 then
|
||||
self.object:set_animation({x=0, y=40}, 0, 0, true)
|
||||
self._animation = 0
|
||||
end
|
||||
end
|
||||
local s = get_sign(self._v)
|
||||
if not on_water and not in_water and math.abs(self._v) > 1.0 then
|
||||
v_slowdown = math.min(math.abs(self._v) - 1.0, v_slowdown * 5)
|
||||
elseif in_water and math.abs(self._v) > 1.5 then
|
||||
v_slowdown = math.min(math.abs(self._v) - 1.5, v_slowdown * 5)
|
||||
end
|
||||
self._v = self._v - v_slowdown * s
|
||||
if s ~= get_sign(self._v) then
|
||||
self._v = 0
|
||||
end
|
||||
|
||||
p.y = p.y - boat_y_offset
|
||||
local new_velo
|
||||
local new_acce = {x = 0, y = 0, z = 0}
|
||||
if not is_water(p) then
|
||||
-- Not on water or inside water: Free fall
|
||||
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)
|
||||
else
|
||||
p.y = p.y + 1
|
||||
if is_water(p) then
|
||||
-- Inside water: Slowly sink
|
||||
local y = self.object:get_velocity().y
|
||||
y = y - 0.01
|
||||
if y < -0.2 then
|
||||
y = -0.2
|
||||
end
|
||||
new_acce = {x = 0, y = 0, z = 0}
|
||||
new_velo = get_velocity(self._v, self.object:get_yaw(), y)
|
||||
else
|
||||
-- On top of water
|
||||
new_acce = {x = 0, y = 0, z = 0}
|
||||
if math.abs(self.object:get_velocity().y) < 0 then
|
||||
new_velo = get_velocity(self._v, self.object:get_yaw(), 0)
|
||||
else
|
||||
new_velo = get_velocity(self._v, self.object:get_yaw(),
|
||||
self.object:get_velocity().y)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Terminal velocity: 8 m/s per axis of travel
|
||||
for _,axis in pairs({"z","y","x"}) do
|
||||
if math.abs(new_velo[axis]) > 8 then
|
||||
new_velo[axis] = 8 * get_sign(new_velo[axis])
|
||||
end
|
||||
end
|
||||
|
||||
self.object:set_velocity(new_velo)
|
||||
self.object:set_acceleration(new_acce)
|
||||
end
|
||||
|
||||
-- Register one entity for all boat types
|
||||
minetest.register_entity("mcl_boats:boat", boat)
|
||||
|
||||
local boat_ids = { "boat", "boat_spruce", "boat_birch", "boat_jungle", "boat_acacia", "boat_dark_oak" }
|
||||
local names = { S("Oak Boat"), S("Spruce Boat"), S("Birch Boat"), S("Jungle Boat"), S("Acacia Boat"), S("Dark Oak Boat") }
|
||||
local craftstuffs = {}
|
||||
if minetest.get_modpath("mcl_core") then
|
||||
craftstuffs = { "mcl_core:wood", "mcl_core:sprucewood", "mcl_core:birchwood", "mcl_core:junglewood", "mcl_core:acaciawood", "mcl_core:darkwood" }
|
||||
end
|
||||
local images = { "oak", "spruce", "birch", "jungle", "acacia", "dark_oak" }
|
||||
|
||||
for b=1, #boat_ids do
|
||||
local itemstring = "mcl_boats:"..boat_ids[b]
|
||||
|
||||
local longdesc, usagehelp, tt_help, help, helpname
|
||||
help = false
|
||||
-- Only create one help entry for all boats
|
||||
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.")
|
||||
helpname = S("Boat")
|
||||
end
|
||||
tt_help = S("Water vehicle")
|
||||
|
||||
minetest.register_craftitem(itemstring, {
|
||||
description = names[b],
|
||||
_tt_help = tt_help,
|
||||
_doc_items_create_entry = help,
|
||||
_doc_items_entry_name = helpname,
|
||||
_doc_items_longdesc = longdesc,
|
||||
_doc_items_usagehelp = usagehelp,
|
||||
inventory_image = "mcl_boats_"..images[b].."_boat.png",
|
||||
liquids_pointable = true,
|
||||
groups = { boat = 1, transport = 1},
|
||||
stack_max = 1,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Call on_rightclick if the pointed node defines it
|
||||
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 pos = table.copy(pointed_thing.under)
|
||||
local dir = vector.subtract(pointed_thing.above, pointed_thing.under)
|
||||
|
||||
if math.abs(dir.x) > 0.9 or math.abs(dir.z) > 0.9 then
|
||||
pos = vector.add(pos, vector.multiply(dir, boat_side_offset))
|
||||
elseif is_water(pos) then
|
||||
pos = vector.add(pos, vector.multiply(dir, boat_y_offset))
|
||||
else
|
||||
pos = vector.add(pos, vector.multiply(dir, boat_y_offset_ground))
|
||||
end
|
||||
local boat = minetest.add_entity(pos, "mcl_boats:boat")
|
||||
boat:get_luaentity()._itemstring = itemstring
|
||||
boat:set_properties({textures = { "mcl_boats_texture_"..images[b].."_boat.png" }})
|
||||
boat:set_yaw(placer:get_look_horizontal())
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
_on_dispense = function(stack, pos, droppos, dropnode, dropdir)
|
||||
local below = {x=droppos.x, y=droppos.y-1, z=droppos.z}
|
||||
local belownode = minetest.get_node(below)
|
||||
-- Place boat as entity on or in water
|
||||
if minetest.get_item_group(dropnode.name, "water") ~= 0 or (dropnode.name == "air" and minetest.get_item_group(belownode.name, "water") ~= 0) then
|
||||
minetest.add_entity(droppos, "mcl_boats:boat")
|
||||
else
|
||||
minetest.add_item(droppos, stack)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local c = craftstuffs[b]
|
||||
minetest.register_craft({
|
||||
output = itemstring,
|
||||
recipe = {
|
||||
{c, "", c},
|
||||
{c, c, c},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "group:boat",
|
||||
burntime = 20,
|
||||
})
|
||||
|
||||
if minetest.get_modpath("doc_identifier") ~= nil then
|
||||
doc.sub.identifier.register_object("mcl_boats:boat", "craftitems", "mcl_boats:boat")
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
# textdomain: mcl_boats
|
||||
Acacia Boat=Akazienboot
|
||||
Birch Boat=Birkenboot
|
||||
Boat=Boot
|
||||
Boats are used to travel on the surface of water.=Boote werden benutzt, um sich auf der Wasseroberfläche zu bewegen.
|
||||
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.
|
||||
Spruce Boat=Fichtenboot
|
||||
Water vehicle=Wasserfahrzeug
|