--- /dev/null
+-- default (Minetest 0.4 mod)
+-- Most default stuff
+
+-- Quick documentation about the API
+-- =================================
+--
+-- Helper functions defined by builtin.lua:
+-- dump2(obj, name="_", dumped={})
+-- dump(obj, dumped={})
+--
+-- Mod load path
+-- -------------
+-- Generic:
+-- $path_data/mods/
+-- $path_userdata/usermods/
+-- $mapdir/worldmods/
+--
+-- On a run-in-place version (eg. the distributed windows version):
+-- minetest-0.4.x/data/mods/
+-- minetest-0.4.x/usermods/
+-- minetest-0.4.x/world/worldmods/
+--
+-- On an installed version on linux:
+-- /usr/share/minetest/mods/
+-- ~/.minetest/usermods
+-- ~/.minetest/world/worldmods
+--
+-- Naming convention for registered textual names
+-- ----------------------------------------------
+-- "modname:<whatever>" (<whatever> can have characters a-zA-Z0-9_)
+--
+-- This is to prevent conflicting names from corrupting maps and is
+-- enforced by the mod loader.
+--
+-- Example: mod "experimental", ideal item/node/entity name "tnt":
+-- -> the name should be "experimental:tnt".
+--
+-- Enforcement can be overridden by prefixing the name with ":". This can
+-- be used for overriding the registrations of some other mod.
+--
+-- Example: Any mod can redefine experimental:tnt by using the name
+-- ":experimental:tnt" when registering it.
+-- (also that mods is required to have "experimental" as a dependency)
+--
+-- The legacy mod uses ":" for maintaining backwards compatibility.
+--
+-- Textures
+-- --------
+-- Mods should generally prefix their textures with modname_, eg. given
+-- the mod name "foomod", a texture could be called "default_foomod_superfurnace.png"
+--
+-- This is not crucial and a conflicting name will not corrupt maps.
+--
+-- Representations of simple things
+-- --------------------------------
+--
+-- MapNode representation:
+-- {name="name", param1=num, param2=num}
+--
+-- param1 and param2 are 8 bit and 4 bit integers, respectively. They
+-- are reserved for certain automated functions. If you don't use these
+-- functions, you can use them to store arbitrary values.
+--
+-- param1 is reserved for the engine when:
+-- paramtype != "none"
+-- param2 is reserved for the engine when any of these are used:
+-- liquidtype == "flowing"
+-- drawtype == "flowingliquid"
+-- drawtype == "torchlike"
+-- drawtype == "signlike"
+--
+-- Position representation:
+-- {x=num, y=num, z=num}
+--
+-- stackstring/itemstring: A stack of items in serialized format.
+-- eg. 'node "default:dirt" 5'
+-- eg. 'tool "default:pick_wood" 21323'
+-- eg. 'craft "default:apple" 2'
+--
+-- item: A stack of items in Lua table format.
+-- eg. {name="default:dirt", count=1, wear=0, metadata=""}
+-- ^ a single dirt node
+-- eg. {name="default:pick_wood", count=1, wear=21323, metadata=""}
+-- ^ a wooden pick about 1/3 weared out
+-- eg. {name="default:apple", count=1, wear=0, metadata=""}
+-- ^ an apple.
+--
+-- Any time an item must be passed to a function, it can be an
+-- ItemStack (see below), an itemstring or a table in the above format.
+--
+-- Global functions:
+-- minetest.register_entity(name, prototype table)
+-- minetest.register_abm(abm definition)
+-- minetest.register_node(name, node definition)
+-- minetest.register_tool(name, item definition)
+-- minetest.register_craftitem(name, item definition)
+-- minetest.register_alias(name, convert_to)
+-- minetest.register_craft(recipe)
+-- minetest.register_globalstep(func(dtime))
+-- minetest.register_on_placenode(func(pos, newnode, placer))
+-- minetest.register_on_dignode(func(pos, oldnode, digger))
+-- minetest.register_on_punchnode(func(pos, node, puncher))
+-- minetest.register_on_generated(func(minp, maxp))
+-- minetest.register_on_newplayer(func(ObjectRef))
+-- minetest.register_on_dieplayer(func(ObjectRef))
+-- minetest.register_on_respawnplayer(func(ObjectRef))
+-- ^ return true in func to disable regular player placement
+-- ^ currently called _before_ repositioning of player occurs
+-- minetest.register_on_chat_message(func(name, message))
+-- minetest.add_to_creative_inventory(itemstring)
+-- minetest.setting_get(name) -> string or nil
+-- minetest.setting_getbool(name) -> boolean value or nil
+-- minetest.chat_send_all(text)
+-- minetest.chat_send_player(name, text)
+-- minetest.get_player_privs(name) -> set of privs
+-- minetest.get_inventory(location) -> InvRef
+-- minetest.get_current_modname() -> string
+-- minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
+-- ^ location = eg. {type="player", name="celeron55"}
+-- {type="node", pos={x=, y=, z=}}
+--
+-- minetest.debug(line)
+-- ^ Goes to dstream
+-- minetest.log(line)
+-- minetest.log(loglevel, line)
+-- ^ loglevel one of "error", "action", "info", "verbose"
+--
+-- minetest.digprop_constanttime(time)
+-- minetest.digprop_stonelike(toughness)
+-- minetest.digprop_dirtlike(toughness)
+-- minetest.digprop_gravellike(toughness)
+-- minetest.digprop_woodlike(toughness)
+-- minetest.digprop_leaveslike(toughness)
+-- minetest.digprop_glasslike(toughness)
+--
+-- Global objects:
+-- minetest.env - environment reference
+--
+-- Global tables:
+-- minetest.registered_items
+-- ^ List of registered items, indexed by name
+-- minetest.registered_nodes
+-- ^ List of registered node definitions, indexed by name
+-- minetest.registered_craftitems
+-- ^ List of registered craft item definitions, indexed by name
+-- minetest.registered_tools
+-- ^ List of registered tool definitions, indexed by name
+-- minetest.registered_entities
+-- ^ List of registered entity prototypes, indexed by name
+-- minetest.object_refs
+-- ^ List of object references, indexed by active object id
+-- minetest.luaentities
+-- ^ List of lua entities, indexed by active object id
+--
+-- EnvRef is basically ServerEnvironment and ServerMap combined.
+-- EnvRef methods:
+-- - add_node(pos, node)
+-- - remove_node(pos)
+-- - get_node(pos)
+-- ^ Returns {name="ignore", ...} for unloaded area
+-- - get_node_or_nil(pos)
+-- ^ Returns nil for unloaded area
+-- - get_node_light(pos, timeofday) -> 0...15 or nil
+-- ^ timeofday: nil = current time, 0 = night, 0.5 = day
+-- - add_entity(pos, name): Returns ObjectRef or nil if failed
+-- - add_item(pos, itemstring)
+-- - add_rat(pos)
+-- - add_firefly(pos)
+-- - get_meta(pos) -- Get a NodeMetaRef at that position
+-- - get_player_by_name(name) -- Get an ObjectRef to a player
+-- - get_objects_inside_radius(pos, radius)
+--
+-- NodeMetaRef (this stuff is subject to change in a future version)
+-- - get_type()
+-- - allows_text_input()
+-- - set_text(text) -- eg. set the text of a sign
+-- - get_text()
+-- - get_owner()
+-- - set_owner(string)
+-- Generic node metadata specific:
+-- - set_infotext(infotext)
+-- - get_inventory() -> InvRef
+-- - set_inventory_draw_spec(string)
+-- - set_allow_text_input(bool)
+-- - set_allow_removal(bool)
+-- - set_enforce_owner(bool)
+-- - is_inventory_modified()
+-- - reset_inventory_modified()
+-- - is_text_modified()
+-- - reset_text_modified()
+-- - set_string(name, value)
+-- - get_string(name)
+--
+-- ObjectRef is basically ServerActiveObject.
+-- ObjectRef methods:
+-- - remove(): remove object (after returning from Lua)
+-- - getpos() -> {x=num, y=num, z=num}
+-- - setpos(pos); pos={x=num, y=num, z=num}
+-- - moveto(pos, continuous=false): interpolated move
+-- - punch(puncher, time_from_last_punch)
+-- ^ puncher = an another ObjectRef,
+-- ^ time_from_last_punch = time since last punch action of the puncher
+-- - right_click(clicker); clicker = an another ObjectRef
+-- - get_hp(): returns number of hitpoints (2 * number of hearts)
+-- - set_hp(hp): set number of hitpoints (2 * number of hearts)
+-- - get_inventory() -> InvRef
+-- - get_wield_list(): returns the name of the inventory list the wielded item is in
+-- - get_wield_index(): returns the index of the wielded item
+-- - get_wielded_item() -> ItemStack
+-- - set_wielded_item(item): replaces the wielded item, returns true if successful
+-- LuaEntitySAO-only: (no-op for other objects)
+-- - setvelocity({x=num, y=num, z=num})
+-- - getvelocity() -> {x=num, y=num, z=num}
+-- - setacceleration({x=num, y=num, z=num})
+-- - getacceleration() -> {x=num, y=num, z=num}
+-- - setyaw(radians)
+-- - getyaw() -> radians
+-- - settexturemod(mod)
+-- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
+-- - select_horiz_by_yawpitch=false)
+-- - ^ Select sprite from spritesheet with optional animation and DM-style
+-- - texture selection based on yaw relative to camera
+-- - get_entity_name() (DEPRECATED: Will be removed in a future version)
+-- - get_luaentity()
+-- Player-only: (no-op for other objects)
+-- - get_player_name(): will return nil if is not a player
+-- - get_look_dir(): get camera direction as a unit vector
+-- - get_look_pitch(): pitch in radians
+-- - get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
+--
+-- InvRef methods:
+-- - get_size(listname): get size of a list
+-- - set_size(listname, size): set size of a list
+-- - get_stack(listname, i): get a copy of stack index i in list
+-- - set_stack(listname, i, stack): copy stack to index i in list
+-- - get_list(listname): return full list
+-- - set_list(listname, list): set full list (size will not change)
+-- - add_item(listname, stack): add item somewhere in list, returns leftover ItemStack
+-- - room_for_item(listname, stack): returns true if the stack of items
+-- can be fully added to the list
+-- - contains_item(listname, stack): returns true if the stack of items
+-- can be fully taken from the list
+-- remove_item(listname, stack): take as many items as specified from the list,
+-- returns the items that were actually removed (as an ItemStack)
+--
+-- ItemStack methods:
+-- - is_empty(): return true if stack is empty
+-- - get_name(): returns item name (e.g. "default:stone")
+-- - get_count(): returns number of items on the stack
+-- - get_wear(): returns tool wear (0-65535), 0 for non-tools
+-- - get_metadata(): returns metadata (a string attached to an item stack)
+-- - clear(): removes all items from the stack, making it empty
+-- - replace(item): replace the contents of this stack (item can also
+-- be an itemstring or table)
+-- - to_string(): returns the stack in itemstring form
+-- - to_table(): returns the stack in Lua table form
+-- - get_stack_max(): returns the maximum size of the stack (depends on the item)
+-- - get_free_space(): returns get_stack_max() - get_count()
+-- - is_known(): returns true if the item name refers to a defined item type
+-- - get_definition(): returns the item definition table
+-- - get_tool_digging_properties(): returns the digging properties of the item,
+-- ^ or those of the hand if none are defined for this item type
+-- - add_wear(amount): increases wear by amount if the item is a tool
+-- - add_item(item): put some item or stack onto this stack,
+-- ^ returns leftover ItemStack
+-- - item_fits(item): returns true if item or stack can be fully added to this one
+-- - take_item(n): take (and remove) up to n items from this stack
+-- ^ returns taken ItemStack
+-- ^ if n is omitted, n=1 is used
+-- - peek_item(n): copy (don't remove) up to n items from this stack
+-- ^ returns copied ItemStack
+-- ^ if n is omitted, n=1 is used
+--
+-- Registered entities:
+-- - Functions receive a "luaentity" as self:
+-- - It has the member .name, which is the registered name ("mod:thing")
+-- - It has the member .object, which is an ObjectRef pointing to the object
+-- - The original prototype stuff is visible directly via a metatable
+-- - Callbacks:
+-- - on_activate(self, staticdata)
+-- - on_step(self, dtime)
+-- - on_punch(self, hitter)
+-- - on_rightclick(self, clicker)
+-- - get_staticdata(self)
+-- ^ return string that will be passed to on_activate when the object
+-- is created next time
+--
+-- Entity prototype table:
+-- {
+-- physical = true,
+-- collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
+-- visual = "cube"/"sprite",
+-- visual_size = {x=1, y=1},
+-- textures = {texture,texture,texture,texture,texture,texture},
+-- spritediv = {x=1, y=1},
+-- initial_sprite_basepos = {x=0, y=0},
+-- on_activate = function(self, staticdata),
+-- on_step = function(self, dtime),
+-- on_punch = function(self, hitter),
+-- on_rightclick = function(self, clicker),
+-- get_staticdata = function(self),
+-- # Also you can define arbitrary member variables here
+-- myvariable = whatever,
+-- }
+--
+-- Item definition options (register_node, register_craftitem, register_tool)
+-- {
+-- description = "Steel Axe",
+-- inventory_image = "default_tool_steelaxe.png",
+-- wield_image = "",
+-- wield_scale = {x=1,y=1,z=1},
+-- stack_max = 99,
+-- liquids_pointable = false,
+-- tool_digging_properties = {
+-- full_punch_interval = 1.0,
+-- basetime = 1.0,
+-- dt_weight = 0.5,
+-- dt_crackiness = -0.2,
+-- dt_crumbliness = 1,
+-- dt_cuttability = -0.5,
+-- basedurability = 330,
+-- dd_weight = 0,
+-- dd_crackiness = 0,
+-- dd_crumbliness = 0,
+-- dd_cuttability = 0,
+-- }
+-- on_drop = func(item, dropper, pos),
+-- on_place = func(item, placer, pointed_thing),
+-- on_use = func(item, user, pointed_thing),
+-- }
+--
+-- Node definition options (register_node):
+-- {
+-- <all fields allowed in item definitions>,
+-- drawtype = "normal",
+-- visual_scale = 1.0,
+-- tile_images = {"default_unknown_block.png"},
+-- special_materials = {
+-- {image="", backface_culling=true},
+-- {image="", backface_culling=true},
+-- },
+-- alpha = 255,
+-- post_effect_color = {a=0, r=0, g=0, b=0},
+-- paramtype = "none",
+-- paramtype2 = "none",
+-- is_ground_content = false,
+-- sunlight_propagates = false,
+-- walkable = true,
+-- pointable = true,
+-- diggable = true,
+-- climbable = false,
+-- buildable_to = false,
+-- drop = "",
+-- -- alternatively drop = { max_items = ..., items = { ... } }
+-- metadata_name = "",
+-- liquidtype = "none",
+-- liquid_alternative_flowing = "",
+-- liquid_alternative_source = "",
+-- liquid_viscosity = 0,
+-- light_source = 0,
+-- damage_per_second = 0,
+-- selection_box = {type="regular"},
+-- material = {
+-- diggablity = "normal",
+-- weight = 0,
+-- crackiness = 0,
+-- crumbliness = 0,
+-- cuttability = 0,
+-- flammability = 0,
+-- },
+-- legacy_facedir_simple = false, -- Support maps made in and before January 2012
+-- legacy_wallmounted = false, -- Support maps made in and before January 2012
+-- }
+--
+-- Recipe:
+-- {
+-- output = 'default:pick_stone',
+-- recipe = {
+-- {'default:cobble', 'default:cobble', 'default:cobble'},
+-- {'', 'default:stick', ''},
+-- {'', 'default:stick', ''},
+-- },
+-- replacements = <optional list of item pairs,
+-- replace one input item with another item on crafting>
+-- }
+--
+-- Recipe (shapeless):
+-- {
+-- type = "shapeless",
+-- output = 'mushrooms:mushroom_stew',
+-- recipe = {
+-- "mushrooms:bowl",
+-- "mushrooms:mushroom_brown",
+-- "mushrooms:mushroom_red",
+-- },
+-- replacements = <optional list of item pairs,
+-- replace one input item with another item on crafting>
+-- }
+--
+-- Recipe (tool repair):
+-- {
+-- type = "toolrepair",
+-- additional_wear = -0.02,
+-- }
+--
+-- Recipe (cooking):
+-- {
+-- type = "cooking",
+-- output = "default:glass",
+-- recipe = "default:sand",
+-- cooktime = 3,
+-- }
+--
+-- Recipe (furnace fuel):
+-- {
+-- type = "fuel",
+-- recipe = "default:leaves",
+-- burntime = 1,
+-- }
+--
+-- ABM (ActiveBlockModifier) definition:
+-- {
+-- nodenames = {"default:lava_source"},
+-- neighbors = {"default:water_source", "default:water_flowing"}, -- (any of these)
+-- ^ If left out or empty, any neighbor will do
+-- ^ This might get removed in the future
+-- interval = 1.0, -- (operation interval)
+-- chance = 1, -- (chance of trigger is 1.0/this)
+-- action = func(pos, node, active_object_count, active_object_count_wider),
+-- }
+
+WATER_ALPHA = 160
+WATER_VISC = 1
+LAVA_VISC = 7
+LIGHT_MAX = 14
+
+-- Definitions made by this mod that other mods can use too
+default = {}
+
+--
+-- Tool definition
+--
+
+minetest.register_tool("default:pick_wood", {
+ description = "Wooden Pickaxe",
+ inventory_image = "default_tool_woodpick.png",
+ tool_digging_properties = {
+ basetime = 2.0,
+ dt_weight = 0,
+ dt_crackiness = -0.5,
+ dt_crumbliness = 2,
+ dt_cuttability = 0,
+ basedurability = 30,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:pick_stone", {
+ description = "Stone Pickaxe",
+ inventory_image = "default_tool_stonepick.png",
+ tool_digging_properties = {
+ basetime = 1.5,
+ dt_weight = 0,
+ dt_crackiness = -0.5,
+ dt_crumbliness = 2,
+ dt_cuttability = 0,
+ basedurability = 100,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:pick_steel", {
+ description = "Steel Pickaxe",
+ inventory_image = "default_tool_steelpick.png",
+ tool_digging_properties = {
+ basetime = 1.0,
+ dt_weight = 0,
+ dt_crackiness = -0.5,
+ dt_crumbliness = 2,
+ dt_cuttability = 0,
+ basedurability = 333,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:pick_mese", {
+ description = "Mese Pickaxe",
+ inventory_image = "default_tool_mesepick.png",
+ tool_digging_properties = {
+ basetime = 0,
+ dt_weight = 0,
+ dt_crackiness = 0,
+ dt_crumbliness = 0,
+ dt_cuttability = 0,
+ basedurability = 1337,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:shovel_wood", {
+ description = "Wooden Shovel",
+ inventory_image = "default_tool_woodshovel.png",
+ tool_digging_properties = {
+ basetime = 2.0,
+ dt_weight = 0.5,
+ dt_crackiness = 2,
+ dt_crumbliness = -1.5,
+ dt_cuttability = 0.3,
+ basedurability = 30,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:shovel_stone", {
+ description = "Stone Shovel",
+ inventory_image = "default_tool_stoneshovel.png",
+ tool_digging_properties = {
+ basetime = 1.5,
+ dt_weight = 0.5,
+ dt_crackiness = 2,
+ dt_crumbliness = -1.5,
+ dt_cuttability = 0.1,
+ basedurability = 100,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:shovel_steel", {
+ description = "Steel Shovel",
+ inventory_image = "default_tool_steelshovel.png",
+ tool_digging_properties = {
+ basetime = 1.0,
+ dt_weight = 0.5,
+ dt_crackiness = 2,
+ dt_crumbliness = -1.5,
+ dt_cuttability = 0.0,
+ basedurability = 330,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:axe_wood", {
+ description = "Wooden Axe",
+ inventory_image = "default_tool_woodaxe.png",
+ tool_digging_properties = {
+ basetime = 2.0,
+ dt_weight = 0.5,
+ dt_crackiness = -0.2,
+ dt_crumbliness = 1,
+ dt_cuttability = -0.5,
+ basedurability = 30,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:axe_stone", {
+ description = "Stone Axe",
+ inventory_image = "default_tool_stoneaxe.png",
+ tool_digging_properties = {
+ basetime = 1.5,
+ dt_weight = 0.5,
+ dt_crackiness = -0.2,
+ dt_crumbliness = 1,
+ dt_cuttability = -0.5,
+ basedurability = 100,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:axe_steel", {
+ description = "Steel Axe",
+ inventory_image = "default_tool_steelaxe.png",
+ tool_digging_properties = {
+ basetime = 1.0,
+ dt_weight = 0.5,
+ dt_crackiness = -0.2,
+ dt_crumbliness = 1,
+ dt_cuttability = -0.5,
+ basedurability = 330,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ },
+})
+minetest.register_tool("default:sword_wood", {
+ description = "Wooden Sword",
+ inventory_image = "default_tool_woodsword.png",
+ tool_digging_properties = {
+ basetime = 3.0,
+ dt_weight = 3,
+ dt_crackiness = 0,
+ dt_crumbliness = 1,
+ dt_cuttability = -1,
+ basedurability = 30,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ }
+})
+minetest.register_tool("default:sword_stone", {
+ description = "Stone Sword",
+ inventory_image = "default_tool_stonesword.png",
+ tool_digging_properties = {
+ basetime = 2.5,
+ dt_weight = 3,
+ dt_crackiness = 0,
+ dt_crumbliness = 1,
+ dt_cuttability = -1,
+ basedurability = 100,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ }
+})
+minetest.register_tool("default:sword_steel", {
+ description = "Steel Sword",
+ inventory_image = "default_tool_steelsword.png",
+ tool_digging_properties = {
+ basetime = 2.0,
+ dt_weight = 3,
+ dt_crackiness = 0,
+ dt_crumbliness = 1,
+ dt_cuttability = -1,
+ basedurability = 330,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+ }
+})
+
+--
+-- Crafting definition
+--
+
+minetest.register_craft({
+ output = 'default:wood 4',
+ recipe = {
+ {'default:tree'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:stick 4',
+ recipe = {
+ {'default:wood'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:fence_wood 2',
+ recipe = {
+ {'default:stick', 'default:stick', 'default:stick'},
+ {'default:stick', 'default:stick', 'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:sign_wall',
+ recipe = {
+ {'default:wood', 'default:wood', 'default:wood'},
+ {'default:wood', 'default:wood', 'default:wood'},
+ {'', 'default:stick', ''},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:torch 4',
+ recipe = {
+ {'default:coal_lump'},
+ {'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:pick_wood',
+ recipe = {
+ {'default:wood', 'default:wood', 'default:wood'},
+ {'', 'default:stick', ''},
+ {'', 'default:stick', ''},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:pick_stone',
+ recipe = {
+ {'default:cobble', 'default:cobble', 'default:cobble'},
+ {'', 'default:stick', ''},
+ {'', 'default:stick', ''},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:pick_steel',
+ recipe = {
+ {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
+ {'', 'default:stick', ''},
+ {'', 'default:stick', ''},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:pick_mese',
+ recipe = {
+ {'default:mese', 'default:mese', 'default:mese'},
+ {'', 'default:stick', ''},
+ {'', 'default:stick', ''},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:shovel_wood',
+ recipe = {
+ {'default:wood'},
+ {'default:stick'},
+ {'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:shovel_stone',
+ recipe = {
+ {'default:cobble'},
+ {'default:stick'},
+ {'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:shovel_steel',
+ recipe = {
+ {'default:steel_ingot'},
+ {'default:stick'},
+ {'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:axe_wood',
+ recipe = {
+ {'default:wood', 'default:wood'},
+ {'default:wood', 'default:stick'},
+ {'', 'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:axe_stone',
+ recipe = {
+ {'default:cobble', 'default:cobble'},
+ {'default:cobble', 'default:stick'},
+ {'', 'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:axe_steel',
+ recipe = {
+ {'default:steel_ingot', 'default:steel_ingot'},
+ {'default:steel_ingot', 'default:stick'},
+ {'', 'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:sword_wood',
+ recipe = {
+ {'default:wood'},
+ {'default:wood'},
+ {'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:sword_stone',
+ recipe = {
+ {'default:cobble'},
+ {'default:cobble'},
+ {'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:sword_steel',
+ recipe = {
+ {'default:steel_ingot'},
+ {'default:steel_ingot'},
+ {'default:stick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:rail 15',
+ recipe = {
+ {'default:steel_ingot', '', 'default:steel_ingot'},
+ {'default:steel_ingot', 'default:stick', 'default:steel_ingot'},
+ {'default:steel_ingot', '', 'default:steel_ingot'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:chest',
+ recipe = {
+ {'default:wood', 'default:wood', 'default:wood'},
+ {'default:wood', '', 'default:wood'},
+ {'default:wood', 'default:wood', 'default:wood'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:chest_locked',
+ recipe = {
+ {'default:wood', 'default:wood', 'default:wood'},
+ {'default:wood', 'default:steel_ingot', 'default:wood'},
+ {'default:wood', 'default:wood', 'default:wood'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:furnace',
+ recipe = {
+ {'default:cobble', 'default:cobble', 'default:cobble'},
+ {'default:cobble', '', 'default:cobble'},
+ {'default:cobble', 'default:cobble', 'default:cobble'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:steelblock',
+ recipe = {
+ {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
+ {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
+ {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:sandstone',
+ recipe = {
+ {'default:sand', 'default:sand'},
+ {'default:sand', 'default:sand'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:clay',
+ recipe = {
+ {'default:clay_lump', 'default:clay_lump'},
+ {'default:clay_lump', 'default:clay_lump'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:brick',
+ recipe = {
+ {'default:clay_brick', 'default:clay_brick'},
+ {'default:clay_brick', 'default:clay_brick'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:paper',
+ recipe = {
+ {'default:papyrus', 'default:papyrus', 'default:papyrus'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:book',
+ recipe = {
+ {'default:paper'},
+ {'default:paper'},
+ {'default:paper'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:bookshelf',
+ recipe = {
+ {'default:wood', 'default:wood', 'default:wood'},
+ {'default:book', 'default:book', 'default:book'},
+ {'default:wood', 'default:wood', 'default:wood'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:ladder',
+ recipe = {
+ {'default:stick', '', 'default:stick'},
+ {'default:stick', 'default:stick', 'default:stick'},
+ {'default:stick', '', 'default:stick'},
+ }
+})
+
+--
+-- Crafting (tool repair)
+--
+minetest.register_craft({
+ type = "toolrepair",
+ additional_wear = -0.02,
+})
+
+--
+-- Cooking recipes
+--
+
+minetest.register_craft({
+ type = "cooking",
+ output = "default:glass",
+ recipe = "default:sand",
+})
+
+minetest.register_craft({
+ type = "cooking",
+ output = "default:coal_lump",
+ recipe = "default:tree",
+})
+
+minetest.register_craft({
+ type = "cooking",
+ output = "default:coal_lump",
+ recipe = "default:jungletree",
+})
+
+minetest.register_craft({
+ type = "cooking",
+ output = "default:stone",
+ recipe = "default:cobble",
+})
+
+minetest.register_craft({
+ type = "cooking",
+ output = "default:steel_ingot",
+ recipe = "default:iron_lump",
+})
+
+minetest.register_craft({
+ type = "cooking",
+ output = "default:clay_brick",
+ recipe = "default:clay_lump",
+})
+
+--
+-- Fuels
+--
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:tree",
+ burntime = 30,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:jungletree",
+ burntime = 30,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:junglegrass",
+ burntime = 2,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:leaves",
+ burntime = 1,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:cactus",
+ burntime = 15,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:papyrus",
+ burntime = 1,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:bookshelf",
+ burntime = 30,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:fence_wood",
+ burntime = 15,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:ladder",
+ burntime = 5,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:wood",
+ burntime = 7,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:mese",
+ burntime = 30,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:lava_source",
+ burntime = 60,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:torch",
+ burntime = 4,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:sign_wall",
+ burntime = 10,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:chest",
+ burntime = 30,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:chest_locked",
+ burntime = 30,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:nyancat",
+ burntime = 1,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:nyancat_rainbow",
+ burntime = 1,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:sapling",
+ burntime = 10,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:apple",
+ burntime = 3,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:coal_lump",
+ burntime = 40,
+})
+
+--
+-- Node definitions
+--
+
+minetest.register_node("default:stone", {
+ description = "Stone",
+ tile_images = {"default_stone.png"},
+ is_ground_content = true,
+ material = minetest.digprop_stonelike(1.0),
+ drop = 'default:cobble',
+ legacy_mineral = true,
+})
+
+minetest.register_node("default:stone_with_coal", {
+ description = "Stone with coal",
+ tile_images = {"default_stone.png^default_mineral_coal.png"},
+ is_ground_content = true,
+ material = minetest.digprop_stonelike(1.0),
+ drop = 'default:coal_lump',
+})
+
+minetest.register_node("default:stone_with_iron", {
+ description = "Stone with iron",
+ tile_images = {"default_stone.png^default_mineral_iron.png"},
+ is_ground_content = true,
+ material = minetest.digprop_stonelike(1.0),
+ drop = 'default:iron_lump',
+})
+
+minetest.register_node("default:dirt_with_grass", {
+ description = "Dirt with grass",
+ tile_images = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
+ is_ground_content = true,
+ material = minetest.digprop_dirtlike(1.0),
+ drop = 'default:dirt',
+})
+
+minetest.register_node("default:dirt_with_grass_footsteps", {
+ description = "Dirt with grass and footsteps",
+ tile_images = {"default_grass_footsteps.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
+ is_ground_content = true,
+ material = minetest.digprop_dirtlike(1.0),
+ drop = 'default:dirt',
+})
+
+minetest.register_node("default:dirt", {
+ description = "Dirt",
+ tile_images = {"default_dirt.png"},
+ is_ground_content = true,
+ material = minetest.digprop_dirtlike(1.0),
+})
+
+minetest.register_node("default:sand", {
+ description = "Sand",
+ tile_images = {"default_sand.png"},
+ is_ground_content = true,
+ material = minetest.digprop_dirtlike(1.0),
+})
+
+minetest.register_node("default:gravel", {
+ description = "Gravel",
+ tile_images = {"default_gravel.png"},
+ is_ground_content = true,
+ material = minetest.digprop_gravellike(1.0),
+})
+
+minetest.register_node("default:sandstone", {
+ description = "Sandstone",
+ tile_images = {"default_sandstone.png"},
+ is_ground_content = true,
+ material = minetest.digprop_dirtlike(1.0), -- FIXME should this be stonelike?
+ drop = 'default:sand',
+})
+
+minetest.register_node("default:clay", {
+ description = "Clay",
+ tile_images = {"default_clay.png"},
+ is_ground_content = true,
+ material = minetest.digprop_dirtlike(1.0),
+ drop = 'default:clay_lump 4',
+})
+
+minetest.register_node("default:brick", {
+ description = "Brick",
+ tile_images = {"default_brick.png"},
+ is_ground_content = true,
+ material = minetest.digprop_stonelike(1.0),
+ drop = 'default:clay_brick 4',
+})
+
+minetest.register_node("default:tree", {
+ description = "Tree",
+ tile_images = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(1.0),
+})
+
+minetest.register_node("default:jungletree", {
+ description = "Jungle Tree",
+ tile_images = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(1.0),
+})
+
+minetest.register_node("default:junglegrass", {
+ description = "Jungle Grass",
+ drawtype = "plantlike",
+ visual_scale = 1.3,
+ tile_images = {"default_junglegrass.png"},
+ inventory_image = "default_junglegrass.png",
+ wield_image = "default_junglegrass.png",
+ paramtype = "light",
+ walkable = false,
+ material = minetest.digprop_leaveslike(1.0),
+})
+
+minetest.register_node("default:leaves", {
+ description = "Leaves",
+ drawtype = "allfaces_optional",
+ visual_scale = 1.3,
+ tile_images = {"default_leaves.png"},
+ paramtype = "light",
+ material = minetest.digprop_leaveslike(1.0),
+ drop = {
+ max_items = 1,
+ items = {
+ {
+ -- player will get sapling with 1/20 chance
+ items = {'default:sapling'},
+ rarity = 20,
+ },
+ {
+ -- player will get leaves only if he get no saplings,
+ -- this is because max_items is 1
+ items = {'default:leaves'},
+ }
+ }
+ },
+})
+
+minetest.register_node("default:cactus", {
+ description = "Cactus",
+ tile_images = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.75),
+})
+
+minetest.register_node("default:papyrus", {
+ description = "Papyrus",
+ drawtype = "plantlike",
+ tile_images = {"default_papyrus.png"},
+ inventory_image = "default_papyrus.png",
+ wield_image = "default_papyrus.png",
+ paramtype = "light",
+ is_ground_content = true,
+ walkable = false,
+ material = minetest.digprop_leaveslike(0.5),
+})
+
+minetest.register_node("default:bookshelf", {
+ description = "Bookshelf",
+ tile_images = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.75),
+})
+
+minetest.register_node("default:glass", {
+ description = "Glass",
+ drawtype = "glasslike",
+ tile_images = {"default_glass.png"},
+ inventory_image = minetest.inventorycube("default_glass.png"),
+ paramtype = "light",
+ sunlight_propagates = true,
+ is_ground_content = true,
+ material = minetest.digprop_glasslike(1.0),
+})
+
+minetest.register_node("default:fence_wood", {
+ description = "Wooden Fence",
+ drawtype = "fencelike",
+ tile_images = {"default_wood.png"},
+ inventory_image = "default_fence.png",
+ wield_image = "default_fence.png",
+ paramtype = "light",
+ is_ground_content = true,
+ selection_box = {
+ type = "fixed",
+ fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
+ },
+ material = minetest.digprop_woodlike(0.75),
+})
+
+minetest.register_node("default:rail", {
+ description = "Rail",
+ drawtype = "raillike",
+ tile_images = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
+ inventory_image = "default_rail.png",
+ wield_image = "default_rail.png",
+ paramtype = "light",
+ is_ground_content = true,
+ walkable = false,
+ selection_box = {
+ type = "fixed",
+ --fixed = <default>
+ },
+ material = minetest.digprop_dirtlike(0.75),
+})
+
+minetest.register_node("default:ladder", {
+ description = "Ladder",
+ drawtype = "signlike",
+ tile_images = {"default_ladder.png"},
+ inventory_image = "default_ladder.png",
+ wield_image = "default_ladder.png",
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ is_ground_content = true,
+ walkable = false,
+ climbable = true,
+ selection_box = {
+ type = "wallmounted",
+ --wall_top = = <default>
+ --wall_bottom = = <default>
+ --wall_side = = <default>
+ },
+ material = minetest.digprop_woodlike(0.5),
+ legacy_wallmounted = true,
+})
+
+minetest.register_node("default:wood", {
+ description = "Wood",
+ tile_images = {"default_wood.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.75),
+})
+
+minetest.register_node("default:mese", {
+ description = "Mese",
+ tile_images = {"default_mese.png"},
+ is_ground_content = true,
+ material = minetest.digprop_stonelike(0.5),
+})
+
+minetest.register_node("default:cloud", {
+ description = "Cloud",
+ tile_images = {"default_cloud.png"},
+ is_ground_content = true,
+})
+
+minetest.register_node("default:water_flowing", {
+ description = "Water (flowing)",
+ inventory_image = minetest.inventorycube("default_water.png"),
+ drawtype = "flowingliquid",
+ tile_images = {"default_water.png"},
+ alpha = WATER_ALPHA,
+ paramtype = "light",
+ walkable = false,
+ pointable = false,
+ diggable = false,
+ buildable_to = true,
+ liquidtype = "flowing",
+ liquid_alternative_flowing = "default:water_flowing",
+ liquid_alternative_source = "default:water_source",
+ liquid_viscosity = WATER_VISC,
+ post_effect_color = {a=64, r=100, g=100, b=200},
+ special_materials = {
+ {image="default_water.png", backface_culling=false},
+ {image="default_water.png", backface_culling=true},
+ },
+})
+
+minetest.register_node("default:water_source", {
+ description = "Water",
+ inventory_image = minetest.inventorycube("default_water.png"),
+ drawtype = "liquid",
+ tile_images = {"default_water.png"},
+ alpha = WATER_ALPHA,
+ paramtype = "light",
+ walkable = false,
+ pointable = false,
+ diggable = false,
+ buildable_to = true,
+ liquidtype = "source",
+ liquid_alternative_flowing = "default:water_flowing",
+ liquid_alternative_source = "default:water_source",
+ liquid_viscosity = WATER_VISC,
+ post_effect_color = {a=64, r=100, g=100, b=200},
+ special_materials = {
+ -- New-style water source material (mostly unused)
+ {image="default_water.png", backface_culling=false},
+ },
+})
+
+minetest.register_node("default:lava_flowing", {
+ description = "Lava (flowing)",
+ inventory_image = minetest.inventorycube("default_lava.png"),
+ drawtype = "flowingliquid",
+ tile_images = {"default_lava.png"},
+ paramtype = "light",
+ light_source = LIGHT_MAX - 1,
+ walkable = false,
+ pointable = false,
+ diggable = false,
+ buildable_to = true,
+ liquidtype = "flowing",
+ liquid_alternative_flowing = "default:lava_flowing",
+ liquid_alternative_source = "default:lava_source",
+ liquid_viscosity = LAVA_VISC,
+ damage_per_second = 4*2,
+ post_effect_color = {a=192, r=255, g=64, b=0},
+ special_materials = {
+ {image="default_lava.png", backface_culling=false},
+ {image="default_lava.png", backface_culling=true},
+ },
+})
+
+minetest.register_node("default:lava_source", {
+ description = "Lava",
+ inventory_image = minetest.inventorycube("default_lava.png"),
+ drawtype = "liquid",
+ tile_images = {"default_lava.png"},
+ paramtype = "light",
+ light_source = LIGHT_MAX - 1,
+ walkable = false,
+ pointable = false,
+ diggable = false,
+ buildable_to = true,
+ liquidtype = "source",
+ liquid_alternative_flowing = "default:lava_flowing",
+ liquid_alternative_source = "default:lava_source",
+ liquid_viscosity = LAVA_VISC,
+ damage_per_second = 4*2,
+ post_effect_color = {a=192, r=255, g=64, b=0},
+ special_materials = {
+ -- New-style lava source material (mostly unused)
+ {image="default_lava.png", backface_culling=false},
+ },
+})
+
+minetest.register_node("default:torch", {
+ description = "Torch",
+ drawtype = "torchlike",
+ tile_images = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"},
+ inventory_image = "default_torch_on_floor.png",
+ wield_image = "default_torch_on_floor.png",
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ sunlight_propagates = true,
+ walkable = false,
+ light_source = LIGHT_MAX-1,
+ selection_box = {
+ type = "wallmounted",
+ wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
+ wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
+ wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
+ },
+ material = minetest.digprop_constanttime(0.0),
+ legacy_wallmounted = true,
+})
+
+minetest.register_node("default:sign_wall", {
+ description = "Sign",
+ drawtype = "signlike",
+ tile_images = {"default_sign_wall.png"},
+ inventory_image = "default_sign_wall.png",
+ wield_image = "default_sign_wall.png",
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ sunlight_propagates = true,
+ walkable = false,
+ metadata_name = "sign",
+ selection_box = {
+ type = "wallmounted",
+ --wall_top = <default>
+ --wall_bottom = <default>
+ --wall_side = <default>
+ },
+ material = minetest.digprop_constanttime(0.5),
+ legacy_wallmounted = true,
+})
+
+minetest.register_node("default:chest", {
+ description = "Chest",
+ tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
+ "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
+ paramtype2 = "facedir",
+ metadata_name = "chest",
+ material = minetest.digprop_woodlike(1.0),
+ legacy_facedir_simple = true,
+})
+
+minetest.register_node("default:chest_locked", {
+ description = "Locked Chest",
+ tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
+ "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
+ paramtype2 = "facedir",
+ metadata_name = "locked_chest",
+ material = minetest.digprop_woodlike(1.0),
+ legacy_facedir_simple = true,
+})
+
+minetest.register_node("default:furnace", {
+ description = "Furnace",
+ tile_images = {"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
+ "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
+ paramtype2 = "facedir",
+ metadata_name = "furnace",
+ material = minetest.digprop_stonelike(3.0),
+ legacy_facedir_simple = true,
+})
+
+minetest.register_node("default:cobble", {
+ description = "Cobble",
+ tile_images = {"default_cobble.png"},
+ is_ground_content = true,
+ material = minetest.digprop_stonelike(0.9),
+})
+
+minetest.register_node("default:mossycobble", {
+ description = "Mossy Cobble",
+ tile_images = {"default_mossycobble.png"},
+ is_ground_content = true,
+ material = minetest.digprop_stonelike(0.8),
+})
+
+minetest.register_node("default:steelblock", {
+ description = "Steel Block",
+ tile_images = {"default_steel_block.png"},
+ is_ground_content = true,
+ material = minetest.digprop_stonelike(5.0),
+})
+
+minetest.register_node("default:nyancat", {
+ description = "Nyancat",
+ tile_images = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
+ "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
+ inventory_image = "default_nc_front.png",
+ paramtype2 = "facedir",
+ material = minetest.digprop_stonelike(3.0),
+ legacy_facedir_simple = true,
+})
+
+minetest.register_node("default:nyancat_rainbow", {
+ description = "Nyancat Rainbow",
+ tile_images = {"default_nc_rb.png"},
+ inventory_image = "default_nc_rb.png",
+ material = minetest.digprop_stonelike(3.0),
+})
+
+minetest.register_node("default:sapling", {
+ description = "Sapling",
+ drawtype = "plantlike",
+ visual_scale = 1.0,
+ tile_images = {"default_sapling.png"},
+ inventory_image = "default_sapling.png",
+ wield_image = "default_sapling.png",
+ paramtype = "light",
+ walkable = false,
+ material = minetest.digprop_constanttime(0.0),
+})
+
+minetest.register_node("default:apple", {
+ description = "Apple",
+ drawtype = "plantlike",
+ visual_scale = 1.0,
+ tile_images = {"default_apple.png"},
+ inventory_image = "default_apple.png",
+ paramtype = "light",
+ sunlight_propagates = true,
+ walkable = false,
+ material = minetest.digprop_constanttime(0.0),
+ on_use = minetest.item_eat(4),
+})
+
+--
+-- Crafting items
+--
+
+minetest.register_craftitem("default:stick", {
+ description = "Stick",
+ inventory_image = "default_stick.png",
+})
+
+minetest.register_craftitem("default:paper", {
+ description = "Paper",
+ inventory_image = "default_paper.png",
+})
+
+minetest.register_craftitem("default:book", {
+ description = "Book",
+ inventory_image = "default_book.png",
+})
+
+minetest.register_craftitem("default:coal_lump", {
+ description = "Lump of coal",
+ inventory_image = "default_coal_lump.png",
+})
+
+minetest.register_craftitem("default:iron_lump", {
+ description = "Lump of iron",
+ inventory_image = "default_iron_lump.png",
+})
+
+minetest.register_craftitem("default:clay_lump", {
+ description = "Lump of clay",
+ inventory_image = "default_clay_lump.png",
+})
+
+minetest.register_craftitem("default:steel_ingot", {
+ description = "Steel ingot",
+ inventory_image = "default_steel_ingot.png",
+})
+
+minetest.register_craftitem("default:clay_brick", {
+ description = "Clay brick",
+ inventory_image = "default_steel_ingot.png",
+ inventory_image = "default_clay_brick.png",
+})
+
+minetest.register_craftitem("default:scorched_stuff", {
+ description = "Scorched stuff",
+ inventory_image = "default_scorched_stuff.png",
+})
+
+--
+-- Creative inventory
+--
+
+minetest.add_to_creative_inventory('default:pick_mese')
+minetest.add_to_creative_inventory('default:pick_steel')
+minetest.add_to_creative_inventory('default:axe_steel')
+minetest.add_to_creative_inventory('default:shovel_steel')
+
+minetest.add_to_creative_inventory('default:torch')
+minetest.add_to_creative_inventory('default:cobble')
+minetest.add_to_creative_inventory('default:dirt')
+minetest.add_to_creative_inventory('default:stone')
+minetest.add_to_creative_inventory('default:sand')
+minetest.add_to_creative_inventory('default:sandstone')
+minetest.add_to_creative_inventory('default:clay')
+minetest.add_to_creative_inventory('default:brick')
+minetest.add_to_creative_inventory('default:tree')
+minetest.add_to_creative_inventory('default:wood')
+minetest.add_to_creative_inventory('default:leaves')
+minetest.add_to_creative_inventory('default:cactus')
+minetest.add_to_creative_inventory('default:papyrus')
+minetest.add_to_creative_inventory('default:bookshelf')
+minetest.add_to_creative_inventory('default:glass')
+minetest.add_to_creative_inventory('default:fence')
+minetest.add_to_creative_inventory('default:rail')
+minetest.add_to_creative_inventory('default:mese')
+minetest.add_to_creative_inventory('default:chest')
+minetest.add_to_creative_inventory('default:furnace')
+minetest.add_to_creative_inventory('default:sign_wall')
+minetest.add_to_creative_inventory('default:water_source')
+minetest.add_to_creative_inventory('default:lava_source')
+minetest.add_to_creative_inventory('default:ladder')
+
+--
+-- Some common functions
+--
+
+default.falling_node_names = {}
+
+function nodeupdate_single(p)
+ n = minetest.env:get_node(p)
+ if default.falling_node_names[n.name] ~= nil then
+ p_bottom = {x=p.x, y=p.y-1, z=p.z}
+ n_bottom = minetest.env:get_node(p_bottom)
+ if n_bottom.name == "air" then
+ minetest.env:remove_node(p)
+ minetest.env:add_entity(p, "default:falling_"..n.name)
+ nodeupdate(p)
+ end
+ end
+end
+
+function nodeupdate(p)
+ for x = -1,1 do
+ for y = -1,1 do
+ for z = -1,1 do
+ p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
+ nodeupdate_single(p2)
+ end
+ end
+ end
+end
+
+--
+-- Falling stuff
+--
+
+function default.register_falling_node(nodename, texture)
+ default.falling_node_names[nodename] = true
+ -- Override naming conventions for stuff like :default:falling_default:sand
+ minetest.register_entity(":default:falling_"..nodename, {
+ -- Static definition
+ physical = true,
+ collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
+ visual = "cube",
+ textures = {texture,texture,texture,texture,texture,texture},
+ -- State
+ -- Methods
+ on_step = function(self, dtime)
+ -- Set gravity
+ self.object:setacceleration({x=0, y=-10, z=0})
+ -- Turn to actual sand when collides to ground or just move
+ local pos = self.object:getpos()
+ local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
+ local bcn = minetest.env:get_node(bcp)
+ if bcn.name ~= "air" then
+ -- Turn to a sand node
+ local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
+ minetest.env:add_node(np, {name=nodename})
+ self.object:remove()
+ else
+ -- Do nothing
+ end
+ end
+ })
+end
+
+default.register_falling_node("default:sand", "default_sand.png")
+default.register_falling_node("default:gravel", "default_gravel.png")
+
+--
+-- Global callbacks
+--
+
+-- Global environment step function
+function on_step(dtime)
+ -- print("on_step")
+end
+minetest.register_globalstep(on_step)
+
+function on_placenode(p, node)
+ --print("on_placenode")
+ nodeupdate(p)
+end
+minetest.register_on_placenode(on_placenode)
+
+function on_dignode(p, node)
+ --print("on_dignode")
+ nodeupdate(p)
+end
+minetest.register_on_dignode(on_dignode)
+
+function on_punchnode(p, node)
+end
+minetest.register_on_punchnode(on_punchnode)
+
+local function handle_give_command(cmd, giver, receiver, stackstring)
+ if not minetest.get_player_privs(giver)["give"] then
+ minetest.chat_send_player(giver, "error: you don't have permission to give")
+ return
+ end
+ minetest.debug("DEBUG: "..cmd..' invoked, stackstring="'..stackstring..'"')
+ minetest.log(cmd..' invoked, stackstring="'..stackstring..'"')
+ local itemstack = ItemStack(stackstring)
+ if itemstack:is_empty() then
+ minetest.chat_send_player(giver, 'error: cannot give an empty item')
+ return
+ elseif not itemstack:is_known() then
+ minetest.chat_send_player(giver, 'error: cannot give an unknown item')
+ return
+ end
+ local receiverref = minetest.env:get_player_by_name(receiver)
+ if receiverref == nil then
+ minetest.chat_send_player(giver, receiver..' is not a known player')
+ return
+ end
+ local leftover = receiverref:get_inventory():add_item("main", itemstack)
+ if leftover:is_empty() then
+ partiality = ""
+ elseif leftover:get_count() == itemstack:get_count() then
+ partiality = "could not be "
+ else
+ partiality = "partially "
+ end
+ if giver == receiver then
+ minetest.chat_send_player(giver, '"'..stackstring
+ ..'" '..partiality..'added to inventory.');
+ else
+ minetest.chat_send_player(giver, '"'..stackstring
+ ..'" '..partiality..'added to '..receiver..'\'s inventory.');
+ minetest.chat_send_player(receiver, '"'..stackstring
+ ..'" '..partiality..'added to inventory.');
+ end
+end
+
+minetest.register_on_chat_message(function(name, message)
+ --print("default on_chat_message: name="..dump(name).." message="..dump(message))
+ local cmd = "/giveme"
+ if message:sub(0, #cmd) == cmd then
+ local stackstring = string.match(message, cmd.." (.*)")
+ if stackstring == nil then
+ minetest.chat_send_player(name, 'usage: '..cmd..' stackstring')
+ return true -- Handled chat message
+ end
+ handle_give_command(cmd, name, name, stackstring)
+ return true
+ end
+ local cmd = "/give"
+ if message:sub(0, #cmd) == cmd then
+ local receiver, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)")
+ if receiver == nil or stackstring == nil then
+ minetest.chat_send_player(name, 'usage: '..cmd..' name stackstring')
+ return true -- Handled chat message
+ end
+ handle_give_command(cmd, name, receiver, stackstring)
+ return true
+ end
+ local cmd = "/spawnentity"
+ if message:sub(0, #cmd) == cmd then
+ if not minetest.get_player_privs(name)["give"] then
+ minetest.chat_send_player(name, "you don't have permission to spawn (give)")
+ return true -- Handled chat message
+ end
+ if not minetest.get_player_privs(name)["interact"] then
+ minetest.chat_send_player(name, "you don't have permission to interact")
+ return true -- Handled chat message
+ end
+ local entityname = string.match(message, cmd.." (.*)")
+ if entityname == nil then
+ minetest.chat_send_player(name, 'usage: '..cmd..' entityname')
+ return true -- Handled chat message
+ end
+ print(cmd..' invoked, entityname="'..entityname..'"')
+ local player = minetest.env:get_player_by_name(name)
+ if player == nil then
+ print("Unable to spawn entity, player is nil")
+ return true -- Handled chat message
+ end
+ local p = player:getpos()
+ p.y = p.y + 1
+ minetest.env:add_entity(p, entityname)
+ minetest.chat_send_player(name, '"'..entityname
+ ..'" spawned.');
+ return true -- Handled chat message
+ end
+ local cmd = "/pulverize"
+ if message:sub(0, #cmd) == cmd then
+ local player = minetest.env:get_player_by_name(name)
+ if player == nil then
+ print("Unable to pulverize, player is nil")
+ return true -- Handled chat message
+ end
+ if player:get_wielded_item():is_empty() then
+ minetest.chat_send_player(name, 'Unable to pulverize, no item in hand.')
+ else
+ player:set_wielded_item(nil)
+ minetest.chat_send_player(name, 'An item was pulverized.')
+ end
+ return true
+ end
+end)
+
+--M13 Blocks--
+---nodes---
+minetest.register_node("default:m13", {
+ description = "M13 Block",
+ tile_images = {"m13.png"},
+ is_ground_content = true,
+ material = minetest.digprop_stonelike(1.00),
+})
+---crafting---
+minetest.register_craft({
+ output = 'default:m13',
+ recipe = {
+ {'default:mese'},
+ {'default:mese'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:m13_pick',
+ recipe = {
+ {'default:m13', 'default:m13', 'default:m13'},
+ {'', 'default:stick', ''},
+ {'', 'default:stick', ''},
+ }
+})
+
+---tools---
+
+minetest.register_tool("default:m13_pick", {
+ image = "m13_pick.png",
+ basetime = 0,
+ dt_weight = 0,
+ dt_crackiness = 0,
+ dt_crumbliness = 0,
+ dt_cuttability = 0,
+ basedurability = 3000,
+ dd_weight = 0,
+ dd_crackiness = 0,
+ dd_crumbliness = 0,
+ dd_cuttability = 0,
+})
+
+--Jungle Tree can be Crafted into wood!--
+minetest.register_craft({
+ output = 'default:wood 4' ,
+ recipe = {
+ {'default:jungletree'},
+ }
+})
+
+-- Wool --
+
+minetest.register_craft({
+ output = 'default:red 16',
+ recipe = {
+ {'default:apple', 'default:white'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:yellow 16',
+ recipe = {
+ {'default:sand', 'default:white'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:white 16',
+ recipe = {
+ {'default:coal_lump', 'default:sand'},
+ }
+})
+
+
+minetest.register_craft({
+ output = 'default:black 16',
+ recipe = {
+ {'default:coal_lump', 'default:grey'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:grey 16',
+ recipe = {
+ {'default:coal_lump', 'default:white'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:green 16',
+ recipe = {
+ {'default:leaves', 'default:white'},
+ }
+})
+
+
+minetest.register_craft({
+ output = 'default:brown 16',
+ recipe = {
+ {'default:dirt', 'default:white'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:cyan 16',
+ recipe = {
+ {'default:jungletree', 'default:white'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:magenta 16',
+ recipe = {
+ {'default:cyan', 'default:red'},
+ }
+})
+
+minetest.register_craft({
+ output = 'default:blue 16',
+ recipe = {
+ {'default:cyan', 'default:magenta'},
+ }
+})
+
+
+minetest.register_craft({
+ output = 'default:orange 16',
+ recipe = {
+ {'default:yellow', 'default:red'},
+ }
+})
+
+
+minetest.register_node("default:cyan", {
+ description = "Cyan",
+ tile_images = {"colour_cyan.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+minetest.register_node("default:red", {
+ description = "Red",
+ tile_images = {"colour_red.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+minetest.register_node("default:magenta", {
+ description = "Magenta",
+ tile_images = {"colour_magenta.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+minetest.register_node("default:white", {
+ description = "White",
+ tile_images = {"colour_white.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+minetest.register_node("default:blue", {
+ description = "Blue",
+ tile_images = {"colour_blue.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+minetest.register_node("default:yellow", {
+ description = "Yellow",
+ tile_images = {"colour_yellow.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+minetest.register_node("default:grey", {
+ description = "Grey",
+ tile_images = {"colour_grey.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+minetest.register_node("default:black", {
+ description = "Black",
+ tile_images = {"colour_black.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+minetest.register_node("default:green", {
+ description = "Green",
+ tile_images = {"colour_green.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+minetest.register_node("default:brown", {
+ description = "Brown",
+ tile_images = {"colour_brown.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+
+minetest.register_node("default:orange", {
+ description = "Orange",
+ tile_images = {"colour_orange.png"},
+ is_ground_content = true,
+ material = minetest.digprop_woodlike(0.25),
+})
+
+-- bucket (Minetest 0.4 mod)
+
+minetest.register_alias("bucket", "bucket:bucket_empty")
+minetest.register_alias("bucket_water", "bucket:bucket_water")
+minetest.register_alias("bucket_lava", "bucket:bucket_lava")
+
+minetest.register_craft({
+ output = 'bucket:bucket_empty 1',
+ recipe = {
+ {'default:steel_ingot', '', 'default:steel_ingot'},
+ {'', 'default:steel_ingot', ''},
+ }
+})
+
+bucket = {}
+bucket.liquids = {}
+
+-- Register a new liquid
+-- source = name of the source node
+-- flowing = name of the flowing node
+-- itemname = name of the new bucket item (or nil if liquid is not takeable)
+-- inventory_image = texture of the new bucket item (ignored if itemname == nil)
+-- This function can be called from any mod (that depends on bucket).
+function bucket.register_liquid(source, flowing, itemname, inventory_image)
+ bucket.liquids[source] = {
+ source = source,
+ flowing = flowing,
+ itemname = itemname,
+ }
+ bucket.liquids[flowing] = bucket.liquids[source]
+
+ if itemname ~= nil then
+ minetest.register_craftitem(itemname, {
+ inventory_image = inventory_image,
+ stack_max = 1,
+ liquids_pointable = true,
+ on_use = function(itemstack, user, pointed_thing)
+ -- Must be pointing to node
+ if pointed_thing.type ~= "node" then
+ return
+ end
+ -- Check if pointing to a liquid
+ n = minetest.env:get_node(pointed_thing.under)
+ if bucket.liquids[n.name] == nil then
+ -- Not a liquid
+ minetest.env:add_node(pointed_thing.above, {name=source})
+ elseif n.name ~= source then
+ -- It's a liquid
+ minetest.env:add_node(pointed_thing.under, {name=source})
+ end
+ return {name="bucket:bucket_empty"}
+ end
+ })
+ end
+end
+
+minetest.register_craftitem("bucket:bucket_empty", {
+ inventory_image = "bucket.png",
+ stack_max = 1,
+ liquids_pointable = true,
+ on_use = function(itemstack, user, pointed_thing)
+ -- Must be pointing to node
+ if pointed_thing.type ~= "node" then
+ return
+ end
+ -- Check if pointing to a liquid source
+ n = minetest.env:get_node(pointed_thing.under)
+ liquiddef = bucket.liquids[n.name]
+ if liquiddef ~= nil and liquiddef.source == n.name and liquiddef.itemname ~= nil then
+ minetest.env:add_node(pointed_thing.under, {name="air"})
+ return {name=liquiddef.itemname}
+ end
+ end,
+})
+
+bucket.register_liquid(
+ "default:water_source",
+ "default:water_flowing",
+ "bucket:bucket_water",
+ "bucket_water.png"
+)
+
+bucket.register_liquid(
+ "default:lava_source",
+ "default:lava_flowing",
+ "bucket:bucket_lava",
+ "bucket_lava.png"
+)
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "default:bucket_lava",
+ burntime = 60,
+})
+
+--Ropes--
+
+minetest.register_on_placenode(function(pos, newnode, placer)
+ if newnode.name == "default:rope" then
+ place_rope(pos, newnode, placer)
+ end
+ end
+)
+
+minetest.register_on_dignode(function(pos, oldnode, digger)
+ if oldnode.name == "default:rope" then
+ remove_rope(pos, oldnode, digger, true)
+ end
+ end
+)
+
+minetest.register_on_punchnode(function(pos, oldnode, digger)
+ if oldnode.name == "default:rope" then
+ remove_rope(pos, oldnode, digger, false)
+ end
+ end
+)
+
+-- helper function
+inventory_find_item = function (object, name, item)
+ local inventory = object:inventory_get_list(name)
+ for key, value in pairs(inventory) do
+ if value == item then
+ return key, value
+ end
+ end
+ return nil, nil
+end
+
+place_rope = function (pos, newnode, placer)
+ local inventory = placer:inventory_get_list("main")
+ local witem = placer:get_wielded_itemstring()
+ local windex, witem = inventory_find_item(placer, "main", witem)
+ local param2 = newnode.param2
+ while witem ~= nil and witem:len() ~= 0 do
+ pos.y = pos.y - 1
+ if minetest.env:get_node(pos).name ~= "air" then
+ break
+ end
+ if minetest.env:add_node(pos, {name="default:rope", param2=param2}) ~= true
+ then
+ break
+ end
+ witem = stackstring_take_item(witem)
+ end
+ if windex == nil then
+ else
+ inventory[windex] = witem
+ placer:inventory_set_list("main", inventory)
+ end
+end
+
+remove_rope = function(pos, oldnode, digger, completely)
+ local num = 0
+ local below = pos
+ local above = pos
+ if completely == true then
+ above.y = above.y + 1
+ while minetest.env:get_node(above).name == "default:rope" do
+ minetest.env:remove_node(above)
+ above.y = above.y + 1
+ num = num + 1
+ end
+ end
+ below.y = below.y - 1
+ while minetest.env:get_node(below).name == "default:rope" do
+ minetest.env:remove_node(below)
+ below.y = below.y -1
+ num = num + 1
+ end
+ if num ~= 0 then
+ digger:add_to_inventory_later('node "default:rope" ' .. num)
+ end
+ return true
+end
+
+minetest.register_craft({
+ output = 'default:rope 16',
+ recipe = {
+ {'', 'tree', ''},
+ {'', 'tree', ''},
+ {'', 'tree', ''},
+ }
+})
+
+minetest.register_node("default:rope", {
+ drawtype = "signlike",
+ tile_images = {"rope2.png"},
+ inventory_image = "rope2.png",
+ light_propagates = true,
+ paramtype = "light",
+ is_ground_content = true,
+ wall_mounted = true,
+ walkable = false,
+ climbable = true,
+ selection_box = {
+ type = "wallmounted",
+ --wall_top = = <default>
+ --wall_bottom = = <default>
+ --wall_side = = <default>
+ },
+ furnace_burntime = 5,
+ material = {
+ diggablity = "normal",
+ cuttability = 1.5,
+ },
+})
+
+--
+-- Done, print some random stuff
+--
+
+--print("minetest.registered_entities:")
+--dump2(minetest.registered_entities)
+
+-- END
--- /dev/null
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 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.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, 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 or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+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 give any other recipients of the Program a copy of this License
+along with the Program.
+
+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 Program or any portion
+of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+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 Program, 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 Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) 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; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, 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 executable. However, as a
+special exception, the source code 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.
+
+If distribution of executable or 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 counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program 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.
+
+ 5. 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 Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program 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 to
+this License.
+
+ 7. 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 Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program 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 Program.
+
+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.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program 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.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the 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 Program
+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 Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, 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
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), 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 Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. 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 program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; 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.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
/*
-Minetest-m13
+Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
/*
SQLite format specification:
- Initially only replaces sectors/ and sectors2/
-
+
If map.sqlite does not exist in the save dir
or the block was not found in the database
the map will try to load from sectors folder.
In either case, map.sqlite will be created
and all future saves will save there.
-
+
Structure of map.sqlite:
Tables:
blocks
MapSector * sector = m_sector_cache;
return sector;
}
-
+
core::map<v2s16, MapSector*>::Node *n = m_sectors.find(p);
-
+
if(n == NULL)
return NULL;
-
+
MapSector *sector = n->getValue();
-
+
// Cache the last result
m_sector_cache_p = p;
m_sector_cache = sector;
MapSector *sector = getSectorNoGenerateNoEx(p);
if(sector == NULL)
throw InvalidPositionException();
-
+
return sector;
}
}
MapBlock * Map::getBlockNoCreate(v3s16 p3d)
-{
+{
MapBlock *block = getBlockNoCreateNoEx(p3d);
if(block == NULL)
throw InvalidPositionException();
v3s16(0,-1,0), // bottom
v3s16(-1,0,0), // left
};
-
+
if(from_nodes.size() == 0)
return;
-
+
u32 blockchangecount = 0;
core::map<v3s16, u8> unlighted_nodes;
MapBlock *block = NULL;
// Cache this a bit, too
bool block_checked_in_modified = false;
-
+
for(; j.atEnd() == false; j++)
{
v3s16 pos = j.getNode()->getKey();
v3s16 blockpos = getNodeBlockPos(pos);
-
+
// Only fetch a new block if the block position has changed
try{
if(block == NULL || blockpos != blockpos_last){
}
}
-
+
/*
Enable this to disable proper lighting for speeding up map
generation for testing or whatever
/*
Add intial metadata
*/
-
+
std::string metadata_name = nodemgr->get(n).metadata_name;
if(metadata_name != ""){
NodeMetadata *meta = NodeMetadata::create(metadata_name, m_gamedef);
core::list<v3s16> *unloaded_blocks)
{
bool save_before_unloading = (mapType() == MAPTYPE_SERVER);
-
+
// Profile modified reasons
Profiler modprofiler;
-
+
core::list<v2s16> sector_deletion_queue;
u32 deleted_blocks_count = 0;
u32 saved_blocks_count = 0;
core::list<MapBlock*> blocks;
sector->getBlocks(blocks);
-
+
for(core::list<MapBlock*>::Iterator i = blocks.begin();
i != blocks.end(); i++)
{
MapBlock *block = (*i);
-
+
block->incrementUsageTimer(dtime);
-
+
if(block->getUsageTimer() > unload_timeout)
{
v3s16 p = block->getPos();
}
}
endSave();
-
+
// Finally delete the empty sectors
deleteSectors(sector_deletion_queue);
-
+
if(deleted_blocks_count != 0)
{
PrintInfo(infostream); // ServerMap/ClientMap:
i != blocks.end(); i++)
{
MapBlock *block = (*i);
-
+
if(block->getUsageTimer() > timeout)
{
// Save if modified
// list of nodes that due to viscosity have not reached their max level height
UniqueQueue<v3s16> must_reflow;
-
+
// List of MapBlocks that will require a lighting update (due to lava)
core::map<v3s16, MapBlock*> lighting_modified_blocks;
}
break;
case LIQUID_SOURCE:
- // if this node is not (yet) of a liquid type, choose the first liquid type we encounter
+ // if this node is not (yet) of a liquid type, choose the first liquid type we encounter
if (liquid_kind == CONTENT_AIR)
liquid_kind = nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing);
if (nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing) != liquid_kind) {
if(enable_mapgen_debug_info)
infostream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl;
-
+
// Do nothing if not inside limits (+-1 because of neighbors)
if(blockpos_over_limit(blockpos - v3s16(1,1,1)) ||
blockpos_over_limit(blockpos + v3s16(1,1,1)))
data->no_op = true;
return;
}
-
+
data->no_op = false;
data->seed = m_seed;
data->blockpos = blockpos;
*/
{
//TimeTaker timer("initBlockMake() create area");
-
+
for(s16 x=-1; x<=1; x++)
for(s16 z=-1; z<=1; z++)
{
}
}
}
-
+
/*
Now we have a big empty area.
Make a ManualMapVoxelManipulator that contains this and the
neighboring blocks
*/
-
+
// The area that contains this block and it's neighbors
v3s16 bigarea_blocks_min = blockpos - v3s16(1,1,1);
v3s16 bigarea_blocks_max = blockpos + v3s16(1,1,1);
-
+
data->vmanip = new ManualMapVoxelManipulator(this);
//data->vmanip->setMap(this);
v3s16 p = data->transforming_liquid.pop_front();
m_transforming_liquid.push_back(p);
}
-
+
/*
Get central block
*/
}*/
#endif
updateLighting(lighting_update_blocks, changed_blocks);
-
+
/*
Set lighting to non-expired state in all of them.
This is cheating, but it is not fast enough if all of them
Set central block as generated
*/
block->setGenerated(true);
-
+
/*
Save changed parts of map
NOTE: Will be saved later.
DSTACKF("%s: p2d=(%d,%d)",
__FUNCTION_NAME,
p2d.X, p2d.Y);
-
+
/*
Check if it exists already in memory
*/
ServerMapSector *sector = (ServerMapSector*)getSectorNoGenerateNoEx(p2d);
if(sector != NULL)
return sector;
-
+
/*
Try to load it from disk (with blocks)
*/
/*
Generate blank sector
*/
-
+
sector = new ServerMapSector(this, p2d, m_gamedef);
-
+
// Sector position on map in nodes
v2s16 nodepos2d = p2d * MAP_BLOCKSIZE;
Insert to container
*/
m_sectors.insert(p2d, sector);
-
+
return sector;
}
)
{
DSTACKF("%s: p=(%d,%d,%d)", __FUNCTION_NAME, p.X, p.Y, p.Z);
-
+
/*infostream<<"generateBlock(): "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;*/
-
+
bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
TimeTaker timer("generateBlock");
-
+
//MapBlock *block = original_dummy;
-
+
v2s16 p2d(p.X, p.Z);
v2s16 p2d_nodes = p2d * MAP_BLOCKSIZE;
-
+
/*
Do not generate over-limit
*/
{
DSTACKF("%s: p=(%d,%d,%d)",
__FUNCTION_NAME, p.X, p.Y, p.Z);
-
+
/*
Do not create over-limit
*/
|| p.Z < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
|| p.Z > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
throw InvalidPositionException("createBlock(): pos. over limit");
-
+
v2s16 p2d(p.X, p.Z);
s16 block_y = p.Y;
/*
DSTACKF("%s: p=(%d,%d,%d), allow_generate=%d",
__FUNCTION_NAME,
p.X, p.Y, p.Z, allow_generate);
-
+
{
MapBlock *block = getBlockNoCreateNoEx(p);
if(block && block->isDummy() == false)
// Queue event
dispatchEvent(&event);
-
+
return block;
}
}
/*
Determine from map generator noise functions
*/
-
+
s16 level = mapgen::find_ground_level_from_noise(m_seed, p2d, 1);
return level;
void ServerMap::verifyDatabase() {
if(m_database)
return;
-
+
{
std::string dbp = m_savedir + DIR_DELIM + "map.sqlite";
bool needs_create = false;
int d;
-
+
/*
Open the database connection
*/
-
+
createDirs(m_savedir);
-
+
if(!fs::PathExists(dbp))
needs_create = true;
-
+
d = sqlite3_open_v2(dbp.c_str(), &m_database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
if(d != SQLITE_OK) {
infostream<<"WARNING: Database failed to open: "<<sqlite3_errmsg(m_database)<<std::endl;
throw FileNotGoodException("Cannot open database file");
}
-
+
if(needs_create)
createDatabase();
-
+
d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL);
if(d != SQLITE_OK) {
infostream<<"WARNING: Database read statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
throw FileNotGoodException("Cannot prepare read statement");
}
-
+
d = sqlite3_prepare(m_database, "REPLACE INTO `blocks` VALUES(?, ?)", -1, &m_database_write, NULL);
if(d != SQLITE_OK) {
infostream<<"WARNING: Database write statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
throw FileNotGoodException("Cannot prepare write statement");
}
-
+
d = sqlite3_prepare(m_database, "SELECT `pos` FROM `blocks`", -1, &m_database_list, NULL);
if(d != SQLITE_OK) {
infostream<<"WARNING: Database list statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
throw FileNotGoodException("Cannot prepare read statement");
}
-
+
infostream<<"Server: Database opened"<<std::endl;
}
}
infostream<<"WARNING: Not saving map, saving disabled."<<std::endl;
return;
}
-
+
if(save_level == MOD_STATE_CLEAN)
infostream<<"ServerMap: Saving whole map, this can take time."
<<std::endl;
-
+
if(m_map_metadata_changed || save_level == MOD_STATE_CLEAN)
{
saveMapMeta();
// Profile modified reasons
Profiler modprofiler;
-
+
u32 sector_meta_count = 0;
u32 block_count = 0;
u32 block_count_all = 0; // Number of blocks in memory
-
+
// Don't do anything with sqlite unless something is really saved
bool save_started = false;
{
ServerMapSector *sector = (ServerMapSector*)i.getNode()->getValue();
assert(sector->getId() == MAPSECTOR_SERVER);
-
+
if(sector->differs_from_disk || save_level == MOD_STATE_CLEAN)
{
saveSectorMeta(sector);
core::list<MapBlock*> blocks;
sector->getBlocks(blocks);
core::list<MapBlock*>::Iterator j;
-
+
for(j=blocks.begin(); j!=blocks.end(); j++)
{
MapBlock *block = *j;
-
+
block_count_all++;
if(block->getModified() >= save_level)
errorstream<<"Map::listAllLoadableBlocks(): Result will be missing "
<<"all blocks that are stored in flat files"<<std::endl;
}
-
+
{
verifyDatabase();
-
+
while(sqlite3_step(m_database_list) == SQLITE_ROW)
{
sqlite3_int64 block_i = sqlite3_column_int64(m_database_list, 0);
void ServerMap::saveMapMeta()
{
DSTACK(__FUNCTION_NAME);
-
+
infostream<<"ServerMap::saveMapMeta(): "
<<"seed="<<m_seed
<<std::endl;
createDirs(m_savedir);
-
+
std::string fullpath = m_savedir + DIR_DELIM + "map_meta.txt";
std::ofstream os(fullpath.c_str(), std::ios_base::binary);
if(os.good() == false)
<<"could not open"<<fullpath<<std::endl;
throw FileNotGoodException("Cannot open chunk metadata");
}
-
+
Settings params;
params.setU64("seed", m_seed);
params.writeLines(os);
os<<"[end_of_params]\n";
-
+
m_map_metadata_changed = false;
}
void ServerMap::loadMapMeta()
{
DSTACK(__FUNCTION_NAME);
-
+
infostream<<"ServerMap::loadMapMeta(): Loading map metadata"
<<std::endl;
v2s16 pos = sector->getPos();
std::string dir = getSectorDir(pos);
createDirs(dir);
-
+
std::string fullpath = dir + DIR_DELIM + "meta";
std::ofstream o(fullpath.c_str(), std::ios_base::binary);
if(o.good() == false)
throw FileNotGoodException("Cannot open sector metafile");
sector->serialize(o, version);
-
+
sector->differs_from_disk = false;
}
if(save_after_load)
saveSectorMeta(sector);
}
-
+
sector->differs_from_disk = false;
return sector;
{
return false;
}
-
+
return true;
}
{
return false;
}
-
+
/*
Load blocks
*/
u8 version = SER_FMT_VER_HIGHEST;
// Get destination
v3s16 p3d = block->getPos();
-
-
+
+
#if 0
v2s16 p2d(p3d.X, p3d.Z);
std::string sectordir = getSectorDir(p2d);
[0] u8 serialization version
[1] data
*/
-
+
verifyDatabase();
-
+
std::ostringstream o(std::ios_base::binary);
-
+
o.write((char*)&version, 1);
-
+
// Write basic data
block->serialize(o, version, true);
-
+
// Write block to database
-
+
std::string tmp = o.str();
const char *bytes = tmp.c_str();
-
+
if(sqlite3_bind_int64(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK)
infostream<<"WARNING: Block position failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl;
if(sqlite3_bind_blob(m_database_write, 2, (void *)bytes, o.tellp(), NULL) != SQLITE_OK) // TODO this mught not be the right length
<<sqlite3_errmsg(m_database)<<std::endl;
// Make ready for later reuse
sqlite3_reset(m_database_write);
-
+
// We just wrote it to the disk so clear modified flag
block->resetModified();
}
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
if(is.good() == false)
throw FileNotGoodException("Cannot open block file");
-
+
v3s16 p3d = getBlockPos(sectordir, blockfile);
v2s16 p2d(p3d.X, p3d.Z);
-
+
assert(sector->getPos() == p2d);
-
+
u8 version = SER_FMT_VER_INVALID;
is.read((char*)&version, 1);
block = sector->createBlankBlockNoInsert(p3d.Y);
created_new = true;
}
-
+
// Read basic data
block->deSerialize(is, version, true);
// If it's a new block, insert it to the map
if(created_new)
sector->insertBlock(block);
-
+
/*
Save blocks loaded in old format in new format
*/
if(version < SER_FMT_VER_HIGHEST || save_after_load)
{
saveBlock(block);
-
+
// Should be in database now, so delete the old file
fs::RecursiveDelete(fullpath);
}
-
+
// We just loaded it from the disk, so it's up-to-date.
block->resetModified();
try {
std::istringstream is(*blob, std::ios_base::binary);
-
+
u8 version = SER_FMT_VER_INVALID;
is.read((char*)&version, 1);
block = sector->createBlankBlockNoInsert(p3d.Y);
created_new = true;
}
-
+
// Read basic data
block->deSerialize(is, version, true);
-
+
// If it's a new block, insert it to the map
if(created_new)
sector->insertBlock(block);
-
+
/*
Save blocks loaded in old format in new format
*/
// Only save if asked to; no need to update version
if(save_after_load)
saveBlock(block);
-
+
// We just loaded it from, so it's up-to-date.
block->resetModified();
if(!loadFromFolders()) {
verifyDatabase();
-
+
if(sqlite3_bind_int64(m_database_read, 1, getBlockAsInteger(blockpos)) != SQLITE_OK)
infostream<<"WARNING: Could not bind block position for load: "
<<sqlite3_errmsg(m_database)<<std::endl;
Make sure sector is loaded
*/
MapSector *sector = createSector(p2d);
-
+
/*
Load block
*/
const char * data = (const char *)sqlite3_column_blob(m_database_read, 0);
size_t len = sqlite3_column_bytes(m_database_read, 0);
-
+
std::string datastr(data, len);
-
+
loadBlock(&datastr, blockpos, sector, false);
sqlite3_step(m_database_read);
return getBlockNoCreateNoEx(blockpos);
}
sqlite3_reset(m_database_read);
-
+
// Not found in database, try the files
}
loadlayout = 2;
sectordir = getSectorDir(p2d, 2);
}
-
+
/*
Make sure sector is loaded
*/
}
catch(InvalidFilenameException &e)
{
- return NULL;
+ return false;
}
catch(FileNotGoodException &e)
{
- return NULL;
+ return false;
}
catch(std::exception &e)
{
- return NULL;
+ return false;
}
}
-
+
/*
Make sure file exists
*/
{
m_camera_mutex.Init();
assert(m_camera_mutex.IsInitialized());
-
+
m_box = core::aabbox3d<f32>(-BS*1000000,-BS*1000000,-BS*1000000,
BS*1000000,BS*1000000,BS*1000000);
}
ClientMap::~ClientMap()
{
/*JMutexAutoLock lock(mesh_mutex);
-
+
if(mesh != NULL)
{
mesh->drop();
catch(InvalidPositionException &e)
{
}
-
+
// Create a sector
ClientMapSector *sector = new ClientMapSector(this, p2d, m_gamedef);
-
+
{
//JMutexAutoLock lock(m_sector_mutex); // Bulk comment-out
m_sectors.insert(p2d, sector);
}
-
+
return sector;
}
ClientMapSector *sector = NULL;
//JMutexAutoLock lock(m_sector_mutex); // Bulk comment-out
-
+
core::map<v2s16, MapSector*>::Node *n = m_sectors.find(p2d);
if(n != NULL)
DSTACK(__FUNCTION_NAME);
bool is_transparent_pass = pass == scene::ESNRP_TRANSPARENT;
-
+
std::string prefix;
if(pass == scene::ESNRP_SOLID)
prefix = "CM: solid: ";
/*
Get time for measuring timeout.
-
+
Measuring time is very useful for long delays when the
machine is swapping a lot.
*/
*/
v3s16 cam_pos_nodes = floatToInt(camera_position, BS);
-
+
v3s16 box_nodes_d = m_control.wanted_range * v3s16(1,1,1);
v3s16 p_nodes_min = cam_pos_nodes - box_nodes_d;
p_nodes_max.X / MAP_BLOCKSIZE + 1,
p_nodes_max.Y / MAP_BLOCKSIZE + 1,
p_nodes_max.Z / MAP_BLOCKSIZE + 1);
-
+
u32 vertex_count = 0;
u32 meshbuffer_count = 0;
-
+
// For limiting number of mesh updates per frame
u32 mesh_update_count = 0;
-
+
// Number of blocks in rendering range
u32 blocks_in_range = 0;
// Number of blocks occlusion culled
/*
Collect a set of blocks for drawing
*/
-
+
core::map<v3s16, MapBlock*> drawset;
{
{
MapSector *sector = si.getNode()->getValue();
v2s16 sp = sector->getPos();
-
+
if(m_control.range_all == false)
{
if(sp.X < p_blocks_min.X
core::list< MapBlock * > sectorblocks;
sector->getBlocks(sectorblocks);
-
+
/*
Loop through blocks in sector
*/
u32 sector_blocks_drawn = 0;
-
+
core::list< MapBlock * >::Iterator i;
for(i=sectorblocks.begin(); i!=sectorblocks.end(); i++)
{
Compare block position to camera position, skip
if not seen on display
*/
-
+
float range = 100000 * BS;
if(m_control.range_all == false)
range = m_control.wanted_range * BS;
continue;*/
blocks_in_range++;
-
+
#if 1
/*
Update expired mesh (used for day/night change)
*/
bool mesh_expired = false;
-
+
{
JMutexAutoLock lock(block->mesh_mutex);
f32 faraway = BS*50;
//f32 faraway = m_control.wanted_range * BS;
-
+
/*
This has to be done with the mesh_mutex unlocked
*/
(mesh_update_count < 3
&& (d < faraway || mesh_update_count < 2)
)
- ||
+ ||
(m_control.range_all && mesh_update_count < 20)
)
)
blocks_occlusion_culled++;
continue;
}
-
+
// This block is in range. Reset usage timer.
block->resetUsageTimer();
JMutexAutoLock lock(block->mesh_mutex);
scene::SMesh *mesh = block->mesh;
-
+
if(mesh == NULL){
blocks_in_range_without_mesh++;
continue;
}
}
-
+
// Limit block count in case of a sudden increase
blocks_would_have_drawn++;
if(blocks_drawn >= m_control.wanted_max_blocks
&& m_control.range_all == false
&& d > m_control.wanted_min_range * BS)
continue;
-
+
// Add to set
drawset[block->getPos()] = block;
-
+
sector_blocks_drawn++;
blocks_drawn++;
m_last_drawn_sectors[sp] = true;
}
} // ScopeProfiler
-
+
/*
Draw the selected MapBlocks
*/
}
}
}
-
+
MapBlock *block = i.getNode()->getValue();
/*
scene::SMesh *mesh = block->mesh;
assert(mesh);
-
+
u32 c = mesh->getMeshBufferCount();
bool stuff_actually_drawn = false;
for(u32 i=0; i<c; i++)
}
}
} // ScopeProfiler
-
+
// Log only on solid pass because values are the same
if(pass == scene::ESNRP_SOLID){
g_profiler->avg("CM: blocks in range", blocks_in_range);
(float)blocks_in_range_without_mesh/blocks_in_range);
g_profiler->avg("CM: blocks drawn", blocks_drawn);
}
-
+
g_profiler->avg(prefix+"vertices drawn", vertex_count);
if(blocks_had_pass_meshbuf != 0)
g_profiler->avg(prefix+"meshbuffers per block",
core::list< MapBlock * > sectorblocks;
sector->getBlocks(sectorblocks);
-
+
core::list< MapBlock * >::Iterator i;
for(i=sectorblocks.begin(); i!=sectorblocks.end(); i++)
{
{
continue;
}
-
+
{
JMutexAutoLock lock(block->mesh_mutex);
if(block->mesh != NULL)
n = m_loaded_blocks.find(p);
if(n != NULL)
continue;
-
+
bool block_data_inexistent = false;
try
{
<<" wanted area: ";
a.print(infostream);
infostream<<std::endl;*/
-
+
MapBlock *block = m_map->getBlockNoCreate(p);
if(block->isDummy())
block_data_inexistent = true;
{
if(m_area.getExtent() == v3s16(0,0,0))
return;
-
+
//TimeTaker timer1("blitBack");
/*infostream<<"blitBack(): m_loaded_blocks.size()="
<<m_loaded_blocks.size()<<std::endl;*/
-
+
/*
Initialize block cache
*/
continue;
MapNode &n = m_data[m_area.index(p)];
-
+
v3s16 blockpos = getNodeBlockPos(p);
-
+
try
{
// Get block
blockpos_last = blockpos;
block_checked_in_modified = false;
}
-
+
// Calculate relative position in block
v3s16 relpos = p - blockpos * MAP_BLOCKSIZE;
//m_map->setNode(m_area.MinEdge + p, n);
block->setNode(relpos, n);
-
+
/*
Make sure block is in modified_blocks
*/
VoxelArea block_area_nodes
(p_min*MAP_BLOCKSIZE, (p_max+1)*MAP_BLOCKSIZE-v3s16(1,1,1));
-
+
u32 size_MB = block_area_nodes.getVolume()*4/1000000;
if(size_MB >= 1)
{
n = m_loaded_blocks.find(p);
if(n != NULL)
continue;
-
+
bool block_data_inexistent = false;
try
{
{
if(m_area.getExtent() == v3s16(0,0,0))
return;
-
+
/*
Copy data of all blocks
*/