Compare commits
1 Commits
master
...
portal_par
Author | SHA1 | Date |
---|---|---|
Wuzzy | cb084568ef |
97
API.md
|
@ -1,89 +1,36 @@
|
||||||
# API
|
# API
|
||||||
## Groups
|
## 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`.
|
Groups are explained in `GROUPS.md`.
|
||||||
|
|
||||||
## Mod naming convention
|
## APIs for adding simple things
|
||||||
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.
|
You can add simple things by calling functions in the various MineClone 2 mods.
|
||||||
|
|
||||||
## Adding items
|
* Fences and fence gates: See `mods/ITEMS/mcl_fences/API.md`.
|
||||||
### Special fields
|
* Walls: See `mods/ITEMS/mcl_walls/API.md`
|
||||||
|
|
||||||
Items can have these fields:
|
### Undocumented APIs
|
||||||
* `_mcl_generate_description(itemstack)`: Required for any items which manipulate their
|
You can also add stuff for the following thins, but the APIs are currently undocumented. These mods are very similar to Minetest Game.
|
||||||
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.
|
|
||||||
|
|
||||||
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
|
WARNING! These 5 mods may be renamed or changed in future releases, and compability could be broken.
|
||||||
* `_mcl_blast_resistance`: How well this block blocks and resists explosions. Default: 0
|
|
||||||
* `_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`
|
|
||||||
|
|
||||||
## Mobs
|
## Mobs
|
||||||
* Mobs: `ENTITIES/mcl_mods`
|
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.
|
||||||
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.
|
|
||||||
|
|
||||||
You can add your own mobs, spawn eggs and spawning rules with this mod.
|
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.
|
Note that mobs in MineClone 2 are still very experimental, everything about mobs may change radically at any time!
|
||||||
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.
|
|
||||||
|
|
||||||
### Help
|
## Other APIs
|
||||||
* Item help texts: `HELP/doc/doc_items`
|
* Statbars / HUD bars: See `mods/HUD/hudbars`
|
||||||
* Low-level help entry and category framework: `HELP/doc/doc`
|
* Hunger: See `mods/PLAYER/mcl_hunger/API.md`
|
||||||
* Support for lookup tool (required for all entities): `HELP/doc/doc_identifier`
|
|
||||||
|
|
||||||
### HUD
|
## Other things of interest
|
||||||
* Statbars: `HUD/hudbars`
|
Mods found in `mods/CORE` contain important core APIs and utility functions, used throughout the subgame.
|
||||||
|
|
||||||
### 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
|
|
||||||
|
|
|
@ -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.
|
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
|
you agree that they fall under the terms of the LGPLv2.1, which basically
|
||||||
means they will become part of a free software.
|
means they will become part of a free software.
|
||||||
|
|
||||||
|
@ -70,4 +70,4 @@ Depending on what you add, the chances for inclusion vary:
|
||||||
## Reporting bugs
|
## Reporting bugs
|
||||||
Report all bugs and missing Minecraft features here:
|
Report all bugs and missing Minecraft features here:
|
||||||
|
|
||||||
<https://git.minetest.land/Wuzzy/MineClone2-Bugs>
|
<https://github.com/Wuzzy2/MineClone2-Bugs>
|
||||||
|
|
33
GROUPS.md
|
@ -1,5 +1,5 @@
|
||||||
## Groups
|
## Groups
|
||||||
This document explains all the groups used in this game.
|
This document explains all the groups used in this subgame.
|
||||||
|
|
||||||
### Special groups
|
### Special groups
|
||||||
|
|
||||||
|
@ -29,8 +29,6 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
||||||
|
|
||||||
### Groups for interactions
|
### 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
|
* `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
|
* `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
|
* `dig_by_piston=1`: Blocks which will drop as an item when pushed by a piston. They also cannot be pulled by sticky pistons
|
||||||
|
@ -38,8 +36,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
||||||
* `cultivatable=1`: Block will be turned into Dirt by using a hoe on it
|
* `cultivatable=1`: Block will be turned into Dirt by using a hoe on it
|
||||||
* `flammable`: Block helps spreading fire and gets destroyed by nearby fire (rating doesn't matter)
|
* `flammable`: Block helps spreading fire and gets destroyed by nearby fire (rating doesn't matter)
|
||||||
* `spreading_dirt_type=1`: A dirt-type block with a cover (e.g. grass) which may spread to neighbor dirt blocks
|
* `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
|
* `dirtifies_below_solid=1`: This node turns into dirt immediately when a solid 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
|
* `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
|
||||||
* `soil=1`: Saplings and other small plants can grow on it
|
* `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=2`: Soil for saplings. Intended to be natural soil. All saplings will grow on this
|
||||||
|
@ -51,11 +48,6 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
||||||
* `destroys_items=1`: If an item happens to be *inside* this node, the item will be destroyed
|
* `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.
|
* `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
|
* `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.
|
|
||||||
|
|
||||||
#### Footnotes
|
#### Footnotes
|
||||||
|
|
||||||
|
@ -79,7 +71,6 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
||||||
* `wool=1`: Wool (only full blocks)
|
* `wool=1`: Wool (only full blocks)
|
||||||
* `carpet=1:` (Wool) carpet
|
* `carpet=1:` (Wool) carpet
|
||||||
* `stick=1`: Stick
|
* `stick=1`: Stick
|
||||||
* `water_bucket=1`: Bucket containing a liquid of group “water”
|
|
||||||
|
|
||||||
### Material groups
|
### Material groups
|
||||||
|
|
||||||
|
@ -98,12 +89,10 @@ These groups are used mostly for informational purposes
|
||||||
|
|
||||||
* `solid=1`: Solid full-cube block (automatically assigned)
|
* `solid=1`: Solid full-cube block (automatically assigned)
|
||||||
* `opaque=1`: Opaque 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_solid=1`: Block is sold (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
|
* `fire=1`: Fire
|
||||||
* `water=1`: Water
|
* `water=1`: Water
|
||||||
* `lava=1`: Lava
|
* `lava=1`: Lava
|
||||||
* `top_snow=X`: Top snow with X layers (1-8)
|
|
||||||
* `torch`: Torch or torch-like node
|
* `torch`: Torch or torch-like node
|
||||||
* `torch=1`: Torch on floor
|
* `torch=1`: Torch on floor
|
||||||
* `torch=2`: Torch at wall
|
* `torch=2`: Torch at wall
|
||||||
|
@ -120,7 +109,6 @@ These groups are used mostly for informational purposes
|
||||||
* `flower_pot=2`: Flower pot with a plant or flower
|
* `flower_pot=2`: Flower pot with a plant or flower
|
||||||
* `flower=1`: Flower
|
* `flower=1`: Flower
|
||||||
* `place_flowerlike=1`: Node has placement rules like that of a 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)
|
* `cake`: Cake (rating = slices left)
|
||||||
* `book=1`: Book
|
* `book=1`: Book
|
||||||
* `pane=1`: Node is a “pane”-like node glass pane or iron bars
|
* `pane=1`: Node is a “pane”-like node glass pane or iron bars
|
||||||
|
@ -152,27 +140,12 @@ These groups are used mostly for informational purposes
|
||||||
* `container=5`: Left part of a 2-part horizontal connected container. Both parts have a `"main"` inventory
|
* `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.
|
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=6`: Same as above, but for the right part.
|
||||||
* `container=7`: Has inventory list "`main`", no movement allowed
|
|
||||||
* `container=1`: Other/unspecified container type
|
* `container=1`: Other/unspecified container type
|
||||||
* `spawn_egg=1`: Spawn egg
|
* `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
|
* `plant=1`: Plant or part of a plant
|
||||||
* `double_plant`: Part of a double-sized plant. 1 = lower part, 2 = upper part
|
* `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
|
* `weapon=1`: Item is primarily (!) a weapon
|
||||||
* `tool=1`: Item is primarily (!) a tool
|
* `tool=1`: Item is primarily (!) a tool
|
||||||
* `craftitem=1`: Item is primarily (!) used for crafting
|
* `craftitem=1`: Item is primarily (!) used for crafting
|
||||||
|
|
81
README.md
|
@ -2,7 +2,7 @@
|
||||||
An unofficial Minecraft-like game for Minetest. Forked from MineClone by daredevils.
|
An unofficial Minecraft-like game for Minetest. Forked from MineClone by daredevils.
|
||||||
Developed by Wuzzy and contributors. Not developed or endorsed by Mojang AB.
|
Developed by Wuzzy and contributors. Not developed or endorsed by Mojang AB.
|
||||||
|
|
||||||
Version: 0.49.0
|
Version: 0.26.0
|
||||||
|
|
||||||
### Gameplay
|
### Gameplay
|
||||||
You start in a randomly-generated world made entirely of cubes. You can explore
|
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)
|
## How to play (quick start)
|
||||||
### Getting started
|
### Getting started
|
||||||
|
* **Use the world generator “v6”!**
|
||||||
* **Punch a tree** trunk until it breaks and collect wood
|
* **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 **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**
|
* Place the 4 wood planks in a 2×2 shape in the crafting grid to **make a crafting table**
|
||||||
|
@ -55,34 +56,25 @@ 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
|
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.
|
the game. You can access the help from your inventory menu.
|
||||||
|
|
||||||
### Special items
|
### Special blocks
|
||||||
The following items are interesting for Creative Mode and for adventure
|
The following blocks are interesting for Creative Mode and for adventure
|
||||||
map builders. They can not be obtained in-game or in the creative inventory.
|
map builders. They can not be obtained in-game or in the creative inventory.
|
||||||
|
|
||||||
* Barrier: `mcl_core:barrier`
|
* Barrier: `mcl_core:barrier`
|
||||||
|
* Command Block: `mesecons_commandblock:commandblock_off`
|
||||||
|
* Monster Spawner (WIP): `mcl_mobspawners:spawner`
|
||||||
|
* Huge mushroom blocks: See `mods/ITEMS/mcl_mushrooms/README.md`
|
||||||
|
|
||||||
Use the `/giveme` chat command to obtain them. See the in-game help for
|
Use the `/giveme` chat command to obtain them. See the in-game help for
|
||||||
an explanation.
|
an explanation.
|
||||||
|
|
||||||
#### Incomplete items
|
|
||||||
These items do not work yet, but you can get them with `/giveme` for testing:
|
|
||||||
|
|
||||||
* Fishing Rod: `mcl_fishing:fishing_rod`
|
|
||||||
* Activator Rail: `mcl_minecarts:activator_rail`
|
|
||||||
* 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
|
## Installation
|
||||||
This game requires [Minetest](http://minetest.net) to run (version 5.0.0 or
|
This game requires [Minetest](http://minetest.net) 0.4.16 (or later) to run,
|
||||||
later). So you need to install Minetest first. Only stable versions of Minetest
|
so you need to install Minetest first. Only stable versions of Minetest are
|
||||||
are officially supported.
|
officially supported. There is no support whatsoever for running MineClone 2
|
||||||
There is no support for running MineClone 2 in development versions of Minetest.
|
in development versions of Minetest.
|
||||||
|
To install MineClone 2, move this directory into the “games” directory of
|
||||||
To install MineClone 2 (if you haven't already), move this directory into the
|
your Minetest data directory. Consult the help of Minetest to learn more.
|
||||||
“games” directory of your Minetest data directory. Consult the help of
|
|
||||||
Minetest to learn more.
|
|
||||||
|
|
||||||
## Project description
|
## Project description
|
||||||
The main goal of **MineClone 2** is to be a clone of Minecraft and to be released as free software.
|
The main goal of **MineClone 2** is to be a clone of Minecraft and to be released as free software.
|
||||||
|
@ -97,26 +89,22 @@ The main goal of **MineClone 2** is to be a clone of Minecraft and to be release
|
||||||
|
|
||||||
## Completion status
|
## Completion status
|
||||||
This game is currently in **alpha** stage.
|
This game is currently in **alpha** stage.
|
||||||
It is playable, but unfinished, many bugs are to be expected.
|
It is playable, but very unfinished, many bugs are to be expected.
|
||||||
Backwards-compability is *not* guaranteed, updating your world might cause small and
|
Backwards-compability is *not* guaranteed, updating your world might cause small and
|
||||||
big bugs (such as “missing node” errors or even crashes).
|
big bugs (such as “missing node” errors or even crashes).
|
||||||
|
|
||||||
The following main features are available:
|
The following main features are available:
|
||||||
|
|
||||||
* Tools, weapons
|
* Tools, weapons and armor
|
||||||
* Armor (unbalanced)
|
|
||||||
* Crafting system: 2×2 grid, crafting table (3×3 grid), furnace, including a crafting guide
|
* Crafting system: 2×2 grid, crafting table (3×3 grid), furnace, including a crafting guide
|
||||||
* Chests, large chests, ender chests, shulker boxes
|
* Chests, large chests, ender chests, shulker boxes
|
||||||
* Furnaces, hoppers
|
|
||||||
* Hunger
|
* Hunger
|
||||||
* Most monsters and animals
|
* Most monsters and animals
|
||||||
* All ores from Minecraft
|
* All ores from Minecraft
|
||||||
* Most blocks in the overworld
|
* Most blocks in the overworld
|
||||||
* Water and lava
|
* Water and lava
|
||||||
* Weather
|
* Weather
|
||||||
* 28 biomes
|
* Redstone circuits (partially): Redstone ore, redstone, redstone repeater, levers, buttons, redstone blocks, redstone lamps
|
||||||
* The Nether, a fiery underworld in another dimension
|
|
||||||
* Redstone circuits (partially)
|
|
||||||
* Minecarts (partial)
|
* Minecarts (partial)
|
||||||
* Boats
|
* Boats
|
||||||
* Fire
|
* Fire
|
||||||
|
@ -135,22 +123,24 @@ The following main features are available:
|
||||||
* Inventory menu
|
* Inventory menu
|
||||||
* Creative inventory
|
* Creative inventory
|
||||||
* Farming
|
* Farming
|
||||||
|
* Bookshelves (deco only)
|
||||||
* Writable books
|
* Writable books
|
||||||
* A few server commands
|
* A few server commands
|
||||||
* And more!
|
* And more!
|
||||||
|
|
||||||
The following features are incomplete:
|
The following features are incomplete:
|
||||||
|
|
||||||
* Generated structures (especially villages)
|
* Trees, biomes, generated structures
|
||||||
* NPCs
|
* NPCs
|
||||||
* Some monsters and animals
|
* Some monsters and animals
|
||||||
* Redstone-related things
|
* Some redstone-related things
|
||||||
|
* The Nether
|
||||||
* The End
|
* The End
|
||||||
* Enchanting
|
* Enchanting
|
||||||
* Experience
|
* Experience
|
||||||
* Status effects
|
* Status effects
|
||||||
* Brewing, potions, tipped arrows
|
* Brewing, potions, tipped arrows
|
||||||
* Special minecarts
|
* Anvil
|
||||||
* A couple of non-trivial blocks and items
|
* A couple of non-trivial blocks and items
|
||||||
|
|
||||||
Bonus features (not found in Minecraft 1.11):
|
Bonus features (not found in Minecraft 1.11):
|
||||||
|
@ -158,33 +148,24 @@ Bonus features (not found in Minecraft 1.11):
|
||||||
* Built-in crafting guide which shows you crafting and smelting recipes
|
* 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
|
* 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
|
* 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
|
|
||||||
|
|
||||||
Technical differences from Minecraft:
|
Technical differences from Minecraft:
|
||||||
|
|
||||||
* Height limit of ca. 31000 blocks (much higher than in 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)
|
* Horizontal world size is ca. 62000×62000 blocks (much smaller than in Minecraft, but it is still very large)
|
||||||
* Still very incomplete and buggy
|
* Still very, very incomplete and buggy
|
||||||
* Blocks, items, enemies and other features are missing
|
* Blocks, items, enemies and other features are missing
|
||||||
* A few items have slightly different names to make them easier to distinguish
|
* A few items have slightly different names to make them easier to distinguish
|
||||||
* Different music for jukebox
|
* Different music for jukebox
|
||||||
* Different textures (Pixel Perfection)
|
* Different textures (Pixel Perfection)
|
||||||
* Different sounds (various sources)
|
* Different sounds (various sources)
|
||||||
* Different engine (Minetest)
|
* Different engine (Minetest)
|
||||||
|
* Free software (“free” as in freedom *and* free beer)
|
||||||
… and finally, MineClone 2 is free software (“free” as in “freedom”)!
|
|
||||||
|
|
||||||
## Reporting bugs
|
## Reporting bugs
|
||||||
Please report all bugs and missing Minecraft features here:
|
Please report all bugs and missing Minecraft features here:
|
||||||
|
|
||||||
<https://git.minetest.land/Wuzzy/MineClone2-Bugs>
|
<https://github.com/Wuzzy2/MineClone2-Bugs>
|
||||||
|
|
||||||
## Other readme files
|
## Other readme files
|
||||||
|
|
||||||
|
@ -199,7 +180,6 @@ There are so many people to list (sorry). Check out the respective mod directori
|
||||||
### Coding
|
### Coding
|
||||||
* [Wuzzy](https://forum.minetest.net/memberlist.php?mode=viewprofile&u=3082): Main programmer of most mods
|
* [Wuzzy](https://forum.minetest.net/memberlist.php?mode=viewprofile&u=3082): Main programmer of most mods
|
||||||
* daredevils: Creator of MineClone on which MineClone 2 is based on
|
* daredevils: Creator of MineClone on which MineClone 2 is based on
|
||||||
* [ex-bart](https://github.com/ex-bart): Redstone comparators
|
|
||||||
* Lots of other people: TO BE WRITTEN (see mod directories for details)
|
* Lots of other people: TO BE WRITTEN (see mod directories for details)
|
||||||
|
|
||||||
### Textures
|
### Textures
|
||||||
|
@ -227,7 +207,6 @@ Various sources. See the respective mod directories for details.
|
||||||
* Notch and Jeb for being the major forces behind Minecraft
|
* Notch and Jeb for being the major forces behind Minecraft
|
||||||
* XSSheep for creating the Pixel Perfection resource pack
|
* XSSheep for creating the Pixel Perfection resource pack
|
||||||
* [22i](https://github.com/22i) for providing great models and support
|
* [22i](https://github.com/22i) for providing great models and support
|
||||||
* [maikerumine](http://github.com/maikerumine) for kicking off mobs and biomes
|
|
||||||
|
|
||||||
## Info for programmers
|
## Info for programmers
|
||||||
You find interesting and useful infos in `API.md`.
|
You find interesting and useful infos in `API.md`.
|
||||||
|
@ -237,7 +216,7 @@ This project is currently mostly a one-person project.
|
||||||
This is a fan game, not developed or endorsed by Mojang AB.
|
This is a fan game, not developed or endorsed by Mojang AB.
|
||||||
|
|
||||||
Copying is an act of love. Please copy and share! <3
|
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
|
### License of source code
|
||||||
MineClone 2 is a clean-room implementation of Minecraft
|
MineClone 2 is a clean-room implementation of Minecraft
|
||||||
|
@ -256,14 +235,18 @@ No non-free licenses are used anywhere.
|
||||||
The textures, unless otherwise noted, are based on the Pixel Perfection resource pack for Minecraft 1.11,
|
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
|
authored by XSSheep. Most textures are verbatim copies, while some textures have been changed or redone
|
||||||
from scratch.
|
from scratch.
|
||||||
The glazed terracotta textures have been created by (MysticTempest)[https://github.com/MysticTempest].
|
|
||||||
Source: <https://www.planetminecraft.com/texture_pack/131pixel-perfection/>
|
Source: <https://www.planetminecraft.com/texture_pack/131pixel-perfection/>
|
||||||
License: [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)
|
License: [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)
|
||||||
|
|
||||||
The main menu images are release under: [CC0](https://creativecommons.org/publicdomain/zero/1.0/)
|
MineClone 2 is currently in the processs of changing all the textures.
|
||||||
|
The textures for the glazed terracotta come from Faithful Vanilla.
|
||||||
|
(authored by Vattic, xMrVizzy and many others).
|
||||||
|
Source: <https://minecraft.curseforge.com/projects/faithful-vanilla>
|
||||||
|
|
||||||
|
License of all main menu images: WTFPL
|
||||||
|
|
||||||
All other files, unless mentioned otherwise, fall under:
|
All other files, unless mentioned otherwise, fall under:
|
||||||
Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 4.0)
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 4.0)
|
||||||
http://creativecommons.org/licenses/by-sa/4.0/
|
http://creativecommons.org/licenses/by-sa/4.0/
|
||||||
|
|
||||||
See README.txt in each mod directory for detailed information about other authors.
|
See README.txt in each mod directory for detailed 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
|
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: 865 B |
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 206 KiB |
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 139 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 133 KiB |
|
@ -8,7 +8,7 @@ movement_acceleration_air = 1.2
|
||||||
|
|
||||||
movement_speed_walk = 4.317
|
movement_speed_walk = 4.317
|
||||||
movement_speed_crouch = 1.295
|
movement_speed_crouch = 1.295
|
||||||
movement_speed_fast = 25.0
|
movement_speed_fast = 10.89
|
||||||
|
|
||||||
movement_speed_jump = 6.6
|
movement_speed_jump = 6.6
|
||||||
movement_speed_climb = 2.35
|
movement_speed_climb = 2.35
|
||||||
|
@ -16,7 +16,7 @@ movement_speed_climb = 2.35
|
||||||
|
|
||||||
movement_liquid_fluidity = 1.13
|
movement_liquid_fluidity = 1.13
|
||||||
movement_liquid_fluidity_smooth = 0.5
|
movement_liquid_fluidity_smooth = 0.5
|
||||||
movement_liquid_sink = 23
|
movement_liquid_sink = 31
|
||||||
|
|
||||||
movement_gravity = 10.4
|
movement_gravity = 10.4
|
||||||
|
|
||||||
|
|
|
@ -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 +0,0 @@
|
||||||
name = _mcl_autogroup
|
|
|
@ -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
|
|
|
@ -1 +0,0 @@
|
||||||
Adds additional ways for nodes to be attached.
|
|
|
@ -1,24 +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)
|
|
||||||
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
|
|
||||||
|
|
||||||
return ret_o or ret
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
--[[ 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!
|
--[[ 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.
|
This mod does include a HACK to make 100% sure the digging times of all tools match Minecraft's perfectly.
|
||||||
|
@ -74,8 +82,7 @@ local overwrite = function()
|
||||||
groups_changed = true
|
groups_changed = true
|
||||||
end
|
end
|
||||||
-- Automatically assign the “opaque” group for opaque nodes
|
-- Automatically assign the “opaque” group for opaque nodes
|
||||||
if (not (ndef.paramtype == "light" or ndef.sunlight_propagates)) and
|
if not (ndef.paramtype == "light" or ndef.sunlight_propagates) then
|
||||||
(ndef.groups.not_opaque == 0 or ndef.groups.not_opaque == nil) then
|
|
||||||
newgroups.opaque = 1
|
newgroups.opaque = 1
|
||||||
groups_changed = true
|
groups_changed = true
|
||||||
end
|
end
|
|
@ -0,0 +1 @@
|
||||||
|
name = mcl_autogroup
|
|
@ -1,24 +1,17 @@
|
||||||
-- Some global variables (don't overwrite them!)
|
-- Some global variables (don't overwrite them!)
|
||||||
mcl_vars = {}
|
mcl_vars = {}
|
||||||
|
|
||||||
--- GUI / inventory menu settings
|
--- GUI / inventory menu colors
|
||||||
mcl_vars.gui_slots = "listcolors[#9990;#FFF7;#FFF0;#000;#FFF]"
|
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
|
|
||||||
|
|
||||||
-- Background stuff must be manually added by mods (no formspec prepend)
|
|
||||||
mcl_vars.gui_bg = "bgcolor[#080808BB;true]"
|
mcl_vars.gui_bg = "bgcolor[#080808BB;true]"
|
||||||
mcl_vars.gui_bg_img = ""
|
mcl_vars.gui_bg_img = ""
|
||||||
|
|
||||||
mcl_vars.inventory_header = mcl_vars.gui_bg
|
mcl_vars.inventory_header = mcl_vars.gui_slots .. mcl_vars.gui_bg
|
||||||
|
|
||||||
-- Mapgen variables
|
-- Mapgen variables
|
||||||
local mg_name = minetest.get_mapgen_setting("mg_name")
|
local mg_name = minetest.get_mapgen_setting("mg_name")
|
||||||
local minecraft_height_limit = 256
|
local minecraft_height_limit = 256
|
||||||
local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true"
|
if mg_name ~= "flat" then
|
||||||
|
|
||||||
if not superflat then
|
|
||||||
-- Normal mode
|
|
||||||
--[[ Realm stacking (h is for height)
|
--[[ Realm stacking (h is for height)
|
||||||
- Overworld (h>=256)
|
- Overworld (h>=256)
|
||||||
- Void (h>=1000)
|
- Void (h>=1000)
|
||||||
|
@ -39,57 +32,39 @@ if not superflat then
|
||||||
mcl_vars.mg_bedrock_is_rough = true
|
mcl_vars.mg_bedrock_is_rough = true
|
||||||
|
|
||||||
else
|
else
|
||||||
-- Classic superflat
|
|
||||||
local ground = minetest.get_mapgen_setting("mgflat_ground_level")
|
local ground = minetest.get_mapgen_setting("mgflat_ground_level")
|
||||||
ground = tonumber(ground)
|
ground = tonumber(ground)
|
||||||
if not ground then
|
if not ground then
|
||||||
ground = 8
|
ground = 8
|
||||||
end
|
end
|
||||||
mcl_vars.mg_overworld_min = ground - 3
|
-- 1 perfectly flat bedrock layer
|
||||||
|
if minetest.get_mapgen_setting("mcl_superflat_classic") == "false" then
|
||||||
|
mcl_vars.mg_overworld_min = -30912
|
||||||
|
else
|
||||||
|
mcl_vars.mg_overworld_min = ground - 3
|
||||||
|
end
|
||||||
mcl_vars.mg_overworld_max_official = mcl_vars.mg_overworld_min + minecraft_height_limit
|
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_min = mcl_vars.mg_overworld_min
|
||||||
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min
|
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min
|
||||||
mcl_vars.mg_lava = false
|
mcl_vars.mg_lava = false
|
||||||
mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min
|
|
||||||
mcl_vars.mg_bedrock_is_rough = false
|
mcl_vars.mg_bedrock_is_rough = false
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_vars.mg_overworld_max = 31000
|
mcl_vars.mg_overworld_max = 31000
|
||||||
|
|
||||||
-- The Nether (around Y = -29000)
|
-- The Nether
|
||||||
mcl_vars.mg_nether_min = -29067 -- Carefully chosen to be at a mapchunk border
|
mcl_vars.mg_nether_min = -29000
|
||||||
mcl_vars.mg_nether_max = mcl_vars.mg_nether_min + 128
|
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_bottom_min = mcl_vars.mg_nether_min
|
||||||
|
mcl_vars.mg_bedrock_nether_bottom_max = mcl_vars.mg_bedrock_nether_bottom_min + 4
|
||||||
mcl_vars.mg_bedrock_nether_top_max = mcl_vars.mg_nether_max
|
mcl_vars.mg_bedrock_nether_top_max = mcl_vars.mg_nether_max
|
||||||
if not superflat then
|
mcl_vars.mg_bedrock_nether_top_min = mcl_vars.mg_bedrock_nether_top_max - 4
|
||||||
mcl_vars.mg_bedrock_nether_bottom_max = mcl_vars.mg_bedrock_nether_bottom_min + 4
|
mcl_vars.mg_lava_nether_max = mcl_vars.mg_nether_min + 31
|
||||||
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
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- The End (surface at ca. Y = -27000)
|
-- The End
|
||||||
mcl_vars.mg_end_min = -27073 -- Carefully chosen to be at a mapchunk border
|
mcl_vars.mg_end_min = mcl_vars.mg_nether_max + 2000
|
||||||
mcl_vars.mg_end_max_official = mcl_vars.mg_end_min + minecraft_height_limit
|
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_max = mcl_vars.mg_overworld_min - 2000
|
||||||
mcl_vars.mg_end_platform_pos = { x = 100, y = mcl_vars.mg_end_min + 80, 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
|
-- Set default stack sizes
|
||||||
minetest.nodedef_default.stack_max = 64
|
minetest.nodedef_default.stack_max = 64
|
||||||
|
|
|
@ -98,54 +98,3 @@ function mcl_loot.get_multi_loot(multi_loot_definitions, pr)
|
||||||
end
|
end
|
||||||
return items
|
return items
|
||||||
end
|
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
|
|
||||||
|
|
Before Width: | Height: | Size: 101 B |
|
@ -67,21 +67,14 @@ blukotek (CC0 1.0)
|
||||||
https://www.freesound.org/people/blukotek/sounds/251660/
|
https://www.freesound.org/people/blukotek/sounds/251660/
|
||||||
default_dig_snappy.ogg
|
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)
|
Voxelands project <http://www.voxelands.com/> (CC BY-SA 3.0)
|
||||||
mcl_sounds_place_node_water.ogg
|
mcl_sounds_place_node_water.ogg
|
||||||
mcl_sounds_dug_water.ogg
|
mcl_sounds_dug_water.ogg
|
||||||
|
player_damage.ogg
|
||||||
|
|
||||||
(Note: Artists from the Voxelands project include: sdzen, darkrose, sapier,
|
(Note: Artists from the Voxelands project include: sdzen, darkrose, sapier,
|
||||||
Tom Peter, Telaron, juskiddink)
|
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):
|
Adam_N (CC0 1.0):
|
||||||
player_falling_damage.ogg
|
player_falling_damage.ogg
|
||||||
Source: <https://www.freesound.org/people/Adam_N/sounds/346692/>
|
Source: <https://www.freesound.org/people/Adam_N/sounds/346692/>
|
||||||
|
|
|
@ -134,21 +134,3 @@ function mcl_sounds.node_sound_water_defaults(table)
|
||||||
mcl_sounds.node_sound_defaults(table)
|
mcl_sounds.node_sound_defaults(table)
|
||||||
return table
|
return table
|
||||||
end
|
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})
|
|
||||||
end)
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ function mcl_util.get_eligible_transfer_item_slot(src_inventory, src_list, dst_i
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns true if itemstack is a shulker box
|
-- Returns true if given itemstack is a shulker box
|
||||||
local is_not_shulker_box = function(itemstack)
|
local is_not_shulker_box = function(itemstack)
|
||||||
local g = minetest.get_item_group(itemstack:get_name(), "shulker_box")
|
local g = minetest.get_item_group(itemstack:get_name(), "shulker_box")
|
||||||
return g == 0 or g == nil
|
return g == 0 or g == nil
|
||||||
|
@ -205,11 +205,6 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list,
|
||||||
local dctype = minetest.get_item_group(dnode.name, "container")
|
local dctype = minetest.get_item_group(dnode.name, "container")
|
||||||
local sctype = minetest.get_item_group(snode.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
|
-- Normalize double container by forcing to always use the left segment first
|
||||||
local normalize_double_container = function(pos, node, ctype)
|
local normalize_double_container = function(pos, node, ctype)
|
||||||
if ctype == 6 then
|
if ctype == 6 then
|
||||||
|
@ -240,7 +235,7 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list,
|
||||||
-- Default source lists
|
-- Default source lists
|
||||||
if not source_list then
|
if not source_list then
|
||||||
-- Main inventory for most container types
|
-- Main inventory for most container types
|
||||||
if sctype == 2 or sctype == 3 or sctype == 5 or sctype == 6 or sctype == 7 then
|
if sctype == 2 or sctype == 3 or sctype == 5 or sctype == 6 then
|
||||||
source_list = "main"
|
source_list = "main"
|
||||||
-- Furnace: output
|
-- Furnace: output
|
||||||
elseif sctype == 4 then
|
elseif sctype == 4 then
|
||||||
|
@ -286,17 +281,13 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list,
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
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 it's a container, put it into the container
|
||||||
if dctype ~= 0 then
|
if dctype ~= 0 then
|
||||||
-- Automatically select a destination list if omitted
|
-- Automatically select a destination list if omitted
|
||||||
if not destination_list then
|
if not destination_list then
|
||||||
-- Main inventory for most container types
|
-- Main inventory for most container types
|
||||||
if dctype == 2 or dctype == 3 or dctype == 5 or dctype == 6 or dctype == 7 then
|
if dctype == 2 or dctype == 3 or dctype == 5 or dctype == 6 then
|
||||||
destination_list = "main"
|
destination_list = "main"
|
||||||
-- Furnace source slot
|
-- Furnace source slot
|
||||||
elseif dctype == 4 then
|
elseif dctype == 4 then
|
||||||
|
@ -340,13 +331,68 @@ function mcl_util.is_fuel(item)
|
||||||
return minetest.get_craft_result({method="fuel", width=1, items={item}}).time ~= 0
|
return minetest.get_craft_result({method="fuel", width=1, items={item}}).time ~= 0
|
||||||
end
|
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 =
|
||||||
|
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
|
||||||
|
void_deadly = pos.y < mcl_vars.mg_end_min - 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
|
||||||
|
|
||||||
|
-- Here come 2 simple converter functions which are important for map generators and mob spawning
|
||||||
|
|
||||||
|
-- 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"
|
||||||
|
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 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_util.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
|
||||||
|
|
||||||
-- Returns a on_place function for plants
|
-- Returns a on_place function for plants
|
||||||
-- * condition: function(pos, node, itemstack)
|
-- * condition: function(pos, node)
|
||||||
-- * A function which is called by the on_place function to check if the node can be placed
|
-- * 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.
|
-- * 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
|
-- * pos, node: Position and node table of plant node
|
||||||
-- * itemstack: Itemstack to place
|
|
||||||
function mcl_util.generate_on_place_plant_function(condition)
|
function mcl_util.generate_on_place_plant_function(condition)
|
||||||
return function(itemstack, placer, pointed_thing)
|
return function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
|
@ -377,10 +423,9 @@ function mcl_util.generate_on_place_plant_function(condition)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check placement rules
|
-- Check placement rules
|
||||||
local result, param2 = condition(place_pos, node, itemstack)
|
if (condition(place_pos, node) == true) then
|
||||||
if result == true then
|
|
||||||
local idef = itemstack:get_definition()
|
local idef = itemstack:get_definition()
|
||||||
local new_itemstack, success = minetest.item_place_node(itemstack, placer, pointed_thing, param2)
|
local new_itemstack, success = minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
if success then
|
if success then
|
||||||
if idef.sounds and idef.sounds.place then
|
if idef.sounds and idef.sounds.place then
|
||||||
|
|
|
@ -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
|
|
|
@ -4,9 +4,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
timer = timer + dtime;
|
timer = timer + dtime;
|
||||||
if timer >= 0.3 then
|
if timer >= 0.3 then
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
local pp = player:get_pos()
|
local loc = vector.add(player:getpos(),{x=0,y=-1,z=0})
|
||||||
pp.y = math.ceil(pp.y)
|
|
||||||
local loc = vector.add(pp, {x=0,y=-1,z=0})
|
|
||||||
if loc ~= nil then
|
if loc ~= nil then
|
||||||
|
|
||||||
local nodeiamon = minetest.get_node(loc)
|
local nodeiamon = minetest.get_node(loc)
|
||||||
|
|
|
@ -13,7 +13,6 @@ minetest.register_entity("drippingwater:drop_water", {
|
||||||
physical = true,
|
physical = true,
|
||||||
collide_with_objects = false,
|
collide_with_objects = false,
|
||||||
collisionbox = {0,0,0,0,0,0},
|
collisionbox = {0,0,0,0,0,0},
|
||||||
pointable = false,
|
|
||||||
visual = "cube",
|
visual = "cube",
|
||||||
visual_size = {x=0.05, y=0.1},
|
visual_size = {x=0.05, y=0.1},
|
||||||
textures = {water_tex, water_tex, water_tex, water_tex, water_tex, water_tex},
|
textures = {water_tex, water_tex, water_tex, water_tex, water_tex, water_tex},
|
||||||
|
@ -21,19 +20,19 @@ minetest.register_entity("drippingwater:drop_water", {
|
||||||
initial_sprite_basepos = {x=0, y=0},
|
initial_sprite_basepos = {x=0, y=0},
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
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,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
local k = math.random(1,222)
|
local k = math.random(1,222)
|
||||||
local ownpos = self.object:get_pos()
|
local ownpos = self.object:getpos()
|
||||||
|
|
||||||
if k==1 then
|
if k==1 then
|
||||||
self.object:set_acceleration({x=0, y=-5, z=0})
|
self.object:setacceleration({x=0, y=-5, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
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
|
end
|
||||||
|
|
||||||
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
||||||
|
@ -59,19 +58,19 @@ minetest.register_entity("drippingwater:drop_lava", {
|
||||||
initial_sprite_basepos = {x=0, y=0},
|
initial_sprite_basepos = {x=0, y=0},
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
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,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
local k = math.random(1,222)
|
local k = math.random(1,222)
|
||||||
local ownpos = self.object:get_pos()
|
local ownpos = self.object:getpos()
|
||||||
|
|
||||||
if k==1 then
|
if k==1 then
|
||||||
self.object:set_acceleration({x=0, y=-5, z=0})
|
self.object:setacceleration({x=0, y=-5, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
local S = minetest.get_translator("mcl_boats")
|
|
||||||
--
|
--
|
||||||
-- Helper functions
|
-- Helper functions
|
||||||
--
|
--
|
||||||
|
@ -68,9 +67,9 @@ function boat.on_rightclick(self, clicker)
|
||||||
clicker:set_properties({visual_size = {x=1, y=1}})
|
clicker:set_properties({visual_size = {x=1, y=1}})
|
||||||
mcl_player.player_attached[name] = false
|
mcl_player.player_attached[name] = false
|
||||||
mcl_player.player_set_animation(clicker, "stand" , 30)
|
mcl_player.player_set_animation(clicker, "stand" , 30)
|
||||||
local pos = clicker:get_pos()
|
local pos = clicker:getpos()
|
||||||
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
|
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
|
||||||
clicker:set_pos(pos)
|
clicker:setpos(pos)
|
||||||
elseif not self._driver then
|
elseif not self._driver then
|
||||||
local attach = clicker:get_attach()
|
local attach = clicker:get_attach()
|
||||||
if attach and attach:get_luaentity() then
|
if attach and attach:get_luaentity() then
|
||||||
|
@ -83,16 +82,15 @@ function boat.on_rightclick(self, clicker)
|
||||||
end
|
end
|
||||||
self._driver = clicker
|
self._driver = clicker
|
||||||
clicker:set_attach(self.object, "",
|
clicker:set_attach(self.object, "",
|
||||||
{x = 0, y = 0.42, z = -1}, {x = 0, y = 0, z = 0})
|
{x = 0, y = 3.75, z = -1}, {x = 0, y = 0, z = 0})
|
||||||
clicker:set_properties({ visual_size = driver_visual_size })
|
clicker:set_properties({ visual_size = driver_visual_size })
|
||||||
mcl_player.player_attached[name] = true
|
mcl_player.player_attached[name] = true
|
||||||
minetest.after(0.2, function(name)
|
minetest.after(0.2, function(clicker)
|
||||||
local player = minetest.get_player_by_name(name)
|
if clicker:is_player() then
|
||||||
if player then
|
mcl_player.player_set_animation(clicker, "sit" , 30)
|
||||||
mcl_player.player_set_animation(player, "sit" , 30)
|
|
||||||
end
|
end
|
||||||
end, name)
|
end, clicker)
|
||||||
clicker:set_look_horizontal(self.object:get_yaw())
|
clicker:set_look_horizontal(self.object:getyaw())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -132,22 +130,17 @@ function boat.on_punch(self, puncher)
|
||||||
self._removed = true
|
self._removed = true
|
||||||
-- Drop boat as item on the ground after punching
|
-- Drop boat as item on the ground after punching
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
minetest.add_item(self.object:get_pos(), self._itemstring)
|
minetest.add_item(self.object:getpos(), 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
|
end
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function boat.on_step(self, dtime)
|
function boat.on_step(self, dtime)
|
||||||
self._v = get_v(self.object:get_velocity()) * get_sign(self._v)
|
self._v = get_v(self.object:getvelocity()) * get_sign(self._v)
|
||||||
if self._driver then
|
if self._driver then
|
||||||
local ctrl = self._driver:get_player_control()
|
local ctrl = self._driver:get_player_control()
|
||||||
local yaw = self.object:get_yaw()
|
local yaw = self.object:getyaw()
|
||||||
if ctrl.up then
|
if ctrl.up then
|
||||||
-- Forwards
|
-- Forwards
|
||||||
self._v = self._v + 0.1
|
self._v = self._v + 0.1
|
||||||
|
@ -175,15 +168,15 @@ function boat.on_step(self, dtime)
|
||||||
end
|
end
|
||||||
if ctrl.left then
|
if ctrl.left then
|
||||||
if self._v < 0 then
|
if self._v < 0 then
|
||||||
self.object:set_yaw(yaw - (1 + dtime) * 0.03)
|
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||||
else
|
else
|
||||||
self.object:set_yaw(yaw + (1 + dtime) * 0.03)
|
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||||
end
|
end
|
||||||
elseif ctrl.right then
|
elseif ctrl.right then
|
||||||
if self._v < 0 then
|
if self._v < 0 then
|
||||||
self.object:set_yaw(yaw + (1 + dtime) * 0.03)
|
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||||
else
|
else
|
||||||
self.object:set_yaw(yaw - (1 + dtime) * 0.03)
|
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -193,15 +186,15 @@ function boat.on_step(self, dtime)
|
||||||
self._animation = 0
|
self._animation = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local velo = self.object:get_velocity()
|
local velo = self.object:getvelocity()
|
||||||
if self._v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
if self._v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||||
self.object:set_pos(self.object:get_pos())
|
self.object:setpos(self.object:getpos())
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local s = get_sign(self._v)
|
local s = get_sign(self._v)
|
||||||
self._v = self._v - 0.02 * s
|
self._v = self._v - 0.02 * s
|
||||||
if s ~= get_sign(self._v) then
|
if s ~= get_sign(self._v) then
|
||||||
self.object:set_velocity({x = 0, y = 0, z = 0})
|
self.object:setvelocity({x = 0, y = 0, z = 0})
|
||||||
self._v = 0
|
self._v = 0
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -209,7 +202,7 @@ function boat.on_step(self, dtime)
|
||||||
self._v = 5 * get_sign(self._v)
|
self._v = 5 * get_sign(self._v)
|
||||||
end
|
end
|
||||||
|
|
||||||
local p = self.object:get_pos()
|
local p = self.object:getpos()
|
||||||
p.y = p.y - boat_y_offset
|
p.y = p.y - boat_y_offset
|
||||||
local new_velo
|
local new_velo
|
||||||
local new_acce = {x = 0, y = 0, z = 0}
|
local new_acce = {x = 0, y = 0, z = 0}
|
||||||
|
@ -221,13 +214,13 @@ function boat.on_step(self, dtime)
|
||||||
else
|
else
|
||||||
new_acce = {x = 0, y = -9.8, z = 0}
|
new_acce = {x = 0, y = -9.8, z = 0}
|
||||||
end
|
end
|
||||||
new_velo = get_velocity(self._v, self.object:get_yaw(),
|
new_velo = get_velocity(self._v, self.object:getyaw(),
|
||||||
self.object:get_velocity().y)
|
self.object:getvelocity().y)
|
||||||
self.object:set_pos(self.object:get_pos())
|
self.object:setpos(self.object:getpos())
|
||||||
else
|
else
|
||||||
p.y = p.y + 1
|
p.y = p.y + 1
|
||||||
if is_water(p) then
|
if is_water(p) then
|
||||||
local y = self.object:get_velocity().y
|
local y = self.object:getvelocity().y
|
||||||
if y >= 5 then
|
if y >= 5 then
|
||||||
y = 5
|
y = 5
|
||||||
elseif y < 0 then
|
elseif y < 0 then
|
||||||
|
@ -235,31 +228,31 @@ function boat.on_step(self, dtime)
|
||||||
else
|
else
|
||||||
new_acce = {x = 0, y = 5, z = 0}
|
new_acce = {x = 0, y = 5, z = 0}
|
||||||
end
|
end
|
||||||
new_velo = get_velocity(self._v, self.object:get_yaw(), y)
|
new_velo = get_velocity(self._v, self.object:getyaw(), y)
|
||||||
self.object:set_pos(self.object:get_pos())
|
self.object:setpos(self.object:getpos())
|
||||||
else
|
else
|
||||||
new_acce = {x = 0, y = 0, z = 0}
|
new_acce = {x = 0, y = 0, z = 0}
|
||||||
if math.abs(self.object:get_velocity().y) < 1 then
|
if math.abs(self.object:getvelocity().y) < 1 then
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:getpos()
|
||||||
pos.y = math.floor(pos.y) + boat_y_offset
|
pos.y = math.floor(pos.y) + boat_y_offset
|
||||||
self.object:set_pos(pos)
|
self.object:setpos(pos)
|
||||||
new_velo = get_velocity(self._v, self.object:get_yaw(), 0)
|
new_velo = get_velocity(self._v, self.object:getyaw(), 0)
|
||||||
else
|
else
|
||||||
new_velo = get_velocity(self._v, self.object:get_yaw(),
|
new_velo = get_velocity(self._v, self.object:getyaw(),
|
||||||
self.object:get_velocity().y)
|
self.object:getvelocity().y)
|
||||||
self.object:set_pos(self.object:get_pos())
|
self.object:setpos(self.object:getpos())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.object:set_velocity(new_velo)
|
self.object:setvelocity(new_velo)
|
||||||
self.object:set_acceleration(new_acce)
|
self.object:setacceleration(new_acce)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register one entity for all boat types
|
-- Register one entity for all boat types
|
||||||
minetest.register_entity("mcl_boats:boat", boat)
|
minetest.register_entity("mcl_boats:boat", boat)
|
||||||
|
|
||||||
local boat_ids = { "boat", "boat_spruce", "boat_birch", "boat_jungle", "boat_acacia", "boat_dark_oak" }
|
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 names = { "Oak Boat", "Spruce Boat", "Birch Boat", "Jungle Boat", "Acacia Boat", "Dark Oak Boat" }
|
||||||
local craftstuffs = {}
|
local craftstuffs = {}
|
||||||
if minetest.get_modpath("mcl_core") then
|
if minetest.get_modpath("mcl_core") then
|
||||||
craftstuffs = { "mcl_core:wood", "mcl_core:sprucewood", "mcl_core:birchwood", "mcl_core:junglewood", "mcl_core:acaciawood", "mcl_core:darkwood" }
|
craftstuffs = { "mcl_core:wood", "mcl_core:sprucewood", "mcl_core:birchwood", "mcl_core:junglewood", "mcl_core:acaciawood", "mcl_core:darkwood" }
|
||||||
|
@ -274,9 +267,9 @@ for b=1, #boat_ids do
|
||||||
-- Only create one help entry for all boats
|
-- Only create one help entry for all boats
|
||||||
if b == 1 then
|
if b == 1 then
|
||||||
help = true
|
help = true
|
||||||
longdesc = S("Boats are used to travel on the surface of water.")
|
longdesc = "Boats are used to travel on the surface of water."
|
||||||
usagehelp = S("Rightclick on a water source to place the boat. Rightclick the boat to enter it. Use [Left] and [Right] to steer, [Forwards] to speed up and [Backwards] to slow down or move backwards. Rightclick the boat again to leave it, punch the boat to make it drop as an item.")
|
usagehelp = "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")
|
helpname = "Boat"
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_craftitem(itemstring, {
|
minetest.register_craftitem(itemstring, {
|
||||||
|
@ -309,22 +302,11 @@ for b=1, #boat_ids do
|
||||||
local boat = minetest.add_entity(pointed_thing.under, "mcl_boats:boat")
|
local boat = minetest.add_entity(pointed_thing.under, "mcl_boats:boat")
|
||||||
boat:get_luaentity()._itemstring = itemstring
|
boat:get_luaentity()._itemstring = itemstring
|
||||||
boat:set_properties({textures = { "mcl_boats_texture_"..images[b].."_boat.png" }})
|
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
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
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]
|
local c = craftstuffs[b]
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Falling node entities, Minecraft-style
|
|
|
@ -1,256 +0,0 @@
|
||||||
local dmes = minetest.get_modpath("mcl_death_messages") ~= nil
|
|
||||||
|
|
||||||
local get_falling_depth = function(self)
|
|
||||||
if not self._startpos then
|
|
||||||
-- Fallback
|
|
||||||
self._startpos = self.object:get_pos()
|
|
||||||
end
|
|
||||||
return self._startpos.y - vector.round(self.object:get_pos()).y
|
|
||||||
end
|
|
||||||
|
|
||||||
local deal_falling_damage = function(self, dtime)
|
|
||||||
if minetest.get_item_group(self.node.name, "falling_node_damage") == 0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
-- Cause damage to any player it hits.
|
|
||||||
-- Algorithm based on MC anvils.
|
|
||||||
-- TODO: Support smashing other objects, too.
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
if not self._startpos then
|
|
||||||
-- Fallback
|
|
||||||
self._startpos = pos
|
|
||||||
end
|
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 1)
|
|
||||||
for _,v in ipairs(objs) do
|
|
||||||
local hp = v:get_hp()
|
|
||||||
if v:is_player() and hp ~= 0 then
|
|
||||||
if not self._hit_players then
|
|
||||||
self._hit_players = {}
|
|
||||||
end
|
|
||||||
local name = v:get_player_name()
|
|
||||||
local hit = false
|
|
||||||
for _,v in ipairs(self._hit_players) do
|
|
||||||
if name == v then
|
|
||||||
hit = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not hit then
|
|
||||||
table.insert(self._hit_players, name)
|
|
||||||
local way = self._startpos.y - pos.y
|
|
||||||
local damage = (way - 1) * 2
|
|
||||||
damage = math.min(40, math.max(0, damage))
|
|
||||||
if damage >= 1 then
|
|
||||||
hp = hp - damage
|
|
||||||
if hp < 0 then
|
|
||||||
hp = 0
|
|
||||||
end
|
|
||||||
if v:is_player() then
|
|
||||||
-- TODO: Reduce damage if wearing a helmet
|
|
||||||
local msg
|
|
||||||
if minetest.get_item_group(self.node.name, "anvil") ~= 0 then
|
|
||||||
msg = "%s was smashed by a falling anvil."
|
|
||||||
else
|
|
||||||
msg = "%s was smashed by a falling block."
|
|
||||||
end
|
|
||||||
if dmes then
|
|
||||||
mcl_death_messages.player_damage(v, string.format(msg, v:get_player_name()))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
v:set_hp(hp)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_entity(":__builtin:falling_node", {
|
|
||||||
initial_properties = {
|
|
||||||
visual = "wielditem",
|
|
||||||
visual_size = {x = 0.667, y = 0.667},
|
|
||||||
textures = {},
|
|
||||||
physical = true,
|
|
||||||
is_visible = false,
|
|
||||||
collide_with_objects = false,
|
|
||||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
|
||||||
},
|
|
||||||
|
|
||||||
node = {},
|
|
||||||
meta = {},
|
|
||||||
|
|
||||||
set_node = function(self, node, meta)
|
|
||||||
self.node = node
|
|
||||||
self.meta = meta or {}
|
|
||||||
self.object:set_properties({
|
|
||||||
is_visible = true,
|
|
||||||
textures = {node.name},
|
|
||||||
})
|
|
||||||
local def = core.registered_nodes[node.name]
|
|
||||||
-- Set correct entity yaw
|
|
||||||
if def and node.param2 ~= 0 then
|
|
||||||
if (def.paramtype2 == "facedir" or def.paramtype2 == "colorfacedir") then
|
|
||||||
self.object:set_yaw(core.dir_to_yaw(core.facedir_to_dir(node.param2)))
|
|
||||||
elseif (def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted") then
|
|
||||||
self.object:set_yaw(core.dir_to_yaw(core.wallmounted_to_dir(node.param2)))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
get_staticdata = function(self)
|
|
||||||
local meta = self.meta
|
|
||||||
-- Workaround: Save inventory seperately from metadata.
|
|
||||||
-- Because Minetest crashes when a node with inventory gets deactivated
|
|
||||||
-- (GitHub issue #7020).
|
|
||||||
-- FIXME: Remove the _inv workaround when it is no longer needed
|
|
||||||
local inv
|
|
||||||
if meta then
|
|
||||||
inv = meta.inv
|
|
||||||
meta.inventory = nil
|
|
||||||
end
|
|
||||||
local ds = {
|
|
||||||
node = self.node,
|
|
||||||
meta = self.meta,
|
|
||||||
_inv = inv,
|
|
||||||
_startpos = self._startpos,
|
|
||||||
_hit_players = self._hit_players,
|
|
||||||
}
|
|
||||||
return minetest.serialize(ds)
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
|
||||||
self.object:set_armor_groups({immortal = 1})
|
|
||||||
|
|
||||||
local ds = minetest.deserialize(staticdata)
|
|
||||||
if ds then
|
|
||||||
self._startpos = ds._startpos
|
|
||||||
self._hit_players = ds._hit_players
|
|
||||||
if ds.node then
|
|
||||||
local meta = ds.meta
|
|
||||||
meta.inventory = ds._inv
|
|
||||||
self:set_node(ds.node, meta)
|
|
||||||
else
|
|
||||||
self:set_node(ds)
|
|
||||||
end
|
|
||||||
elseif staticdata ~= "" then
|
|
||||||
self:set_node({name = staticdata})
|
|
||||||
end
|
|
||||||
if not self._startpos then
|
|
||||||
self._startpos = self.object:get_pos()
|
|
||||||
end
|
|
||||||
self._startpos = vector.round(self._startpos)
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
|
||||||
-- Set gravity
|
|
||||||
local acceleration = self.object:get_acceleration()
|
|
||||||
if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
|
|
||||||
self.object:set_acceleration({x = 0, y = -10, z = 0})
|
|
||||||
end
|
|
||||||
-- Turn to actual node when colliding with ground, or continue to move
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
-- Portal check
|
|
||||||
local np = {x = pos.x, y = pos.y + 0.3, z = pos.z}
|
|
||||||
local n2 = minetest.get_node(np)
|
|
||||||
if n2.name == "mcl_portals:portal_end" then
|
|
||||||
-- TODO: Teleport falling node.
|
|
||||||
self.object:remove()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Position of bottom center point
|
|
||||||
local bcp = {x = pos.x, y = pos.y - 0.7, z = pos.z}
|
|
||||||
-- Avoid bugs caused by an unloaded node below
|
|
||||||
local bcn = minetest.get_node_or_nil(bcp)
|
|
||||||
local bcd = bcn and minetest.registered_nodes[bcn.name]
|
|
||||||
|
|
||||||
-- TODO: At this point, we did 2 get_nodes in 1 tick.
|
|
||||||
-- Figure out how to improve that (if it is a problem).
|
|
||||||
|
|
||||||
if bcn and (not bcd or bcd.walkable or
|
|
||||||
(minetest.get_item_group(self.node.name, "float") ~= 0 and
|
|
||||||
bcd.liquidtype ~= "none")) then
|
|
||||||
if bcd and bcd.leveled and
|
|
||||||
bcn.name == self.node.name then
|
|
||||||
local addlevel = self.node.level
|
|
||||||
if not addlevel or addlevel <= 0 then
|
|
||||||
addlevel = bcd.leveled
|
|
||||||
end
|
|
||||||
if minetest.add_node_level(bcp, addlevel) == 0 then
|
|
||||||
if minetest.registered_nodes[self.node.name]._mcl_after_falling then
|
|
||||||
minetest.registered_nodes[self.node.name]._mcl_after_falling(bcp, get_falling_depth(self))
|
|
||||||
end
|
|
||||||
deal_falling_damage(self, dtime)
|
|
||||||
self.object:remove()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
elseif bcd and bcd.buildable_to and
|
|
||||||
(minetest.get_item_group(self.node.name, "float") == 0 or
|
|
||||||
bcd.liquidtype == "none") then
|
|
||||||
minetest.remove_node(bcp)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local nd = minetest.registered_nodes[n2.name]
|
|
||||||
if n2.name == "mcl_portals:portal_end" then
|
|
||||||
-- TODO: Teleport falling node.
|
|
||||||
|
|
||||||
elseif (nd and nd.buildable_to == true) or minetest.get_item_group(self.node.name, "crush_after_fall") ~= 0 then
|
|
||||||
-- Replace destination node if it's buildable to
|
|
||||||
minetest.remove_node(np)
|
|
||||||
-- Run script hook
|
|
||||||
for _, callback in pairs(minetest.registered_on_dignodes) do
|
|
||||||
callback(np, n2)
|
|
||||||
end
|
|
||||||
if minetest.registered_nodes[self.node.name] then
|
|
||||||
minetest.add_node(np, self.node)
|
|
||||||
if minetest.registered_nodes[self.node.name]._mcl_after_falling then
|
|
||||||
minetest.registered_nodes[self.node.name]._mcl_after_falling(np, get_falling_depth(self))
|
|
||||||
end
|
|
||||||
if self.meta then
|
|
||||||
local meta = minetest.get_meta(np)
|
|
||||||
meta:from_table(self.meta)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- Drop the *falling node* as an item if the destination node is NOT buildable to
|
|
||||||
local drops = minetest.get_node_drops(self.node.name, "")
|
|
||||||
for _, dropped_item in pairs(drops) do
|
|
||||||
minetest.add_item(np, dropped_item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
deal_falling_damage(self, dtime)
|
|
||||||
self.object:remove()
|
|
||||||
minetest.check_for_falling(np)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
-- Fix position if entity does not move
|
|
||||||
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
|
|
||||||
local npos = vector.round(self.object:get_pos())
|
|
||||||
local npos2 = table.copy(npos)
|
|
||||||
npos2.y = npos2.y - 2
|
|
||||||
local lownode = minetest.get_node(npos2)
|
|
||||||
-- Special check required for fences and walls, because of their overhigh collision box.
|
|
||||||
if minetest.get_item_group(lownode.name, "fence") == 1 or minetest.get_item_group(lownode.name, "wall") == 1 then
|
|
||||||
-- Instantly stop the node if it is above a fence/wall. This is needed
|
|
||||||
-- because the falling node collides early with a fence/wall node.
|
|
||||||
-- Hacky, because the falling node will teleport a short distance, instead
|
|
||||||
-- of smoothly fall on the fence post.
|
|
||||||
local npos3 = table.copy(npos)
|
|
||||||
npos3.y = npos3.y - 1
|
|
||||||
minetest.add_node(npos3, self.node)
|
|
||||||
if minetest.registered_nodes[self.node.name]._mcl_after_falling then
|
|
||||||
minetest.registered_nodes[self.node.name]._mcl_after_falling(npos3, get_falling_depth(self))
|
|
||||||
end
|
|
||||||
deal_falling_damage(self, dtime)
|
|
||||||
self.object:remove()
|
|
||||||
minetest.check_for_falling(npos3)
|
|
||||||
return
|
|
||||||
else
|
|
||||||
-- Normal position fix (expected case)
|
|
||||||
self.object:set_pos(npos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
deal_falling_damage(self, dtime)
|
|
||||||
end
|
|
||||||
})
|
|
|
@ -1 +0,0 @@
|
||||||
name = mcl_falling_nodes
|
|
|
@ -4,7 +4,7 @@ by PilzAdam
|
||||||
Introduction:
|
Introduction:
|
||||||
This mod adds Minecraft like drop/pick up of items to Minetest.
|
This mod adds Minecraft like drop/pick up of items to Minetest.
|
||||||
|
|
||||||
This mod has been forked from item_drop in the VoxBox game.
|
This mod has been forked from item_drop in the VoxBox subgame.
|
||||||
|
|
||||||
License:
|
License:
|
||||||
Sourcecode: WTFPL (see below)
|
Sourcecode: WTFPL (see below)
|
||||||
|
|
|
@ -55,20 +55,20 @@ end
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
|
if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
|
||||||
local pos = player:get_pos()
|
local pos = player:getpos()
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local checkpos = {x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z}
|
local checkpos = {x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z}
|
||||||
|
|
||||||
--magnet and collection
|
--magnet and collection
|
||||||
for _,object in ipairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.radius_magnet)) do
|
for _,object in ipairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.radius_magnet)) do
|
||||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and object:get_luaentity()._magnet_timer and (object:get_luaentity()._insta_collect or (object:get_luaentity().age > item_drop_settings.age)) then
|
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and (object:get_luaentity()._insta_collect or (object:get_luaentity().age > item_drop_settings.age)) then
|
||||||
object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime
|
object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime
|
||||||
local collected = false
|
local collected = false
|
||||||
if object:get_luaentity()._magnet_timer >= 0 and object:get_luaentity()._magnet_timer < item_drop_settings.magnet_time and inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
if object:get_luaentity()._magnet_timer >= 0 and object:get_luaentity()._magnet_timer < item_drop_settings.magnet_time and inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||||
|
|
||||||
-- Collection
|
-- Collection
|
||||||
if vector.distance(checkpos, object:get_pos()) <= item_drop_settings.radius_collect and not object:get_luaentity()._removed then
|
if vector.distance(checkpos, object:getpos()) <= item_drop_settings.radius_collect then
|
||||||
-- Ignore if itemstring is not set yet
|
|
||||||
if object:get_luaentity().itemstring ~= "" then
|
if object:get_luaentity().itemstring ~= "" then
|
||||||
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||||
minetest.sound_play("item_drop_pickup", {
|
minetest.sound_play("item_drop_pickup", {
|
||||||
|
@ -77,11 +77,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
gain = 1.0,
|
gain = 1.0,
|
||||||
})
|
})
|
||||||
check_pickup_achievements(object, player)
|
check_pickup_achievements(object, player)
|
||||||
|
object:get_luaentity().itemstring = ""
|
||||||
|
|
||||||
-- Destroy entity
|
|
||||||
-- This just prevents this section to be run again because object:remove() doesn't remove the item immediately.
|
|
||||||
object:get_luaentity()._removed = true
|
|
||||||
object:remove()
|
object:remove()
|
||||||
collected = true
|
collected = true
|
||||||
end
|
end
|
||||||
|
@ -95,17 +91,17 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- Move object to player
|
-- Move object to player
|
||||||
disable_physics(object, object:get_luaentity())
|
disable_physics(object, object:get_luaentity())
|
||||||
|
|
||||||
local opos = object:get_pos()
|
local opos = object:getpos()
|
||||||
local vec = vector.subtract(checkpos, opos)
|
local vec = vector.subtract(checkpos, opos)
|
||||||
vec = vector.add(opos, vector.divide(vec, 2))
|
vec = vector.add(opos, vector.divide(vec, 2))
|
||||||
object:move_to(vec)
|
object:moveto(vec)
|
||||||
|
|
||||||
|
|
||||||
--fix eternally falling items
|
--fix eternally falling items
|
||||||
minetest.after(0, function(object)
|
minetest.after(0, function(object)
|
||||||
local lua = object:get_luaentity()
|
local lua = object:get_luaentity()
|
||||||
if lua then
|
if lua then
|
||||||
object:set_acceleration({x=0, y=0, z=0})
|
object:setacceleration({x=0, y=0, z=0})
|
||||||
end
|
end
|
||||||
end, object)
|
end, object)
|
||||||
|
|
||||||
|
@ -115,8 +111,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
if object:get_luaentity().init ~= true then
|
if object:get_luaentity().init ~= true then
|
||||||
object:get_luaentity().init = true
|
object:get_luaentity().init = true
|
||||||
minetest.after(1, function(args)
|
minetest.after(1, function(args)
|
||||||
local playername = args[1]
|
local player = args[1]
|
||||||
local player = minetest.get_player_by_name(playername)
|
|
||||||
local object = args[2]
|
local object = args[2]
|
||||||
local lua = object:get_luaentity()
|
local lua = object:get_luaentity()
|
||||||
if player == nil or not player:is_player() or object == nil or lua == nil or lua.itemstring == nil then
|
if player == nil or not player:is_player() or object == nil or lua == nil or lua.itemstring == nil then
|
||||||
|
@ -124,7 +119,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||||
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||||
if not object:get_luaentity()._removed then
|
if object:get_luaentity().itemstring ~= "" then
|
||||||
minetest.sound_play("item_drop_pickup", {
|
minetest.sound_play("item_drop_pickup", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
max_hear_distance = 16,
|
max_hear_distance = 16,
|
||||||
|
@ -132,12 +127,12 @@ minetest.register_globalstep(function(dtime)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
check_pickup_achievements(object, player)
|
check_pickup_achievements(object, player)
|
||||||
object:get_luaentity()._removed = true
|
object:get_luaentity().itemstring = ""
|
||||||
object:remove()
|
object:remove()
|
||||||
else
|
else
|
||||||
enable_physics(object, object:get_luaentity())
|
enable_physics(object, object:get_luaentity())
|
||||||
end
|
end
|
||||||
end, {player:get_player_name(), object})
|
end, {player, object})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -208,25 +203,18 @@ local check_can_drop = function(node_name, tool_capabilities)
|
||||||
end
|
end
|
||||||
|
|
||||||
function minetest.handle_node_drops(pos, drops, digger)
|
function minetest.handle_node_drops(pos, drops, digger)
|
||||||
-- NOTE: This function override allows digger to be nil.
|
|
||||||
-- This means there is no digger. This is a special case which allows this function to be called
|
|
||||||
-- by hand. Creative Mode is intentionally ignored in this case.
|
|
||||||
|
|
||||||
local doTileDrops = minetest.settings:get_bool("mcl_doTileDrops") or true
|
local doTileDrops = minetest.settings:get_bool("mcl_doTileDrops") or true
|
||||||
if (digger ~= nil and minetest.settings:get_bool("creative_mode")) or doTileDrops == false then
|
if minetest.settings:get_bool("creative_mode") or doTileDrops == false then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if node will yield its useful drop by the digger's tool
|
-- Check if node will yield its useful drop by the digger's tool
|
||||||
local dug_node = minetest.get_node(pos)
|
local dug_node = minetest.get_node(pos)
|
||||||
local toolcaps
|
local tool = digger:get_wielded_item()
|
||||||
if digger ~= nil then
|
local toolcaps = tool:get_tool_capabilities()
|
||||||
local tool = digger:get_wielded_item()
|
|
||||||
toolcaps = tool:get_tool_capabilities()
|
|
||||||
|
|
||||||
if not check_can_drop(dug_node.name, toolcaps) then
|
if not check_can_drop(dug_node.name, toolcaps) then
|
||||||
return
|
return
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ Special node drops when dug by shears by reading _mcl_shears_drop
|
--[[ Special node drops when dug by shears by reading _mcl_shears_drop
|
||||||
|
@ -236,7 +224,7 @@ function minetest.handle_node_drops(pos, drops, digger)
|
||||||
* table: Drop every itemstring in this table when dub by shears
|
* table: Drop every itemstring in this table when dub by shears
|
||||||
]]
|
]]
|
||||||
local nodedef = minetest.registered_nodes[dug_node.name]
|
local nodedef = minetest.registered_nodes[dug_node.name]
|
||||||
if toolcaps ~= nil and toolcaps.groupcaps and toolcaps.groupcaps.shearsy_dig and nodedef._mcl_shears_drop then
|
if toolcaps.groupcaps and toolcaps.groupcaps.shearsy_dig and nodedef._mcl_shears_drop then
|
||||||
if nodedef._mcl_shears_drop == true then
|
if nodedef._mcl_shears_drop == true then
|
||||||
drops = { dug_node.name }
|
drops = { dug_node.name }
|
||||||
else
|
else
|
||||||
|
@ -245,16 +233,16 @@ function minetest.handle_node_drops(pos, drops, digger)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,item in ipairs(drops) do
|
for _,item in ipairs(drops) do
|
||||||
local count
|
local count, name
|
||||||
if type(item) == "string" then
|
if type(item) == "string" then
|
||||||
count = ItemStack(item):get_count()
|
count = 1
|
||||||
|
name = item
|
||||||
else
|
else
|
||||||
count = item:get_count()
|
count = item:get_count()
|
||||||
|
name = item:get_name()
|
||||||
end
|
end
|
||||||
local drop_item = ItemStack(item)
|
|
||||||
drop_item:set_count(1)
|
|
||||||
for i=1,count do
|
for i=1,count do
|
||||||
local obj = core.add_item(pos, drop_item)
|
local obj = minetest.add_item(pos, name)
|
||||||
if obj ~= nil then
|
if obj ~= nil then
|
||||||
local x = math.random(1, 5)
|
local x = math.random(1, 5)
|
||||||
if math.random(1,2) == 1 then
|
if math.random(1,2) == 1 then
|
||||||
|
@ -264,7 +252,7 @@ function minetest.handle_node_drops(pos, drops, digger)
|
||||||
if math.random(1,2) == 1 then
|
if math.random(1,2) == 1 then
|
||||||
z = -z
|
z = -z
|
||||||
end
|
end
|
||||||
obj:set_velocity({x=1/x, y=obj:get_velocity().y, z=1/z})
|
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -285,7 +273,7 @@ function minetest.item_drop(itemstack, dropper, pos)
|
||||||
v.x = v.x*4
|
v.x = v.x*4
|
||||||
v.y = v.y*4 + 2
|
v.y = v.y*4 + 2
|
||||||
v.z = v.z*4
|
v.z = v.z*4
|
||||||
obj:set_velocity(v)
|
obj:setvelocity(v)
|
||||||
-- Force collection delay
|
-- Force collection delay
|
||||||
obj:get_luaentity()._insta_collect = false
|
obj:get_luaentity()._insta_collect = false
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -295,7 +283,7 @@ end
|
||||||
|
|
||||||
--modify builtin:item
|
--modify builtin:item
|
||||||
|
|
||||||
local time_to_live = tonumber(minetest.settings:get("item_entity_ttl"))
|
local time_to_live = tonumber(core.setting_get("item_entity_ttl"))
|
||||||
if not time_to_live then
|
if not time_to_live then
|
||||||
time_to_live = 300
|
time_to_live = 300
|
||||||
end
|
end
|
||||||
|
@ -306,7 +294,6 @@ core.register_entity(":__builtin:item", {
|
||||||
physical = true,
|
physical = true,
|
||||||
collide_with_objects = false,
|
collide_with_objects = false,
|
||||||
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
|
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
|
||||||
pointable = false,
|
|
||||||
visual = "wielditem",
|
visual = "wielditem",
|
||||||
visual_size = {x = 0.4, y = 0.4},
|
visual_size = {x = 0.4, y = 0.4},
|
||||||
textures = {""},
|
textures = {""},
|
||||||
|
@ -316,27 +303,17 @@ core.register_entity(":__builtin:item", {
|
||||||
infotext = "",
|
infotext = "",
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Itemstring of dropped item. The empty string is used when the item is not yet initialized yet.
|
|
||||||
-- The itemstring MUST be set immediately to a non-empty string after creating the entity.
|
|
||||||
-- The hand is NOT permitted as dropped item. ;-)
|
|
||||||
-- Item entities will be deleted if they still have an empty itemstring on their first on_step tick.
|
|
||||||
itemstring = '',
|
itemstring = '',
|
||||||
|
|
||||||
-- If true, item will fall
|
|
||||||
physical_state = true,
|
physical_state = true,
|
||||||
|
_flowing = false, -- item entity is currently flowing
|
||||||
-- If item entity is currently flowing in water
|
-- States:
|
||||||
_flowing = false,
|
-- * "magnet": Attracted to a nearby player or item
|
||||||
|
-- * "flowing": Moving in a flowing liquid
|
||||||
-- Number of seconds this item entity has existed so far
|
-- * "normal": Affected by gravitiy
|
||||||
age = 0,
|
age = 0,
|
||||||
|
|
||||||
set_item = function(self, itemstring)
|
set_item = function(self, itemstring)
|
||||||
self.itemstring = itemstring
|
self.itemstring = itemstring
|
||||||
if self.itemstring == "" then
|
|
||||||
-- item not yet known
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local stack = ItemStack(itemstring)
|
local stack = ItemStack(itemstring)
|
||||||
local count = stack:get_count()
|
local count = stack:get_count()
|
||||||
local max_count = stack:get_stack_max()
|
local max_count = stack:get_stack_max()
|
||||||
|
@ -374,7 +351,7 @@ core.register_entity(":__builtin:item", {
|
||||||
if not self or not self.object or not self.object:get_luaentity() then
|
if not self or not self.object or not self.object:get_luaentity() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local vel = self.object:get_velocity()
|
local vel = self.object:getvelocity()
|
||||||
if vel and vel.x == 0 and vel.z == 0 then
|
if vel and vel.x == 0 and vel.z == 0 then
|
||||||
local x = math.random(1, 5)
|
local x = math.random(1, 5)
|
||||||
if math.random(1,2) == 1 then
|
if math.random(1,2) == 1 then
|
||||||
|
@ -385,7 +362,7 @@ core.register_entity(":__builtin:item", {
|
||||||
z = -z
|
z = -z
|
||||||
end
|
end
|
||||||
local y = math.random(2,4)
|
local y = math.random(2,4)
|
||||||
self.object:set_velocity({x=1/x, y=y, z=1/z})
|
self.object:setvelocity({x=1/x, y=y, z=1/z})
|
||||||
end
|
end
|
||||||
end, self)
|
end, self)
|
||||||
end
|
end
|
||||||
|
@ -399,7 +376,6 @@ core.register_entity(":__builtin:item", {
|
||||||
age = self.age,
|
age = self.age,
|
||||||
_insta_collect = self._insta_collect,
|
_insta_collect = self._insta_collect,
|
||||||
_flowing = self._flowing,
|
_flowing = self._flowing,
|
||||||
_removed = self._removed,
|
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -418,16 +394,10 @@ core.register_entity(":__builtin:item", {
|
||||||
-- If true, can collect item without delay
|
-- If true, can collect item without delay
|
||||||
self._insta_collect = data._insta_collect
|
self._insta_collect = data._insta_collect
|
||||||
self._flowing = data._flowing
|
self._flowing = data._flowing
|
||||||
self._removed = data._removed
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.itemstring = staticdata
|
self.itemstring = staticdata
|
||||||
end
|
end
|
||||||
if self._removed then
|
|
||||||
self._removed = true
|
|
||||||
self.object:remove()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if self._insta_collect == nil then
|
if self._insta_collect == nil then
|
||||||
-- Intentionally default, since delayed collection is rare
|
-- Intentionally default, since delayed collection is rare
|
||||||
self._insta_collect = true
|
self._insta_collect = true
|
||||||
|
@ -445,71 +415,72 @@ core.register_entity(":__builtin:item", {
|
||||||
self._forcetimer = 0
|
self._forcetimer = 0
|
||||||
|
|
||||||
self.object:set_armor_groups({immortal = 1})
|
self.object:set_armor_groups({immortal = 1})
|
||||||
self.object:set_velocity({x = 0, y = 2, z = 0})
|
self.object:setvelocity({x = 0, y = 2, z = 0})
|
||||||
self.object:set_acceleration({x = 0, y = -get_gravity(), z = 0})
|
self.object:setacceleration({x = 0, y = -get_gravity(), z = 0})
|
||||||
self:set_item(self.itemstring)
|
self:set_item(self.itemstring)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
try_merge_with = function(self, own_stack, object, entity)
|
try_merge_with = function(self, own_stack, object, obj)
|
||||||
if self.age == entity.age or entity._removed then
|
local stack = ItemStack(obj.itemstring)
|
||||||
-- Can not merge with itself and remove entity
|
if own_stack:get_name() == stack:get_name() and stack:get_free_space() > 0 then
|
||||||
return false
|
local overflow = false
|
||||||
|
local count = stack:get_count() + own_stack:get_count()
|
||||||
|
local max_count = stack:get_stack_max()
|
||||||
|
if count > max_count then
|
||||||
|
overflow = true
|
||||||
|
count = count - max_count
|
||||||
|
else
|
||||||
|
self.itemstring = ''
|
||||||
|
end
|
||||||
|
local pos = object:getpos()
|
||||||
|
pos.y = pos.y + (count - stack:get_count()) / max_count * 0.15
|
||||||
|
object:moveto(pos, false)
|
||||||
|
local s, c
|
||||||
|
local max_count = stack:get_stack_max()
|
||||||
|
local name = stack:get_name()
|
||||||
|
if not overflow then
|
||||||
|
obj.itemstring = name .. " " .. count
|
||||||
|
s = 0.2 + 0.1 * (count / max_count)
|
||||||
|
c = s
|
||||||
|
object:set_properties({
|
||||||
|
visual_size = {x = s, y = s},
|
||||||
|
collisionbox = {-c, -c, -c, c, c, c}
|
||||||
|
})
|
||||||
|
self.object:remove()
|
||||||
|
-- merging succeeded
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
s = 0.4
|
||||||
|
c = 0.3
|
||||||
|
object:set_properties({
|
||||||
|
visual_size = {x = s, y = s},
|
||||||
|
collisionbox = {-c, -c, -c, c, c, c}
|
||||||
|
})
|
||||||
|
obj.itemstring = name .. " " .. max_count
|
||||||
|
s = 0.2 + 0.1 * (count / max_count)
|
||||||
|
c = s
|
||||||
|
self.object:set_properties({
|
||||||
|
visual_size = {x = s, y = s},
|
||||||
|
collisionbox = {-c, -c, -c, c, c, c}
|
||||||
|
})
|
||||||
|
self.itemstring = name .. " " .. count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
-- merging didn't succeed
|
||||||
local stack = ItemStack(entity.itemstring)
|
return false
|
||||||
local name = stack:get_name()
|
|
||||||
if own_stack:get_name() ~= name or
|
|
||||||
own_stack:get_meta() ~= stack:get_meta() or
|
|
||||||
own_stack:get_wear() ~= stack:get_wear() or
|
|
||||||
own_stack:get_free_space() == 0 then
|
|
||||||
-- Can not merge different or full stack
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local count = own_stack:get_count()
|
|
||||||
local total_count = stack:get_count() + count
|
|
||||||
local max_count = stack:get_stack_max()
|
|
||||||
|
|
||||||
if total_count > max_count then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
-- Merge the remote stack into this one
|
|
||||||
|
|
||||||
local pos = object:get_pos()
|
|
||||||
pos.y = pos.y + ((total_count - count) / max_count) * 0.15
|
|
||||||
self.object:move_to(pos)
|
|
||||||
|
|
||||||
self.age = 0 -- Handle as new entity
|
|
||||||
own_stack:set_count(total_count)
|
|
||||||
self:set_item(own_stack:to_string())
|
|
||||||
|
|
||||||
entity._removed = true
|
|
||||||
object:remove()
|
|
||||||
return true
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
if self._removed then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self.age = self.age + dtime
|
self.age = self.age + dtime
|
||||||
if self._collector_timer ~= nil then
|
if self._collector_timer ~= nil then
|
||||||
self._collector_timer = self._collector_timer + dtime
|
self._collector_timer = self._collector_timer + dtime
|
||||||
end
|
end
|
||||||
if time_to_live > 0 and self.age > time_to_live then
|
if time_to_live > 0 and self.age > time_to_live then
|
||||||
self._removed = true
|
self.itemstring = ''
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Delete corrupted item entities. The itemstring MUST be non-empty on its first step,
|
local p = self.object:getpos()
|
||||||
-- otherwise there might have some data corruption.
|
|
||||||
if self.itemstring == "" then
|
|
||||||
minetest.log("warning", "Item entity with empty itemstring found at "..minetest.pos_to_string(self.object:get_pos()).. "! Deleting it now.")
|
|
||||||
self._removed = true
|
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
|
|
||||||
local p = self.object:get_pos()
|
|
||||||
local node = core.get_node_or_nil(p)
|
local node = core.get_node_or_nil(p)
|
||||||
local in_unloaded = (node == nil)
|
local in_unloaded = (node == nil)
|
||||||
|
|
||||||
|
@ -525,17 +496,14 @@ core.register_entity(":__builtin:item", {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Destroy item in lava, fire or special nodes
|
-- Destroy item in lava or special nodes
|
||||||
local nn = node.name
|
local nn = node.name
|
||||||
local def = minetest.registered_nodes[nn]
|
local def = minetest.registered_nodes[nn]
|
||||||
local lg = minetest.get_item_group(nn, "lava")
|
if (def and def.groups and (def.groups.lava or def.groups.destroys_items == 1)) then
|
||||||
local fg = minetest.get_item_group(nn, "fire")
|
-- Special effect for lava
|
||||||
local dg = minetest.get_item_group(nn, "destroys_items")
|
if def.groups.lava then
|
||||||
if (def and (lg ~= 0 or fg ~= 0 or dg == 1)) then
|
minetest.sound_play("builtin_item_lava", {pos = self.object:getpos(), gain = 0.5})
|
||||||
if dg ~= 2 then
|
|
||||||
minetest.sound_play("builtin_item_lava", {pos = self.object:get_pos(), gain = 0.5})
|
|
||||||
end
|
end
|
||||||
self._removed = true
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -590,8 +558,8 @@ core.register_entity(":__builtin:item", {
|
||||||
|
|
||||||
-- Set new item moving speed accordingly
|
-- Set new item moving speed accordingly
|
||||||
local newv = vector.multiply(shootdir, 3)
|
local newv = vector.multiply(shootdir, 3)
|
||||||
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
self.object:setacceleration({x = 0, y = 0, z = 0})
|
||||||
self.object:set_velocity(newv)
|
self.object:setvelocity(newv)
|
||||||
|
|
||||||
disable_physics(self.object, self, false, false)
|
disable_physics(self.object, self, false, false)
|
||||||
|
|
||||||
|
@ -644,8 +612,8 @@ core.register_entity(":__builtin:item", {
|
||||||
local f = 1.39
|
local f = 1.39
|
||||||
-- Set new item moving speed into the direciton of the liquid
|
-- Set new item moving speed into the direciton of the liquid
|
||||||
local newv = vector.multiply(vec, f)
|
local newv = vector.multiply(vec, f)
|
||||||
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
self.object:setacceleration({x = 0, y = 0, z = 0})
|
||||||
self.object:set_velocity({x = newv.x, y = -0.22, z = newv.z})
|
self.object:setvelocity({x = newv.x, y = -0.22, z = newv.z})
|
||||||
|
|
||||||
self.physical_state = true
|
self.physical_state = true
|
||||||
self._flowing = true
|
self._flowing = true
|
||||||
|
@ -663,7 +631,7 @@ core.register_entity(":__builtin:item", {
|
||||||
|
|
||||||
-- If node is not registered or node is walkably solid and resting on nodebox
|
-- If node is not registered or node is walkably solid and resting on nodebox
|
||||||
local nn = minetest.get_node({x=p.x, y=p.y-0.5, z=p.z}).name
|
local nn = minetest.get_node({x=p.x, y=p.y-0.5, z=p.z}).name
|
||||||
local v = self.object:get_velocity()
|
local v = self.object:getvelocity()
|
||||||
|
|
||||||
if not core.registered_nodes[nn] or core.registered_nodes[nn].walkable and v.y == 0 then
|
if not core.registered_nodes[nn] or core.registered_nodes[nn].walkable and v.y == 0 then
|
||||||
if self.physical_state then
|
if self.physical_state then
|
||||||
|
|
|
@ -13,10 +13,6 @@ License of source code:
|
||||||
-----------------------
|
-----------------------
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (C) 2012-2016 PilzAdam
|
|
||||||
Copyright (C) 2014-2016 SmallJoker
|
|
||||||
Copyright (C) 2012-2016 Various Minetest developers and contributors
|
|
||||||
|
|
||||||
Authors/licenses of media files:
|
Authors/licenses of media files:
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,5 @@ mcl_core
|
||||||
mcl_sounds
|
mcl_sounds
|
||||||
mcl_player
|
mcl_player
|
||||||
mcl_achievements
|
mcl_achievements
|
||||||
mcl_chests
|
mesecons?
|
||||||
mcl_furnaces
|
|
||||||
mesecons_commandblock
|
|
||||||
mcl_hoppers
|
|
||||||
mcl_tnt
|
|
||||||
mesecons
|
|
||||||
doc_identifier?
|
doc_identifier?
|
||||||
|
|
|
@ -138,3 +138,13 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
||||||
return {x=0, y=0, z=0}
|
return {x=0, y=0, z=0}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_minecarts:boost_rail(pos, amount)
|
||||||
|
minetest.get_meta(pos):set_string("cart_acceleration", tostring(amount))
|
||||||
|
for _,obj_ in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do
|
||||||
|
if not obj_:is_player() and
|
||||||
|
obj_:get_luaentity() and
|
||||||
|
obj_:get_luaentity().name == "mcl_minecarts:minecart" then
|
||||||
|
obj_:get_luaentity():on_punch()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -1,629 +1,323 @@
|
||||||
local S = minetest.get_translator("mcl_minecarts")
|
|
||||||
|
|
||||||
mcl_minecarts = {}
|
mcl_minecarts = {}
|
||||||
mcl_minecarts.modpath = minetest.get_modpath("mcl_minecarts")
|
mcl_minecarts.modpath = minetest.get_modpath("mcl_minecarts")
|
||||||
mcl_minecarts.speed_max = 10
|
mcl_minecarts.speed_max = 10
|
||||||
mcl_minecarts.check_float_time = 15
|
|
||||||
|
local vector_floor = function(v)
|
||||||
|
return {
|
||||||
|
x = math.floor(v.x),
|
||||||
|
y = math.floor(v.y),
|
||||||
|
z = math.floor(v.z)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
dofile(mcl_minecarts.modpath.."/functions.lua")
|
dofile(mcl_minecarts.modpath.."/functions.lua")
|
||||||
dofile(mcl_minecarts.modpath.."/rails.lua")
|
dofile(mcl_minecarts.modpath.."/rails.lua")
|
||||||
|
|
||||||
-- Table for item-to-entity mapping. Keys: itemstring, Values: Corresponding entity ID
|
mcl_minecarts.cart = {
|
||||||
local entity_mapping = {}
|
physical = false,
|
||||||
|
collisionbox = {-10/16., -0.5, -10/16, 10/16, 0.25, 10/16},
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "mcl_minecarts_minecart.b3d",
|
||||||
|
visual_size = {x=1, y=1},
|
||||||
|
textures = {"mcl_minecarts_minecart.png"},
|
||||||
|
|
||||||
local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
|
_driver = nil,
|
||||||
local cart = {
|
_punched = false, -- used to re-send _velocity and position
|
||||||
physical = false,
|
_velocity = {x=0, y=0, z=0}, -- only used on punch
|
||||||
collisionbox = {-10/16., -0.5, -10/16, 10/16, 0.25, 10/16},
|
_start_pos = nil, -- Used to calculate distance for “On A Rail” achievement
|
||||||
visual = "mesh",
|
_old_dir = {x=0, y=0, z=0},
|
||||||
mesh = mesh,
|
_old_pos = nil,
|
||||||
visual_size = {x=1, y=1},
|
_old_switch = 0,
|
||||||
textures = textures,
|
_railtype = nil,
|
||||||
|
}
|
||||||
|
|
||||||
on_rightclick = on_rightclick,
|
function mcl_minecarts.cart:on_rightclick(clicker)
|
||||||
|
if not clicker or not clicker:is_player() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local player_name = clicker:get_player_name()
|
||||||
|
if self._driver and player_name == self._driver then
|
||||||
|
self._driver = nil
|
||||||
|
self._start_pos = nil
|
||||||
|
clicker:set_detach()
|
||||||
|
elseif not self._driver then
|
||||||
|
self._driver = player_name
|
||||||
|
self._start_pos = self.object:getpos()
|
||||||
|
mcl_player.player_attached[player_name] = true
|
||||||
|
clicker:set_attach(self.object, "", {x=0, y=3, z=0}, {x=0, y=0, z=0})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
_driver = nil, -- player who sits in and controls the minecart (only for minecart!)
|
function mcl_minecarts.cart:on_activate(staticdata, dtime_s)
|
||||||
_punched = false, -- used to re-send _velocity and position
|
self.object:set_armor_groups({immortal=1})
|
||||||
_velocity = {x=0, y=0, z=0}, -- only used on punch
|
end
|
||||||
_start_pos = nil, -- Used to calculate distance for “On A Rail” achievement
|
|
||||||
_last_float_check = nil, -- timestamp of last time the cart was checked to be still on a rail
|
|
||||||
_old_dir = {x=0, y=0, z=0},
|
|
||||||
_old_pos = nil,
|
|
||||||
_old_vel = {x=0, y=0, z=0},
|
|
||||||
_old_switch = 0,
|
|
||||||
_railtype = nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
function cart:on_activate(staticdata, dtime_s)
|
function mcl_minecarts.cart:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
||||||
local data = minetest.deserialize(staticdata)
|
local pos = self.object:getpos()
|
||||||
if type(data) == "table" then
|
if not self._railtype then
|
||||||
self._railtype = data._railtype
|
local node = minetest.get_node(vector_floor(pos)).name
|
||||||
end
|
self._railtype = minetest.get_item_group(node, "connect_to_raillike")
|
||||||
self.object:set_armor_groups({immortal=1})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function cart:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
if not puncher or not puncher:is_player() then
|
||||||
local pos = self.object:get_pos()
|
local cart_dir = mcl_minecarts:get_rail_direction(pos, {x=1, y=0, z=0}, nil, nil, self._railtype)
|
||||||
if not self._railtype then
|
|
||||||
local node = minetest.get_node(vector.floor(pos)).name
|
|
||||||
self._railtype = minetest.get_item_group(node, "connect_to_raillike")
|
|
||||||
end
|
|
||||||
|
|
||||||
if not puncher or not puncher:is_player() then
|
|
||||||
local cart_dir = mcl_minecarts:get_rail_direction(pos, {x=1, y=0, z=0}, nil, nil, self._railtype)
|
|
||||||
if vector.equals(cart_dir, {x=0, y=0, z=0}) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self._velocity = vector.multiply(cart_dir, 3)
|
|
||||||
self._old_pos = nil
|
|
||||||
self._punched = true
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if puncher:get_player_control().sneak then
|
|
||||||
if self._driver then
|
|
||||||
if self._old_pos then
|
|
||||||
self.object:set_pos(self._old_pos)
|
|
||||||
end
|
|
||||||
mcl_player.player_attached[self._driver] = nil
|
|
||||||
local player = minetest.get_player_by_name(self._driver)
|
|
||||||
if player then
|
|
||||||
player:set_detach()
|
|
||||||
player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Disable detector rail
|
|
||||||
local rou_pos = vector.round(pos)
|
|
||||||
local node = minetest.get_node(rou_pos)
|
|
||||||
if node.name == "mcl_minecarts:detector_rail_on" then
|
|
||||||
local newnode = {name="mcl_minecarts:detector_rail", param2 = node.param2}
|
|
||||||
minetest.swap_node(rou_pos, newnode)
|
|
||||||
mesecon.receptor_off(rou_pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Drop items and remove cart entity
|
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
|
||||||
for d=1, #drop do
|
|
||||||
minetest.add_item(self.object:get_pos(), drop[d])
|
|
||||||
end
|
|
||||||
elseif puncher and puncher:is_player() then
|
|
||||||
local inv = puncher:get_inventory()
|
|
||||||
for d=1, #drop do
|
|
||||||
if not inv:contains_item("main", drop[d]) then
|
|
||||||
inv:add_item("main", drop[d])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.object:remove()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
if puncher:get_player_name() == self._driver then
|
|
||||||
if math.abs(vel.x + vel.z) > 7 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local punch_dir = mcl_minecarts:velocity_to_dir(puncher:get_look_dir())
|
|
||||||
punch_dir.y = 0
|
|
||||||
local cart_dir = mcl_minecarts:get_rail_direction(pos, punch_dir, nil, nil, self._railtype)
|
|
||||||
if vector.equals(cart_dir, {x=0, y=0, z=0}) then
|
if vector.equals(cart_dir, {x=0, y=0, z=0}) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
self._velocity = vector.multiply(cart_dir, 3)
|
||||||
time_from_last_punch = math.min(time_from_last_punch, tool_capabilities.full_punch_interval)
|
|
||||||
local f = 3 * (time_from_last_punch / tool_capabilities.full_punch_interval)
|
|
||||||
|
|
||||||
self._velocity = vector.multiply(cart_dir, f)
|
|
||||||
self._old_pos = nil
|
self._old_pos = nil
|
||||||
self._punched = true
|
self._punched = true
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function cart:on_step(dtime)
|
if puncher:get_player_control().sneak then
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
local update = {}
|
|
||||||
if self._last_float_check == nil then
|
|
||||||
self._last_float_check = 0
|
|
||||||
else
|
|
||||||
self._last_float_check = self._last_float_check + dtime
|
|
||||||
end
|
|
||||||
local pos, rou_pos, node
|
|
||||||
-- Drop minecart if it isn't on a rail anymore
|
|
||||||
if self._last_float_check >= mcl_minecarts.check_float_time then
|
|
||||||
pos = self.object:get_pos()
|
|
||||||
rou_pos = vector.round(pos)
|
|
||||||
node = minetest.get_node(rou_pos)
|
|
||||||
local g = minetest.get_item_group(node.name, "connect_to_raillike")
|
|
||||||
if g ~= self._railtype and self._railtype ~= nil then
|
|
||||||
-- Detach driver
|
|
||||||
if self._driver then
|
|
||||||
if self._old_pos then
|
|
||||||
self.object:set_pos(self._old_pos)
|
|
||||||
end
|
|
||||||
mcl_player.player_attached[self._driver] = nil
|
|
||||||
local player = minetest.get_player_by_name(self._driver)
|
|
||||||
if player then
|
|
||||||
player:set_detach()
|
|
||||||
player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Drop items and remove cart entity
|
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
|
||||||
for d=1, #drop do
|
|
||||||
minetest.add_item(self.object:get_pos(), drop[d])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.object:remove()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self._last_float_check = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
if self._punched then
|
|
||||||
vel = vector.add(vel, self._velocity)
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
self._old_dir.y = 0
|
|
||||||
elseif vector.equals(vel, {x=0, y=0, z=0}) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local dir, last_switch = nil, nil
|
|
||||||
if not pos then
|
|
||||||
pos = self.object:get_pos()
|
|
||||||
end
|
|
||||||
if self._old_pos and not self._punched then
|
|
||||||
local flo_pos = vector.floor(pos)
|
|
||||||
local flo_old = vector.floor(self._old_pos)
|
|
||||||
if vector.equals(flo_pos, flo_old) then
|
|
||||||
return
|
|
||||||
-- Prevent querying the same node over and over again
|
|
||||||
end
|
|
||||||
|
|
||||||
if not rou_pos then
|
|
||||||
rou_pos = vector.round(pos)
|
|
||||||
end
|
|
||||||
rou_old = vector.round(self._old_pos)
|
|
||||||
if not node then
|
|
||||||
node = minetest.get_node(rou_pos)
|
|
||||||
end
|
|
||||||
local node_old = minetest.get_node(rou_old)
|
|
||||||
|
|
||||||
-- Update detector rails
|
|
||||||
if node.name == "mcl_minecarts:detector_rail" then
|
|
||||||
local newnode = {name="mcl_minecarts:detector_rail_on", param2 = node.param2}
|
|
||||||
minetest.swap_node(rou_pos, newnode)
|
|
||||||
mesecon.receptor_on(rou_pos)
|
|
||||||
end
|
|
||||||
if node_old.name == "mcl_minecarts:detector_rail_on" then
|
|
||||||
local newnode = {name="mcl_minecarts:detector_rail", param2 = node_old.param2}
|
|
||||||
minetest.swap_node(rou_old, newnode)
|
|
||||||
mesecon.receptor_off(rou_old)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local ctrl, player = nil, nil
|
|
||||||
if self._driver then
|
if self._driver then
|
||||||
player = minetest.get_player_by_name(self._driver)
|
if self._old_pos then
|
||||||
|
self.object:setpos(self._old_pos)
|
||||||
|
end
|
||||||
|
mcl_player.player_attached[self._driver] = nil
|
||||||
|
local player = minetest.get_player_by_name(self._driver)
|
||||||
if player then
|
if player then
|
||||||
ctrl = player:get_player_control()
|
player:set_detach()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Stop cart if velocity vector flips
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
if self._old_vel and self._old_vel.y == 0 and
|
minetest.add_item(self.object:getpos(), "mcl_minecarts:minecart")
|
||||||
(self._old_vel.x * vel.x < 0 or self._old_vel.z * vel.z < 0) then
|
end
|
||||||
self._old_vel = {x = 0, y = 0, z = 0}
|
self.object:remove()
|
||||||
self._old_pos = pos
|
return
|
||||||
self.object:set_velocity(vector.new())
|
end
|
||||||
self.object:set_acceleration(vector.new())
|
|
||||||
|
local vel = self.object:getvelocity()
|
||||||
|
if puncher:get_player_name() == self._driver then
|
||||||
|
if math.abs(vel.x + vel.z) > 7 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self._old_vel = vector.new(vel)
|
end
|
||||||
|
|
||||||
if self._old_pos then
|
local punch_dir = mcl_minecarts:velocity_to_dir(puncher:get_look_dir())
|
||||||
local diff = vector.subtract(self._old_pos, pos)
|
punch_dir.y = 0
|
||||||
for _,v in ipairs({"x","y","z"}) do
|
local cart_dir = mcl_minecarts:get_rail_direction(pos, punch_dir, nil, nil, self._railtype)
|
||||||
if math.abs(diff[v]) > 1.1 then
|
if vector.equals(cart_dir, {x=0, y=0, z=0}) then
|
||||||
local expected_pos = vector.add(self._old_pos, self._old_dir)
|
return
|
||||||
dir, last_switch = mcl_minecarts:get_rail_direction(pos, self._old_dir, ctrl, self._old_switch, self._railtype)
|
end
|
||||||
if vector.equals(dir, {x=0, y=0, z=0}) then
|
|
||||||
dir = false
|
time_from_last_punch = math.min(time_from_last_punch, tool_capabilities.full_punch_interval)
|
||||||
pos = vector.new(expected_pos)
|
local f = 3 * (time_from_last_punch / tool_capabilities.full_punch_interval)
|
||||||
update.pos = true
|
|
||||||
end
|
self._velocity = vector.multiply(cart_dir, f)
|
||||||
break
|
self._old_pos = nil
|
||||||
end
|
self._punched = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_minecarts.cart:on_step(dtime)
|
||||||
|
local vel = self.object:getvelocity()
|
||||||
|
local update = {}
|
||||||
|
if self._punched then
|
||||||
|
vel = vector.add(vel, self._velocity)
|
||||||
|
self.object:setvelocity(vel)
|
||||||
|
self._old_dir.y = 0
|
||||||
|
elseif vector.equals(vel, {x=0, y=0, z=0}) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local dir, last_switch = nil, nil
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
if self._old_pos and not self._punched then
|
||||||
|
local flo_pos = vector_floor(pos)
|
||||||
|
local flo_old = vector_floor(self._old_pos)
|
||||||
|
if vector.equals(flo_pos, flo_old) then
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if vel.y == 0 then
|
local ctrl, player = nil, nil
|
||||||
for _,v in ipairs({"x", "z"}) do
|
if self._driver then
|
||||||
if vel[v] ~= 0 and math.abs(vel[v]) < 0.9 then
|
player = minetest.get_player_by_name(self._driver)
|
||||||
vel[v] = 0
|
if player then
|
||||||
update.vel = true
|
ctrl = player:get_player_control()
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
local cart_dir = mcl_minecarts:velocity_to_dir(vel)
|
if self._old_pos then
|
||||||
local max_vel = mcl_minecarts.speed_max
|
local diff = vector.subtract(self._old_pos, pos)
|
||||||
if not dir then
|
|
||||||
dir, last_switch = mcl_minecarts:get_rail_direction(pos, cart_dir, ctrl, self._old_switch, self._railtype)
|
|
||||||
end
|
|
||||||
|
|
||||||
local new_acc = {x=0, y=0, z=0}
|
|
||||||
if vector.equals(dir, {x=0, y=0, z=0}) then
|
|
||||||
vel = {x=0, y=0, z=0}
|
|
||||||
update.vel = true
|
|
||||||
else
|
|
||||||
-- If the direction changed
|
|
||||||
if dir.x ~= 0 and self._old_dir.z ~= 0 then
|
|
||||||
vel.x = dir.x * math.abs(vel.z)
|
|
||||||
vel.z = 0
|
|
||||||
pos.z = math.floor(pos.z + 0.5)
|
|
||||||
update.pos = true
|
|
||||||
end
|
|
||||||
if dir.z ~= 0 and self._old_dir.x ~= 0 then
|
|
||||||
vel.z = dir.z * math.abs(vel.x)
|
|
||||||
vel.x = 0
|
|
||||||
pos.x = math.floor(pos.x + 0.5)
|
|
||||||
update.pos = true
|
|
||||||
end
|
|
||||||
-- Up, down?
|
|
||||||
if dir.y ~= self._old_dir.y then
|
|
||||||
vel.y = dir.y * math.abs(vel.x + vel.z)
|
|
||||||
pos = vector.round(pos)
|
|
||||||
update.pos = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Slow down or speed up
|
|
||||||
local acc = dir.y * -1.8
|
|
||||||
|
|
||||||
local speed_mod = minetest.registered_nodes[minetest.get_node(pos).name]._rail_acceleration
|
|
||||||
if speed_mod and speed_mod ~= 0 then
|
|
||||||
acc = acc + speed_mod
|
|
||||||
else
|
|
||||||
acc = acc - 0.4
|
|
||||||
end
|
|
||||||
|
|
||||||
new_acc = vector.multiply(dir, acc)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.object:set_acceleration(new_acc)
|
|
||||||
self._old_pos = vector.new(pos)
|
|
||||||
self._old_dir = vector.new(dir)
|
|
||||||
self._old_switch = last_switch
|
|
||||||
|
|
||||||
-- Limits
|
|
||||||
for _,v in ipairs({"x","y","z"}) do
|
for _,v in ipairs({"x","y","z"}) do
|
||||||
if math.abs(vel[v]) > max_vel then
|
if math.abs(diff[v]) > 1.1 then
|
||||||
vel[v] = mcl_minecarts:get_sign(vel[v]) * max_vel
|
local expected_pos = vector.add(self._old_pos, self._old_dir)
|
||||||
new_acc[v] = 0
|
dir, last_switch = mcl_minecarts:get_rail_direction(pos, self._old_dir, ctrl, self._old_switch, self._railtype)
|
||||||
|
if vector.equals(dir, {x=0, y=0, z=0}) then
|
||||||
|
dir = false
|
||||||
|
pos = vector.new(expected_pos)
|
||||||
|
update.pos = true
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if vel.y == 0 then
|
||||||
|
for _,v in ipairs({"x", "z"}) do
|
||||||
|
if vel[v] ~= 0 and math.abs(vel[v]) < 0.9 then
|
||||||
|
vel[v] = 0
|
||||||
update.vel = true
|
update.vel = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Give achievement when player reached a distance of 1000 nodes from the start position
|
|
||||||
if self._driver and (vector.distance(self._start_pos, pos) >= 1000) then
|
|
||||||
awards.unlock(self._driver, "mcl:onARail")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if update.pos or self._punched then
|
|
||||||
local yaw = 0
|
|
||||||
if dir.x < 0 then
|
|
||||||
yaw = 0.5
|
|
||||||
elseif dir.x > 0 then
|
|
||||||
yaw = 1.5
|
|
||||||
elseif dir.z < 0 then
|
|
||||||
yaw = 1
|
|
||||||
end
|
|
||||||
self.object:set_yaw(yaw * math.pi)
|
|
||||||
end
|
|
||||||
|
|
||||||
if self._punched then
|
|
||||||
self._punched = false
|
|
||||||
end
|
|
||||||
|
|
||||||
if not (update.vel or update.pos) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local anim = {x=0, y=0}
|
|
||||||
if dir.y == -1 then
|
|
||||||
anim = {x=1, y=1}
|
|
||||||
elseif dir.y == 1 then
|
|
||||||
anim = {x=2, y=2}
|
|
||||||
end
|
|
||||||
self.object:set_animation(anim, 1, 0)
|
|
||||||
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
if update.pos then
|
|
||||||
self.object:set_pos(pos)
|
|
||||||
end
|
|
||||||
update = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function cart:get_staticdata()
|
local cart_dir = mcl_minecarts:velocity_to_dir(vel)
|
||||||
return minetest.serialize({_railtype = self._railtype})
|
local max_vel = mcl_minecarts.speed_max
|
||||||
|
if not dir then
|
||||||
|
dir, last_switch = mcl_minecarts:get_rail_direction(pos, cart_dir, ctrl, self._old_switch, self._railtype)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity(entity_id, cart)
|
local new_acc = {x=0, y=0, z=0}
|
||||||
end
|
if vector.equals(dir, {x=0, y=0, z=0}) then
|
||||||
|
vel = {x=0, y=0, z=0}
|
||||||
-- Place a minecart at pointed_thing
|
update.vel = true
|
||||||
mcl_minecarts.place_minecart = function(itemstack, pointed_thing)
|
|
||||||
if not pointed_thing.type == "node" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local railpos, node
|
|
||||||
if mcl_minecarts:is_rail(pointed_thing.under) then
|
|
||||||
railpos = pointed_thing.under
|
|
||||||
node = minetest.get_node(pointed_thing.under)
|
|
||||||
elseif mcl_minecarts:is_rail(pointed_thing.above) then
|
|
||||||
railpos = pointed_thing.above
|
|
||||||
node = minetest.get_node(pointed_thing.above)
|
|
||||||
else
|
else
|
||||||
|
-- If the direction changed
|
||||||
|
if dir.x ~= 0 and self._old_dir.z ~= 0 then
|
||||||
|
vel.x = dir.x * math.abs(vel.z)
|
||||||
|
vel.z = 0
|
||||||
|
pos.z = math.floor(pos.z + 0.5)
|
||||||
|
update.pos = true
|
||||||
|
end
|
||||||
|
if dir.z ~= 0 and self._old_dir.x ~= 0 then
|
||||||
|
vel.z = dir.z * math.abs(vel.x)
|
||||||
|
vel.x = 0
|
||||||
|
pos.x = math.floor(pos.x + 0.5)
|
||||||
|
update.pos = true
|
||||||
|
end
|
||||||
|
-- Up, down?
|
||||||
|
if dir.y ~= self._old_dir.y then
|
||||||
|
vel.y = dir.y * math.abs(vel.x + vel.z)
|
||||||
|
pos = vector.round(pos)
|
||||||
|
update.pos = true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Slow down or speed up..
|
||||||
|
local acc = dir.y * -1.8
|
||||||
|
|
||||||
|
local speed_mod = tonumber(minetest.get_meta(pos):get_string("cart_acceleration"))
|
||||||
|
if speed_mod and speed_mod ~= 0 then
|
||||||
|
if speed_mod > 0 then
|
||||||
|
for _,v in ipairs({"x","y","z"}) do
|
||||||
|
if math.abs(vel[v]) >= max_vel then
|
||||||
|
speed_mod = 0
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
acc = acc + (speed_mod * 8)
|
||||||
|
else
|
||||||
|
acc = acc - 0.4
|
||||||
|
end
|
||||||
|
|
||||||
|
new_acc = vector.multiply(dir, acc)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.object:setacceleration(new_acc)
|
||||||
|
self._old_pos = vector.new(pos)
|
||||||
|
self._old_dir = vector.new(dir)
|
||||||
|
self._old_switch = last_switch
|
||||||
|
|
||||||
|
-- Limits
|
||||||
|
for _,v in ipairs({"x","y","z"}) do
|
||||||
|
if math.abs(vel[v]) > max_vel then
|
||||||
|
vel[v] = mcl_minecarts:get_sign(vel[v]) * max_vel
|
||||||
|
update.vel = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Give achievement when player reached a distance of 1000 nodes from the start position
|
||||||
|
if self._driver and (vector.distance(self._start_pos, pos) >= 1000) then
|
||||||
|
awards.unlock(self._driver, "mcl:onARail")
|
||||||
|
end
|
||||||
|
|
||||||
|
if update.pos or self._punched then
|
||||||
|
local yaw = 0
|
||||||
|
if dir.x < 0 then
|
||||||
|
yaw = 0.5
|
||||||
|
elseif dir.x > 0 then
|
||||||
|
yaw = 1.5
|
||||||
|
elseif dir.z < 0 then
|
||||||
|
yaw = 1
|
||||||
|
end
|
||||||
|
self.object:setyaw(yaw * math.pi)
|
||||||
|
end
|
||||||
|
|
||||||
|
if self._punched then
|
||||||
|
self._punched = false
|
||||||
|
end
|
||||||
|
|
||||||
|
if not (update.vel or update.pos) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Activate detector rail
|
|
||||||
if node.name == "mcl_minecarts:detector_rail" then
|
|
||||||
local newnode = {name="mcl_minecarts:detector_rail_on", param2 = node.param2}
|
|
||||||
minetest.swap_node(railpos, newnode)
|
|
||||||
mesecon.receptor_on(railpos)
|
|
||||||
end
|
|
||||||
|
|
||||||
local entity_id = entity_mapping[itemstack:get_name()]
|
local anim = {x=0, y=0}
|
||||||
local cart = minetest.add_entity(railpos, entity_id)
|
if dir.y == -1 then
|
||||||
local railtype = minetest.get_item_group(node.name, "connect_to_raillike")
|
anim = {x=1, y=1}
|
||||||
local le = cart:get_luaentity()
|
elseif dir.y == 1 then
|
||||||
if le ~= nil then
|
anim = {x=2, y=2}
|
||||||
le._railtype = railtype
|
|
||||||
end
|
end
|
||||||
local cart_dir = mcl_minecarts:get_rail_direction(railpos, {x=1, y=0, z=0}, nil, nil, railtype)
|
self.object:set_animation(anim, 1, 0)
|
||||||
cart:set_yaw(minetest.dir_to_yaw(cart_dir))
|
|
||||||
|
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
self.object:setvelocity(vel)
|
||||||
itemstack:take_item()
|
if update.pos then
|
||||||
|
self.object:setpos(pos)
|
||||||
end
|
end
|
||||||
return itemstack
|
update = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_entity("mcl_minecarts:minecart", mcl_minecarts.cart)
|
||||||
|
minetest.register_craftitem("mcl_minecarts:minecart", {
|
||||||
|
description = "Minecart",
|
||||||
|
_doc_items_longdesc = "Minecarts can be used for a quick transportion on rails." .. "\n" ..
|
||||||
|
"Minecarts only ride on rails and always follow the tracks. At a T-junction with no straight way ahead, they turn left. The speed is affected by the rail type.",
|
||||||
|
_doc_items_usagehelp = "You can place the minecart on rails. Right-click it to enter it. Punch it to get it moving." .. "\n" ..
|
||||||
|
"To obtain the minecart, punch it while holding down the sneak key.",
|
||||||
|
|
||||||
local register_craftitem = function(itemstring, entity_id, description, longdesc, usagehelp, icon, creative)
|
inventory_image = "mcl_minecarts_minecart_normal.png",
|
||||||
entity_mapping[itemstring] = entity_id
|
wield_image = "mcl_minecarts_minecart_normal.png",
|
||||||
|
stack_max = 1,
|
||||||
local groups = { minecart = 1, transport = 1 }
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if creative == false then
|
if not pointed_thing.type == "node" then
|
||||||
groups.not_in_creative_inventory = 1
|
|
||||||
end
|
|
||||||
local def = {
|
|
||||||
stack_max = 1,
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
|
||||||
if not pointed_thing.type == "node" then
|
|
||||||
return
|
|
||||||
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
|
|
||||||
|
|
||||||
return mcl_minecarts.place_minecart(itemstack, pointed_thing)
|
|
||||||
end,
|
|
||||||
_on_dispense = function(stack, pos, droppos, dropnode, dropdir)
|
|
||||||
-- Place minecart as entity on rail. If there's no rail, just drop it.
|
|
||||||
local placed
|
|
||||||
if minetest.get_item_group(dropnode.name, "rail") ~= 0 then
|
|
||||||
-- FIXME: This places minecarts even if the spot is already occupied
|
|
||||||
local pointed_thing = { under = droppos, above = { x=droppos.x, y=droppos.y+1, z=droppos.z } }
|
|
||||||
placed = mcl_minecarts.place_minecart(stack, pointed_thing)
|
|
||||||
end
|
|
||||||
if placed == nil then
|
|
||||||
-- Drop item
|
|
||||||
minetest.add_item(droppos, stack)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
groups = groups,
|
|
||||||
}
|
|
||||||
def.description = description
|
|
||||||
def._doc_items_longdesc = longdesc
|
|
||||||
def._doc_items_usagehelp = usagehelp
|
|
||||||
def.inventory_image = icon
|
|
||||||
def.wield_image = icon
|
|
||||||
minetest.register_craftitem(itemstring, def)
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
|
||||||
Register a minecart
|
|
||||||
* itemstring: Itemstring of minecart item
|
|
||||||
* entity_id: ID of minecart entity
|
|
||||||
* description: Item name / description
|
|
||||||
* longdesc: Long help text
|
|
||||||
* usagehelp: Usage help text
|
|
||||||
* mesh: Minecart mesh
|
|
||||||
* textures: Minecart textures table
|
|
||||||
* icon: Item icon
|
|
||||||
* drop: Dropped items after destroying minecart
|
|
||||||
* on_rightclick: Called after rightclick
|
|
||||||
* on_activate_by_rail: Called when above activator rail
|
|
||||||
* creative: If false, don't show in Creative Inventory
|
|
||||||
]]
|
|
||||||
local function register_minecart(itemstring, entity_id, description, longdesc, usagehelp, mesh, textures, icon, drop, on_rightclick, on_activate_by_rail, creative)
|
|
||||||
register_entity(entity_id, mesh, textures, drop, on_rightclick)
|
|
||||||
register_craftitem(itemstring, entity_id, description, longdesc, usagehelp, icon, creative)
|
|
||||||
if minetest.get_modpath("doc_identifier") ~= nil then
|
|
||||||
doc.sub.identifier.register_object(entity_id, "craftitems", itemstring)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Minecart
|
|
||||||
register_minecart(
|
|
||||||
"mcl_minecarts:minecart",
|
|
||||||
"mcl_minecarts:minecart",
|
|
||||||
S("Minecart"),
|
|
||||||
S("Minecarts can be used for a quick transportion on rails.") .. "\n" ..
|
|
||||||
S("Minecarts only ride on rails and always follow the tracks. At a T-junction with no straight way ahead, they turn left. The speed is affected by the rail type."),
|
|
||||||
S("You can place the minecart on rails. Right-click it to enter it. Punch it to get it moving.") .. "\n" ..
|
|
||||||
S("To obtain the minecart, punch it while holding down the sneak key."),
|
|
||||||
"mcl_minecarts_minecart.b3d",
|
|
||||||
{"mcl_minecarts_minecart.png"},
|
|
||||||
"mcl_minecarts_minecart_normal.png",
|
|
||||||
{"mcl_minecarts:minecart"},
|
|
||||||
function(self, clicker)
|
|
||||||
local name = clicker:get_player_name()
|
|
||||||
if not clicker or not clicker:is_player() then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local player_name = clicker:get_player_name()
|
|
||||||
if self._driver and player_name == self._driver then
|
-- Call on_rightclick if the pointed node defines it
|
||||||
self._driver = nil
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
self._start_pos = nil
|
if placer and not placer:get_player_control().sneak then
|
||||||
clicker:set_detach()
|
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||||
clicker:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0})
|
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
||||||
elseif not self._driver then
|
end
|
||||||
self._driver = player_name
|
|
||||||
self._start_pos = self.object:get_pos()
|
|
||||||
mcl_player.player_attached[player_name] = true
|
|
||||||
clicker:set_attach(self.object, "", {x=0, y=-1.75, z=-2}, {x=0, y=0, z=0})
|
|
||||||
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)
|
|
||||||
player:set_eye_offset({x=0, y=-5.5, z=0},{x=0, y=-4, z=0})
|
|
||||||
end
|
|
||||||
end, name)
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Minecart with Chest
|
local railpos
|
||||||
register_minecart(
|
if mcl_minecarts:is_rail(pointed_thing.under) then
|
||||||
"mcl_minecarts:chest_minecart",
|
railpos = pointed_thing.under
|
||||||
"mcl_minecarts:chest_minecart",
|
elseif mcl_minecarts:is_rail(pointed_thing.above) then
|
||||||
S("Minecart with Chest"),
|
railpos = pointed_thing.under
|
||||||
nil, nil,
|
else
|
||||||
"mcl_minecarts_minecart_chest.b3d",
|
|
||||||
{ "mcl_chests_normal.png", "mcl_minecarts_minecart.png" },
|
|
||||||
"mcl_minecarts_minecart_chest.png",
|
|
||||||
{"mcl_minecarts:minecart", "mcl_chests:chest"},
|
|
||||||
nil, nil, false)
|
|
||||||
|
|
||||||
-- Minecart with Furnace
|
|
||||||
register_minecart(
|
|
||||||
"mcl_minecarts:furnace_minecart",
|
|
||||||
"mcl_minecarts:furnace_minecart",
|
|
||||||
S("Minecart with Furnace"),
|
|
||||||
nil, nil,
|
|
||||||
"mcl_minecarts_minecart_block.b3d",
|
|
||||||
{
|
|
||||||
"default_furnace_top.png",
|
|
||||||
"default_furnace_top.png",
|
|
||||||
"default_furnace_front.png",
|
|
||||||
"default_furnace_side.png",
|
|
||||||
"default_furnace_side.png",
|
|
||||||
"default_furnace_side.png",
|
|
||||||
"mcl_minecarts_minecart.png",
|
|
||||||
},
|
|
||||||
"mcl_minecarts_minecart_furnace.png",
|
|
||||||
{"mcl_minecarts:minecart", "mcl_furnaces:furnace"},
|
|
||||||
-- Feed furnace with coal
|
|
||||||
function(self, clicker)
|
|
||||||
if not clicker or not clicker:is_player() then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not self._fueltime then
|
local cart = minetest.add_entity(railpos, "mcl_minecarts:minecart")
|
||||||
self._fueltime = 0
|
local railtype = minetest.get_item_group(node.name, "connect_to_raillike")
|
||||||
|
local cart_dir = mcl_minecarts:get_rail_direction(railpos, {x=1, y=0, z=0}, nil, nil, railtype)
|
||||||
|
cart:setyaw(minetest.dir_to_yaw(cart_dir))
|
||||||
|
|
||||||
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
local held = clicker:get_wielded_item()
|
return itemstack
|
||||||
if minetest.get_item_group(held:get_name(), "coal") == 1 then
|
end,
|
||||||
self._fueltime = self._fueltime + 180
|
groups = { minecart = 1, transport = 1},
|
||||||
|
})
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
|
||||||
held:take_item()
|
|
||||||
local index = clicker:get_wielded_index()
|
|
||||||
local inv = clicker:get_inventory()
|
|
||||||
inv:set_stack("main", index, held)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- DEBUG
|
|
||||||
minetest.chat_send_player(clicker:get_player_name(), "Fuel: " .. tostring(self._fueltime))
|
|
||||||
end
|
|
||||||
end, nil, false
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Minecart with Command Block
|
|
||||||
register_minecart(
|
|
||||||
"mcl_minecarts:command_block_minecart",
|
|
||||||
"mcl_minecarts:command_block_minecart",
|
|
||||||
S("Minecart with Command Block"),
|
|
||||||
nil, nil,
|
|
||||||
"mcl_minecarts_minecart_block.b3d",
|
|
||||||
{
|
|
||||||
"jeija_commandblock_off.png^[verticalframe:2:0",
|
|
||||||
"jeija_commandblock_off.png^[verticalframe:2:0",
|
|
||||||
"jeija_commandblock_off.png^[verticalframe:2:0",
|
|
||||||
"jeija_commandblock_off.png^[verticalframe:2:0",
|
|
||||||
"jeija_commandblock_off.png^[verticalframe:2:0",
|
|
||||||
"jeija_commandblock_off.png^[verticalframe:2:0",
|
|
||||||
"mcl_minecarts_minecart.png",
|
|
||||||
},
|
|
||||||
"mcl_minecarts_minecart_command_block.png",
|
|
||||||
{"mcl_minecarts:minecart"},
|
|
||||||
nil, nil, false
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Minecart with Hopper
|
|
||||||
register_minecart(
|
|
||||||
"mcl_minecarts:hopper_minecart",
|
|
||||||
"mcl_minecarts:hopper_minecart",
|
|
||||||
S("Minecart with Hopper"),
|
|
||||||
nil, nil,
|
|
||||||
"mcl_minecarts_minecart_hopper.b3d",
|
|
||||||
{
|
|
||||||
"mcl_hoppers_hopper_inside.png",
|
|
||||||
"mcl_minecarts_minecart.png",
|
|
||||||
"mcl_hoppers_hopper_outside.png",
|
|
||||||
"mcl_hoppers_hopper_top.png",
|
|
||||||
},
|
|
||||||
"mcl_minecarts_minecart_hopper.png",
|
|
||||||
{"mcl_minecarts:minecart", "mcl_hoppers:hopper"},
|
|
||||||
nil, nil, false
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Minecart with TNT
|
|
||||||
register_minecart(
|
|
||||||
"mcl_minecarts:tnt_minecart",
|
|
||||||
"mcl_minecarts:tnt_minecart",
|
|
||||||
S("Minecart with TNT"),
|
|
||||||
nil, nil,
|
|
||||||
"mcl_minecarts_minecart_block.b3d",
|
|
||||||
{
|
|
||||||
"default_tnt_top.png",
|
|
||||||
"default_tnt_bottom.png",
|
|
||||||
"default_tnt_side.png",
|
|
||||||
"default_tnt_side.png",
|
|
||||||
"default_tnt_side.png",
|
|
||||||
"default_tnt_side.png",
|
|
||||||
"mcl_minecarts_minecart.png",
|
|
||||||
},
|
|
||||||
"mcl_minecarts_minecart_tnt.png",
|
|
||||||
{"mcl_minecarts:minecart", "mcl_tnt:tnt"},
|
|
||||||
nil, nil, false
|
|
||||||
)
|
|
||||||
|
|
||||||
|
if minetest.get_modpath("doc_identifier") ~= nil then
|
||||||
|
doc.sub.identifier.register_object("mcl_minecarts:minecart", "craftitems", "mcl_minecarts:minecart")
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mcl_minecarts:minecart",
|
output = "mcl_minecarts:minecart",
|
||||||
|
@ -632,38 +326,3 @@ minetest.register_craft({
|
||||||
{"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
|
{"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- TODO: Re-enable crafting of special minecarts when they have been implemented
|
|
||||||
if false then
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "mcl_minecarts:hopper_minecart",
|
|
||||||
recipe = {
|
|
||||||
{"mcl_hoppers:hopper"},
|
|
||||||
{"mcl_minecarts:minecart"},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "mcl_minecarts:chest_minecart",
|
|
||||||
recipe = {
|
|
||||||
{"mcl_chests:chest"},
|
|
||||||
{"mcl_minecarts:minecart"},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "mcl_minecarts:tnt_minecart",
|
|
||||||
recipe = {
|
|
||||||
{"mcl_tnt:tnt"},
|
|
||||||
{"mcl_minecarts:minecart"},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "mcl_minecarts:furnace_minecart",
|
|
||||||
recipe = {
|
|
||||||
{"mcl_furnaces:furnace"},
|
|
||||||
{"mcl_minecarts:minecart"},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,194 +1,29 @@
|
||||||
local S = minetest.get_translator("mcl_minecarts")
|
local railuse = "Place them on the ground to build your railway, the rails will automatically connect to each other and will turn into curves, T-junctions, crossings and slopes as needed."
|
||||||
|
|
||||||
-- Template rail function
|
|
||||||
local register_rail = function(itemstring, tiles, def_extras, creative)
|
|
||||||
local groups = {handy=1,pickaxey=1, attached_node=1,rail=1,connect_to_raillike=1,dig_by_water=1,destroy_by_lava_flow=1, transport=1}
|
|
||||||
if creative == false then
|
|
||||||
groups.not_in_creative_inventory = 1
|
|
||||||
end
|
|
||||||
local ndef = {
|
|
||||||
drawtype = "raillike",
|
|
||||||
tiles = tiles,
|
|
||||||
is_ground_content = false,
|
|
||||||
inventory_image = tiles[1],
|
|
||||||
wield_image = tiles[1],
|
|
||||||
paramtype = "light",
|
|
||||||
walkable = false,
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
stack_max = 64,
|
|
||||||
groups = groups,
|
|
||||||
sounds = mcl_sounds.node_sound_metal_defaults(),
|
|
||||||
_mcl_blast_resistance = 3.5,
|
|
||||||
_mcl_hardness = 0.7,
|
|
||||||
after_destruct = function(pos)
|
|
||||||
-- Scan for minecarts in this pos and force them to execute their "floating" check.
|
|
||||||
-- Normally, this will make them drop.
|
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 1)
|
|
||||||
for o=1, #objs do
|
|
||||||
local le = objs[o]:get_luaentity()
|
|
||||||
if le then
|
|
||||||
-- All entities in this mod are minecarts, so this works
|
|
||||||
if string.sub(le.name, 1, 14) == "mcl_minecarts:" then
|
|
||||||
le._last_float_check = mcl_minecarts.check_float_time
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
if def_extras then
|
|
||||||
for k,v in pairs(def_extras) do
|
|
||||||
ndef[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
minetest.register_node(itemstring, ndef)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Redstone rules
|
|
||||||
local rail_rules_long =
|
|
||||||
{{x=-1, y= 0, z= 0, spread=true},
|
|
||||||
{x= 1, y= 0, z= 0, spread=true},
|
|
||||||
{x= 0, y=-1, z= 0, spread=true},
|
|
||||||
{x= 0, y= 1, z= 0, spread=true},
|
|
||||||
{x= 0, y= 0, z=-1, spread=true},
|
|
||||||
{x= 0, y= 0, z= 1, spread=true},
|
|
||||||
|
|
||||||
{x= 1, y= 1, z= 0},
|
|
||||||
{x= 1, y=-1, z= 0},
|
|
||||||
{x=-1, y= 1, z= 0},
|
|
||||||
{x=-1, y=-1, z= 0},
|
|
||||||
{x= 0, y= 1, z= 1},
|
|
||||||
{x= 0, y=-1, z= 1},
|
|
||||||
{x= 0, y= 1, z=-1},
|
|
||||||
{x= 0, y=-1, z=-1}}
|
|
||||||
|
|
||||||
local rail_rules_short = mesecon.rules.pplate
|
|
||||||
|
|
||||||
local railuse = S("Place them on the ground to build your railway, the rails will automatically connect to each other and will turn into curves, T-junctions, crossings and slopes as needed.")
|
|
||||||
|
|
||||||
-- Normal rail
|
-- Normal rail
|
||||||
register_rail("mcl_minecarts:rail",
|
minetest.register_node("mcl_minecarts:rail", {
|
||||||
{"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
|
description = "Rail",
|
||||||
{
|
_doc_items_longdesc = "Rails can be used to build transport tracks for minecarts. Normal rails slightly slow down minecarts due to friction.",
|
||||||
description = S("Rail"),
|
_doc_items_usagehelp = railuse,
|
||||||
_doc_items_longdesc = S("Rails can be used to build transport tracks for minecarts. Normal rails slightly slow down minecarts due to friction."),
|
drawtype = "raillike",
|
||||||
_doc_items_usagehelp = railuse,
|
tiles = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
|
||||||
}
|
is_ground_content = false,
|
||||||
)
|
inventory_image = "default_rail.png",
|
||||||
|
wield_image = "default_rail.png",
|
||||||
-- Powered rail (off = brake mode)
|
paramtype = "light",
|
||||||
register_rail("mcl_minecarts:golden_rail",
|
walkable = false,
|
||||||
{"mcl_minecarts_rail_golden.png", "mcl_minecarts_rail_golden_curved.png", "mcl_minecarts_rail_golden_t_junction.png", "mcl_minecarts_rail_golden_crossing.png"},
|
selection_box = {
|
||||||
{
|
type = "fixed",
|
||||||
description = S("Powered Rail"),
|
-- but how to specify the dimensions for curved and sideways rails?
|
||||||
_doc_items_longdesc = S("Rails can be used to build transport tracks for minecarts. Powered rails are able to accelerate and brake minecarts."),
|
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||||
_doc_items_usagehelp = railuse .. "\n" .. S("Without redstone power, the rail will brake minecarts. To make this rail accelerate minecarts, power it with redstone power."),
|
|
||||||
_rail_acceleration = -3,
|
|
||||||
mesecons = {
|
|
||||||
conductor = {
|
|
||||||
state = mesecon.state.off,
|
|
||||||
offstate = "mcl_minecarts:golden_rail",
|
|
||||||
onstate = "mcl_minecarts:golden_rail_on",
|
|
||||||
rules = rail_rules_long,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Powered rail (on = acceleration mode)
|
|
||||||
register_rail("mcl_minecarts:golden_rail_on",
|
|
||||||
{"mcl_minecarts_rail_golden_powered.png", "mcl_minecarts_rail_golden_curved_powered.png", "mcl_minecarts_rail_golden_t_junction_powered.png", "mcl_minecarts_rail_golden_crossing_powered.png"},
|
|
||||||
{
|
|
||||||
_doc_items_create_entry = false,
|
|
||||||
_rail_acceleration = 4,
|
|
||||||
mesecons = {
|
|
||||||
conductor = {
|
|
||||||
state = mesecon.state.on,
|
|
||||||
offstate = "mcl_minecarts:golden_rail",
|
|
||||||
onstate = "mcl_minecarts:golden_rail_on",
|
|
||||||
rules = rail_rules_long,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
drop = "mcl_minecarts:golden_rail",
|
|
||||||
},
|
},
|
||||||
false
|
stack_max = 64,
|
||||||
)
|
groups = {handy=1,pickaxey=1, attached_node=1,rail=1,connect_to_raillike=1,dig_by_water=1,destroy_by_lava_flow=1,transport=1},
|
||||||
|
sounds = mcl_sounds.node_sound_metal_defaults(),
|
||||||
|
_mcl_blast_resistance = 3.5,
|
||||||
|
_mcl_hardness = 0.7,
|
||||||
|
})
|
||||||
|
|
||||||
-- Activator rail (off)
|
|
||||||
register_rail("mcl_minecarts:activator_rail",
|
|
||||||
{"mcl_minecarts_rail_activator.png", "mcl_minecarts_rail_activator_curved.png", "mcl_minecarts_rail_activator_t_junction.png", "mcl_minecarts_rail_activator_crossing.png"},
|
|
||||||
{
|
|
||||||
description = S("Activator Rail"),
|
|
||||||
_doc_items_longdesc = S("Rails can be used to build transport tracks for minecarts. Activator rails are used to activate special minecarts."),
|
|
||||||
_doc_items_usagehelp = railuse .. "\n" .. S("To make this rail activate minecarts, power it with redstone power and send a minecart over this piece of rail."),
|
|
||||||
mesecons = {
|
|
||||||
conductor = {
|
|
||||||
state = mesecon.state.off,
|
|
||||||
offstate = "mcl_minecarts:activator_rail",
|
|
||||||
onstate = "mcl_minecarts:activator_rail_on",
|
|
||||||
rules = rail_rules_long,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- Hidden from creative because no cart is using this rail so far.
|
|
||||||
-- TODO: Remove this when the activator rail has become useful.
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Activator rail (on)
|
|
||||||
register_rail("mcl_minecarts:activator_rail_on",
|
|
||||||
{"mcl_minecarts_rail_activator_powered.png", "mcl_minecarts_rail_activator_curved_powered.png", "mcl_minecarts_rail_activator_t_junction_powered.png", "mcl_minecarts_rail_activator_crossing_powered.png"},
|
|
||||||
{
|
|
||||||
_doc_items_create_entry = false,
|
|
||||||
mesecons = {
|
|
||||||
conductor = {
|
|
||||||
state = mesecon.state.on,
|
|
||||||
offstate = "mcl_minecarts:activator_rail",
|
|
||||||
onstate = "mcl_minecarts:activator_rail_on",
|
|
||||||
rules = rail_rules_long,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
drop = "mcl_minecarts:activator_rail",
|
|
||||||
},
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Detector rail (off)
|
|
||||||
register_rail("mcl_minecarts:detector_rail",
|
|
||||||
{"mcl_minecarts_rail_detector.png", "mcl_minecarts_rail_detector_curved.png", "mcl_minecarts_rail_detector_t_junction.png", "mcl_minecarts_rail_detector_crossing.png"},
|
|
||||||
{
|
|
||||||
description = S("Detector Rail"),
|
|
||||||
_doc_items_longdesc = S("Rails can be used to build transport tracks for minecarts. A detector rail is able to detect a minecart above it and powers redstone mechanisms."),
|
|
||||||
_doc_items_usagehelp = railuse .. "\n" .. S("To detect a minecart and provide redstone power, connect it to redstone trails or redstone mechanisms and send any minecart over the rail."),
|
|
||||||
mesecons = {
|
|
||||||
receptor = {
|
|
||||||
state = mesecon.state.off,
|
|
||||||
rules = rail_rules_short,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Detector rail (on)
|
|
||||||
register_rail("mcl_minecarts:detector_rail_on",
|
|
||||||
{"mcl_minecarts_rail_detector_powered.png", "mcl_minecarts_rail_detector_curved_powered.png", "mcl_minecarts_rail_detector_t_junction_powered.png", "mcl_minecarts_rail_detector_crossing_powered.png"},
|
|
||||||
{
|
|
||||||
_doc_items_create_entry = false,
|
|
||||||
mesecons = {
|
|
||||||
receptor = {
|
|
||||||
state = mesecon.state.on,
|
|
||||||
rules = rail_rules_short,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
drop = "mcl_minecarts:detector_rail",
|
|
||||||
},
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
-- Crafting
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'mcl_minecarts:rail 16',
|
output = 'mcl_minecarts:rail 16',
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -198,6 +33,46 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Rail to speed up
|
||||||
|
minetest.register_node("mcl_minecarts:golden_rail", {
|
||||||
|
description = "Powered Rail",
|
||||||
|
_doc_items_longdesc = "Rails can be used to build transport tracks for minecarts. Powered rails will accelerate moving minecarts, up to a maximum speed.",
|
||||||
|
_doc_items_usagehelp = railuse,
|
||||||
|
drawtype = "raillike",
|
||||||
|
tiles = {"carts_rail_pwr.png", "carts_rail_curved_pwr.png", "carts_rail_t_junction_pwr.png", "carts_rail_crossing_pwr.png"},
|
||||||
|
inventory_image = "carts_rail_pwr.png",
|
||||||
|
wield_image = "carts_rail_pwr.png",
|
||||||
|
paramtype = "light",
|
||||||
|
is_ground_content = false,
|
||||||
|
walkable = false,
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
-- but how to specify the dimensions for curved and sideways rails?
|
||||||
|
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||||
|
},
|
||||||
|
groups = {handy=1,pickaxey=1, attached_node = 1, rail = 1, connect_to_raillike = 1, dig_by_water = 1,destroy_by_lava_flow=1, transport = 1},
|
||||||
|
|
||||||
|
after_place_node = function(pos, placer, itemstack)
|
||||||
|
if not mesecon then
|
||||||
|
minetest.get_meta(pos):set_string("cart_acceleration", "0.5")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
sounds = mcl_sounds.node_sound_metal_defaults(),
|
||||||
|
mesecons = {
|
||||||
|
effector = {
|
||||||
|
action_on = function(pos, node)
|
||||||
|
mcl_minecarts:boost_rail(pos, 0.5)
|
||||||
|
end,
|
||||||
|
|
||||||
|
action_off = function(pos, node)
|
||||||
|
minetest.get_meta(pos):set_string("cart_acceleration", "0")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
_mcl_blast_resistance = 3.5,
|
||||||
|
_mcl_hardness = 0.7,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mcl_minecarts:golden_rail 6",
|
output = "mcl_minecarts:golden_rail 6",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -207,31 +82,3 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Activator rail crafting is disabled until it becomes useful.
|
|
||||||
-- TODO: Enable crafting as needed.
|
|
||||||
if false then
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "mcl_minecarts:activator_rail 6",
|
|
||||||
recipe = {
|
|
||||||
{"mcl_core:iron_ingot", "mcl_core:stick", "mcl_core:iron_ingot"},
|
|
||||||
{"mcl_core:iron_ingot", "mesecons_torch:mesecon_torch_on", "mcl_core:iron_ingot"},
|
|
||||||
{"mcl_core:iron_ingot", "mcl_core:stick", "mcl_core:iron_ingot"},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "mcl_minecarts:detector_rail 6",
|
|
||||||
recipe = {
|
|
||||||
{"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
|
|
||||||
{"mcl_core:iron_ingot", "mesecons_pressureplates:pressure_plate_stone_off", "mcl_core:iron_ingot"},
|
|
||||||
{"mcl_core:iron_ingot", "mesecons:redstone", "mcl_core:iron_ingot"},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
-- Aliases
|
|
||||||
if minetest.get_modpath("doc") then
|
|
||||||
doc.add_entry_alias("nodes", "mcl_minecarts:golden_rail", "nodes", "mcl_minecarts:golden_rail_on")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
After Width: | Height: | Size: 562 B |
After Width: | Height: | Size: 459 B |
After Width: | Height: | Size: 276 B |
After Width: | Height: | Size: 596 B |
Before Width: | Height: | Size: 247 B After Width: | Height: | Size: 542 B |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 576 B |
Before Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 249 B |
Before Width: | Height: | Size: 285 B |
Before Width: | Height: | Size: 254 B |
Before Width: | Height: | Size: 254 B |
Before Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 281 B |
Before Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 274 B |
Before Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 321 B |
Before Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 256 B |
Before Width: | Height: | Size: 263 B |
Before Width: | Height: | Size: 263 B |
Before Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 223 B |