code:
[3d_armor]

armor_material_wood (Enable wood armor) bool true
armor_material_cactus (Enable cactus armor) bool true
armor_material_steel (Enable steel armor) bool true
armor_material_bronze (Enable bronze armor) bool true
armor_material_diamond (Enable diamond armor) bool true
armor_material_gold (Enable gold armor) bool true
armor_material_mithril (Enable mithril armor) bool true
armor_material_crystal (Enable crystal armor) bool true

# Increase this if you get initialization glitches when a player first joins.
armor_init_delay (Initialization delay) int 2

# Number of initialization attempts.
# Use in conjunction with armor_init_delay if initialization problems persist.
armor_init_times (Initialization attempts) int 10

# Increase this if armor is not getting into bones due to server lag.
armor_bones_delay (Delay for bones) int 1

# How often player armor items are updated.
armor_update_time (Armor refresh rate [seconds]) int 1

# Drop armor when a player dies.
# Uses bones mod if present, otherwise items are dropped around the player.
armor_drop (Drop armor on death) bool true

# Pulverize armor when a player dies, overrides armor_drop.
armor_destroy (Pulverize armor on death) bool false

# You can use this to increase or decrease overall armor effectiveness,
# eg: level_multiplier = 0.5 will reduce armor level by half.
armor_level_multiplier (Armor effectiveness multiplier) float 1

# You can use this to increase or decrease overall armor healing,
# eg: armor_heal_multiplier = 0 will disable healing altogether.
armor_heal_multiplier (Armor healing multiplier) float 1

# Enable water protection (periodically restores breath when activated).
armor_water_protect (Enable water protection) bool true

# Enable fire protection (defaults true if using ethereal mod).
armor_fire_protect (Enable fire protection) bool false

# Enable punch damage effects.
armor_punch_damage (Enable damage effects) bool true

# Enable migration of old armor inventories.
armor_migrate_old_inventory (Migrate old armor inventories) bool true

[shields]

shields_disable_sounds (Disable shield sounds) bool false

[wieldview]

# Set number of seconds between visible wielded item updates.
wieldview_update_time (Wieldview refresh rate [seconds]) int 2

# Show nodes as tiles, disabled by default.
wieldview_node_tiles (Show nodes as tiles) bool false


code:
[mod] Shields [shields]
=======================

Adds shields to 3d_armor

Depends: 3d_armor

Originally a part of 3d_armor, shields have been re-included as an optional extra.
If you do not what shields then simply remove the shields folder from the modpack.

Shields Configuration
---------------------

Override the following default settings by adding them to your minetest.conf file.

shields_disable_sounds = false

repo_name: korkut/MeseCraft

license: mit


code:
Shields -- Crafting Guide
--------------------------

+---+---+---+
| X | X | X |
+---+---+---+
| X | X | X |
+---+---+---+
|   | X |   |
+---+---+---+

[shields:shield_wood] X = [default:wood]
[shields:shield_cactus] X = [default:cactus]
[shields:shield_steel] X = [default:steel_ingot]
[shields:shield_bronze] X = [default:bronze_ingot]
[shields:shield_diamond] X = [default:diamond]
[shields:shield_gold] X = [default:gold_ingot]
[shields:shield_mithril] X = [moreores:mithril_ingot]
[shields:shield_crystal] X = [ethereal:crystal_ingot]

Enhanced Shields
----------------

+---+
| S |
+---+
| X |
+---+
| S |
+---+

[shields:shield_enhanced_wood] X = [shields:shield_wood]
[shields:shield_enhanced_cactus] X = [shields:shield_cactus]

S = [default:steel_ingot]


code: Adds visible shields to 3d armor.


code:
-- support for i18n
local S = minetest.get_translator(minetest.get_current_modname())

local disable_sounds = minetest.settings:get_bool("shields_disable_sounds")
local function play_sound_effect(player, name)
	if not disable_sounds and player then
		local pos = player:get_pos()
		if pos then
			minetest.sound_play(name, {
				pos = pos,
				max_hear_distance = 10,
				gain = 0.5,
			})
		end
	end
end

if minetest.global_exists("armor") and armor.elements then
	table.insert(armor.elements, "shield")
	local mult = armor.config.level_multiplier or 1
	armor.config.level_multiplier = mult * 0.9
end

-- Regisiter Shields

armor:register_armor("shields:shield_admin", {
	description = S("Admin Shield"),
	inventory_image = "shields_inv_shield_admin.png",
	groups = {armor_shield=1000, armor_heal=100, armor_use=0, not_in_creative_inventory=1},
})

minetest.register_alias("adminshield", "shields:shield_admin")

if armor.materials.wood then
	armor:register_armor("shields:shield_wood", {
		description = S("Wooden Shield"),
		inventory_image = "shields_inv_shield_wood.png",
		groups = {armor_shield=1, armor_heal=0, armor_use=2000, flammable=1},
		armor_groups = {fleshy=5},
		damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=1},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_wood_footstep")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_wood_footstep")
		end,
	})
	armor:register_armor("shields:shield_enhanced_wood", {
		description = S("Enhanced Wood Shield"),
		inventory_image = "shields_inv_shield_enhanced_wood.png",
		groups = {armor_shield=1, armor_heal=0, armor_use=2000},
		armor_groups = {fleshy=8},
		damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=2},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_dig_metal")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_dug_metal")
		end,
	})
	minetest.register_craft({
		output = "shields:shield_enhanced_wood",
		recipe = {
			{"default:steel_ingot"},
			{"shields:shield_wood"},
			{"default:steel_ingot"},
		},
	})
	minetest.register_craft({
		type = "fuel",
		recipe = "shields:shield_wood",
		burntime = 8,
	})
end

if armor.materials.cactus then
	armor:register_armor("shields:shield_cactus", {
		description = S("Cactus Shield"),
		inventory_image = "shields_inv_shield_cactus.png",
		groups = {armor_shield=1, armor_heal=0, armor_use=1000},
		armor_groups = {fleshy=5},
		damage_groups = {cracky=3, snappy=3, choppy=2, crumbly=2, level=1},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_wood_footstep")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_wood_footstep")
		end,
	})
	armor:register_armor("shields:shield_enhanced_cactus", {
		description = S("Enhanced Cactus Shield"),
		inventory_image = "shields_inv_shield_enhanced_cactus.png",
		groups = {armor_shield=1, armor_heal=0, armor_use=1000},
		armor_groups = {fleshy=8},
		damage_groups = {cracky=3, snappy=3, choppy=2, crumbly=2, level=2},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_dig_metal")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_dug_metal")
		end,
	})
	minetest.register_craft({
		output = "shields:shield_enhanced_cactus",
		recipe = {
			{"default:steel_ingot"},
			{"shields:shield_cactus"},
			{"default:steel_ingot"},
		},
	})
	minetest.register_craft({
		type = "fuel",
		recipe = "shields:shield_cactus",
		burntime = 16,
	})
end

if armor.materials.steel then
	armor:register_armor("shields:shield_steel", {
		description = S("Steel Shield"),
		inventory_image = "shields_inv_shield_steel.png",
		groups = {armor_shield=1, armor_heal=0, armor_use=800,
			physics_speed=-0.03, physics_gravity=0.03},
		armor_groups = {fleshy=10},
		damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_dig_metal")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_dug_metal")
		end,
	})
end

if armor.materials.bronze then
	armor:register_armor("shields:shield_bronze", {
		description = S("Bronze Shield"),
		inventory_image = "shields_inv_shield_bronze.png",
		groups = {armor_shield=1, armor_heal=6, armor_use=400,
			physics_speed=-0.03, physics_gravity=0.03},
		armor_groups = {fleshy=10},
		damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_dig_metal")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_dug_metal")
		end,
	})
end

if armor.materials.diamond then
	armor:register_armor("shields:shield_diamond", {
		description = S("Diamond Shield"),
		inventory_image = "shields_inv_shield_diamond.png",
		groups = {armor_shield=1, armor_heal=12, armor_use=200},
		armor_groups = {fleshy=15},
		damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_glass_footstep")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_break_glass")
		end,
	})
end

if armor.materials.gold then
	armor:register_armor("shields:shield_gold", {
		description = S("Gold Shield"),
		inventory_image = "shields_inv_shield_gold.png",
		groups = {armor_shield=1, armor_heal=6, armor_use=300,
			physics_speed=-0.04, physics_gravity=0.04},
		armor_groups = {fleshy=10},
		damage_groups = {cracky=1, snappy=2, choppy=2, crumbly=3, level=2},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_dig_metal")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_dug_metal")
		end,
	})
end

if armor.materials.mithril then
	armor:register_armor("shields:shield_mithril", {
		description = S("Mithril Shield"),
		inventory_image = "shields_inv_shield_mithril.png",
		groups = {armor_shield=1, armor_heal=12, armor_use=100},
		armor_groups = {fleshy=15},
		damage_groups = {cracky=2, snappy=1, level=3},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_glass_footstep")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_break_glass")
		end,
	})
end

if armor.materials.crystal then
	armor:register_armor("shields:shield_crystal", {
		description = S("Crystal Shield"),
		inventory_image = "shields_inv_shield_crystal.png",
		groups = {armor_shield=1, armor_heal=12, armor_use=100, armor_fire=1},
		armor_groups = {fleshy=15},
		damage_groups = {cracky=2, snappy=1, level=3},
		reciprocate_damage = true,
		on_damage = function(player, index, stack)
			play_sound_effect(player, "default_glass_footstep")
		end,
		on_destroy = function(player, index, stack)
			play_sound_effect(player, "default_break_glass")
		end,
	})
end

for k, v in pairs(armor.materials) do
	minetest.register_craft({
		output = "shields:shield_"..k,
		recipe = {
			{v, v, v},
			{v, v, v},
			{"", v, ""},
		},
	})
end


code:
# textdomain: shields

### init.lua ###

Admin Shield=Bouclier d'admin
Bronze Shield=Bouclier en bronze
Cactus Shield=Bouclier en cactus
Crystal Shield=Bouclier en cristal
Diamond Shield=Bouclier en diamant
Enhanced Cactus Shield=Bouclier en cactus amélioré
Enhanced Wood Shield=Bouclier en bois amélioré
Gold Shield=Bouclier en or
Mithril Shield=Bouclier en mithril
Steel Shield=Bouclier en acier
Wooden Shield=Bouclier en bois


code:
# textdomain: shields

### init.lua ###

Admin Shield=
Bronze Shield=
Cactus Shield=
Crystal Shield=
Diamond Shield=
Enhanced Cactus Shield=
Enhanced Wood Shield=
Gold Shield=
Mithril Shield=
Steel Shield=
Wooden Shield=


code:
name = shields
depends = default, 3d_armor
description = Adds visible shields to 3d armor.


code:
[mod] visible wielded items [wieldview]
=======================================

Depends on: 3d_armor

Makes hand wielded items visible to other players.

default settings: [minetest.conf]

# Set number of seconds between visible wielded item updates.
wieldview_update_time = 2

# Show nodes as tiles, disabled by default
wieldview_node_tiles = false

Info for modders
################

Wield image transformation: To apply a simple transformation to the item in
hand, add the group “wieldview_transform” to the item definition. The group
rating equals one of the numbers used for the [transform texture modifier
of the Lua API.

Disabling the feature in-game: If you want to hide the wielded item
you can add an INT metadata to the player called "show_wielded_item" and set
it to 2 (any other value will show the wielded item again).


code: Makes hand wielded items visible to other players.


code:
local time = 0
local update_time = tonumber(minetest.settings:get("wieldview_update_time"))
if not update_time then
	update_time = 2
	minetest.settings:set("wieldview_update_time", tostring(update_time))
end
local node_tiles = minetest.settings:get_bool("wieldview_node_tiles")
if not node_tiles then
	node_tiles = false
	minetest.settings:set("wieldview_node_tiles", "false")
end

wieldview = {
	wielded_item = {},
	transform = {},
}

dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua")

wieldview.get_item_texture = function(self, item)
	local texture = "3d_armor_trans.png"
	if item ~= "" then
		if minetest.registered_items[item] then
			if minetest.registered_items[item].inventory_image ~= "" then
				texture = minetest.registered_items[item].inventory_image
			elseif node_tiles == true and minetest.registered_items[item].tiles
					and type(minetest.registered_items[item].tiles[1]) == "string"
					and minetest.registered_items[item].tiles[1] ~= "" then
				texture = minetest.inventorycube(minetest.registered_items[item].tiles[1])
			end
		end
		-- Get item image transformation, first from group, then from transform.lua
		local transform = minetest.get_item_group(item, "wieldview_transform")
		if transform == 0 then
			transform = wieldview.transform[item]
		end
		if transform then
			-- This actually works with groups ratings because transform1, transform2, etc.
			-- have meaning and transform0 is used for identidy, so it can be ignored
			texture = texture.."^[transform"..tostring(transform)
		end
	end
	return texture
end

wieldview.update_wielded_item = function(self, player)
	if not player then
		return
	end
	local name = player:get_player_name()
	local stack = player:get_wielded_item()
	local item = stack:get_name()
	if not item then
		return
	end
	if self.wielded_item[name] then
		if player:get_meta():get_int("show_wielded_item") == 2 then
			item = ""
		end
		if self.wielded_item[name] == item then
			return
		end
		armor.textures[name].wielditem = self:get_item_texture(item)
		armor:update_player_visuals(player)
	end
	self.wielded_item[name] = item
end

minetest.register_on_joinplayer(function(player)
	local name = player:get_player_name()
	wieldview.wielded_item[name] = ""
	minetest.after(0, function()
		local pplayer = minetest.get_player_by_name(name)
		if player then
			wieldview:update_wielded_item(pplayer)
		end
	end)
end)

minetest.register_globalstep(function(dtime)
	time = time + dtime
	if time > update_time then
		for _,player in ipairs(minetest.get_connected_players()) do
			wieldview:update_wielded_item(player)
		end
		time = 0
	end
end)


code:
name = wieldview
depends = 3d_armor
description = Makes hand wielded items visible to other players.


code:
-- Wielded Item Transformations - http://dev.minetest.net/texture

wieldview.transform = {
	["default:torch"]="R270",
	["default:sapling"]="R270",
	["flowers:dandelion_white"]="R270",
	["flowers:dandelion_yellow"]="R270",
	["flowers:geranium"]="R270",
	["flowers:rose"]="R270",
	["flowers:tulip"]="R270",
	["flowers:viola"]="R270",
	["mesecraft_bucket:bucket_empty"]="R270",
	["mesecraft_bucket:bucket_water"]="R270",
	["mesecraft_bucket:bucket_lava"]="R270",
	["screwdriver:screwdriver"]="R270",
	["screwdriver:screwdriver1"]="R270",
	["screwdriver:screwdriver2"]="R270",
	["screwdriver:screwdriver3"]="R270",
	["screwdriver:screwdriver4"]="R270",
	["vessels:glass_bottle"]="R270",
	["vessels:drinking_glass"]="R270",
	["vessels:steel_bottle"]="R270",
}


code:
Baked Clay

This mod lets the player bake clay into hardened blocks and colour them with
dye (8x baked clay and 1x dye in centre), stairs and slabs are also available.

https://forum.minetest.net/viewtopic.php?id=8890

Changelog:

- 0.9 - Baked clay now works in the technic cnc machine
- 0.8 - Cooking clay block in furnace gives natural baked clay which you can dye
- 0.7 - Added support for stairsplus so that stairs are registered properly
- 0.6 - Added 3 new flowers and a new grass that are used for missing dyes
- 0.5 - Now using minecraft recipe to colour baked clay (8x baked clay, 1x dye in centre)
- 0.4 - Code tweak and tidy
- 0.3 - Added Stairs and Slabs for each colour
- 0.2 - Any colour of baked clay can be re-dyed into another colour
- 0.1 - Initial Release

Lucky Blocks: 9


code:
-- Baked Clay by TenPlus1

local clay = {
	{"natural", "Natural"},
	{"white", "White"},
	{"grey", "Grey"},
	{"black", "Black"},
	{"red", "Red"},
	{"yellow", "Yellow"},
	{"green", "Green"},
	{"cyan", "Cyan"},
	{"blue", "Blue"},
	{"magenta", "Magenta"},
	{"orange", "Orange"},
	{"violet", "Violet"},
	{"brown", "Brown"},
	{"pink", "Pink"},
	{"dark_grey", "Dark Grey"},
	{"dark_green", "Dark Green"},
}

local techcnc_mod = minetest.get_modpath("technic_cnc")
local stairs_mod = minetest.get_modpath("stairs")
local stairsplus_mod = minetest.get_modpath("moreblocks")
	and minetest.global_exists("stairsplus")

for _, clay in pairs(clay) do

	-- node definition

	minetest.register_node("bakedclay:" .. clay[1], {
		description = clay[2] .. " Baked Clay",
		tiles = {"baked_clay_" .. clay[1] ..".png"},
		groups = {cracky = 3, bakedclay = 1},
		sounds = default.node_sound_stone_defaults(),
	})

	-- craft from dye and any baked clay
	if clay[1] ~= "natural" then
		minetest.register_craft({
			output = "bakedclay:" .. clay[1] .. " 8",
			recipe = {
				{"group:bakedclay", "group:bakedclay", "group:bakedclay"},
				{"group:bakedclay", "dye:" .. clay[1], "group:bakedclay"},
				{"group:bakedclay", "group:bakedclay", "group:bakedclay"}
			},
		})
	end

	-- register stairsplus stairs if found
	if stairsplus_mod then

		stairsplus:register_all("bakedclay", "baked_clay_" .. clay[1], "bakedclay:" .. clay[1], {
			description = clay[2] .. " Baked Clay",
			tiles = {"baked_clay_" .. clay[1] .. ".png"},
			groups = {cracky = 3},
			sounds = default.node_sound_stone_defaults(),
		})

		stairsplus:register_alias_all("bakedclay", clay[1], "bakedclay", "baked_clay_" .. clay[1])
		minetest.register_alias("stairs:slab_bakedclay_".. clay[1], "bakedclay:slab_baked_clay_" .. clay[1])
		minetest.register_alias("stairs:stair_bakedclay_".. clay[1], "bakedclay:stair_baked_clay_" .. clay[1])

	-- register all stair types for stairs redo
	elseif stairs_mod and stairs.mod then

		stairs.register_all("bakedclay_" .. clay[1], "bakedclay:" .. clay[1],
			{cracky = 3},
			{"baked_clay_" .. clay[1] .. ".png"},
			clay[2] .. " Baked Clay",
			default.node_sound_stone_defaults())

	-- register stair and slab using default stairs
	elseif stairs_mod then

		stairs.register_stair_and_slab("bakedclay_".. clay[1], "bakedclay:".. clay[1],
			{cracky = 3},
			{"baked_clay_" .. clay[1] .. ".png"},
			clay[2] .. " Baked Clay Stair",
			clay[2] .. " Baked Clay Slab",
			default.node_sound_stone_defaults())
	end

	-- register bakedclay for use in technic_cnc mod
	if techcnc_mod then

		technic_cnc.register_all("bakedclay:" .. clay[1],
		{cracky = 3, not_in_creative_inventory = 1},
		{"baked_clay_" .. clay[1] .. ".png"},
		clay[2] .. " Baked Clay")
	end
end

-- cook clay block into white baked clay

minetest.register_craft({
	type = "cooking",
	output = "bakedclay:natural",
	recipe = "default:clay",
})

-- register a few extra dye colour options

minetest.register_craft( {
	type = "shapeless",
	output = "dye:dark_grey 3",
	recipe = {"dye:black", "dye:black", "dye:white"}
})

minetest.register_craft( {
	type = "shapeless",
	output = "dye:grey 3",
	recipe = {"dye:black", "dye:white", "dye:white"}
})

minetest.register_craft( {
	type = "shapeless",
	output = "dye:green 4",
	recipe = {"default:cactus"}
})

minetest.register_craft( {
	type = "shapeless",
	output = "dye:black 4",
	recipe = {"default:coal_lump"}
})

minetest.register_craft( {
	type = "shapeless",
	output = "dye:brown 4",
	recipe = {"default:dry_shrub"}
})

-- 2x2 red bakedclay makes 16x clay brick
minetest.register_craft( {
	output = "default:clay_brick 16",
	recipe = {
		{"bakedclay:red", "bakedclay:red"},
		{"bakedclay:red", "bakedclay:red"},
	}
})

-- register some new flowers to fill in missing dye colours
-- flower registration (borrowed from default game)

local function add_simple_flower(name, desc, box, f_groups)

	f_groups.snappy = 3
	f_groups.flower = 1
	f_groups.flora = 1
	f_groups.attached_node = 1

	minetest.register_node("bakedclay:" .. name, {
		description = desc,
		drawtype = "plantlike",
		waving = 1,
		tiles = {"baked_clay_" .. name .. ".png"},
		inventory_image = "baked_clay_" .. name .. ".png",
		wield_image = "baked_clay_" .. name .. ".png",
		sunlight_propagates = true,
		paramtype = "light",
		walkable = false,
		buildable_to = true,
		stack_max = 99,
		groups = f_groups,
		sounds = default.node_sound_leaves_defaults(),
		selection_box = {
			type = "fixed",
			fixed = box
		}
	})
end

local flowers = {
	{"delphinium", "Blue Delphinium", {-0.15, -0.5, -0.15, 0.15, 0.3, 0.15}, {color_cyan = 1}},
	{"thistle", "Thistle", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_magenta = 1}},
	{"lazarus", "Lazarus Bell", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_pink = 1}},
	{"mannagrass", "Reed Mannagrass", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_dark_green = 1}},
}

for _,item in pairs(flowers) do
	add_simple_flower(unpack(item))
end

-- mapgen for new flowers

minetest.register_decoration({
	deco_type = "simple",
	place_on = {"default:dirt_with_grass"},
	sidelen = 16,
	noise_params = {
		offset = 0,
		scale = 0.004,
		spread = {x = 100, y = 100, z = 100},
		seed = 7133,
		octaves = 3,
		persist = 0.6
	},
	y_min = 10,
	y_max = 90,
	decoration = "bakedclay:delphinium",
})

minetest.register_decoration({
	deco_type = "simple",
	place_on = {"default:dirt_with_grass", "default:dirt_with_dry_grass"},
	sidelen = 16,
	noise_params = {
		offset = 0,
		scale = 0.004,
		spread = {x = 100, y = 100, z = 100},
		seed = 7134,
		octaves = 3,
		persist = 0.6
	},
	y_min = 15,
	y_max = 90,
	decoration = "bakedclay:thistle",
})

minetest.register_decoration({
	deco_type = "simple",
	place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
	sidelen = 16,
	noise_params = {
		offset = 0,
		scale = 0.01,
		spread = {x = 100, y = 100, z = 100},
		seed = 7135,
		octaves = 3,
		persist = 0.6
	},
	y_min = 1,
	y_max = 90,
	decoration = "bakedclay:lazarus",
	spawn_by = "default:jungletree",
	num_spawn_by = 1,
})

minetest.register_decoration({
	deco_type = "simple",
	place_on = {"default:dirt_with_grass", "default:sand"},
	sidelen = 16,
	noise_params = {
		offset = 0,
		scale = 0.009,
		spread = {x = 100, y = 100, z = 100},
		seed = 7136,
		octaves = 3,
		persist = 0.6
	},
	y_min = 1,
	y_max = 15,
	decoration = "bakedclay:mannagrass",
	spawn_by = "group:water",
	num_spawn_by = 1,
})

-- add lucky blocks

if minetest.get_modpath("lucky_block") then
local p = "bakedclay:"
lucky_block:add_blocks({
	{"dro", {"bakedclay:"}, 10, true},
	{"fal", {p.."black", p.."blue", p.."brown", p.."cyan", p.."dark_green",
		p.."dark_grey", p.."green", p.."grey", p.."magenta", p.."orange",
		p.."pink", p.."red", p.."violet", p.."white", p.."yellow", p.."natural"}, 0},
	{"fal", {p.."black", p.."blue", p.."brown", p.."cyan", p.."dark_green",
		p.."dark_grey", p.."green", p.."grey", p.."magenta", p.."orange",
		p.."pink", p.."red", p.."violet", p.."white", p.."yellow", p.."natural"}, 0, true},
	{"dro", {p.."delphinium"}, 5},
	{"dro", {p.."lazarus"}, 5},
	{"dro", {p.."mannagrass"}, 5},
	{"dro", {p.."thistle"}, 6},
	{"flo", 5, {p.."natural", p.."black", p.."blue", p.."brown", p.."cyan",
		p.."dark_green", p.."dark_grey", p.."green", p.."grey", p.."magenta",
		p.."orange", p.."pink", p.."red", p.."violet", p.."white", p.."yellow"}, 2},
	{"nod", "default:chest", 0, {
		{name = p.."natural", max = 30},
		{name = p.."black", max = 30},
		{name = p.."blue", max = 30},
		{name = p.."brown", max = 30},
		{name = p.."cyan", max = 30},
		{name = p.."dark_green", max = 30},
		{name = p.."dark_grey", max = 30},
		{name = p.."green", max = 30},
		{name = p.."grey", max = 30},
		{name = p.."magenta", max = 30},
		{name = p.."orange", max = 30},
		{name = p.."pink", max = 30},
		{name = p.."red", max = 30},
		{name = p.."violet", max = 30},
		{name = p.."white", max = 30},
		{name = p.."yellow", max = 30},
	}},
})
end

print ("[MOD] Baked Clay loaded")


code:
name = bakedclay
author = TenPlus1
description = Adds the ability to bake clay into blocks and colour them with dye.
depends = default, stairs
optional_depends = moreblocks, lucky_block, technic_cnc


code:
-- items

minetest.register_craftitem("basic_materials:silicon", {
	description = "Silicon lump",
	inventory_image = "basic_materials_silicon.png",
})

minetest.register_craftitem("basic_materials:ic", {
	description = "Simple Integrated Circuit",
	inventory_image = "basic_materials_ic.png",
})

minetest.register_craftitem("basic_materials:motor", {
	description = "Simple Motor",
	inventory_image = "basic_materials_motor.png",
})

minetest.register_craftitem("basic_materials:heating_element", {
	description = "Heating element",
	inventory_image = "basic_materials_heating_element.png",
})

minetest.register_craftitem("basic_materials:energy_crystal_simple", {
	description = "Simple energy crystal",
	inventory_image = "basic_materials_energy_crystal.png",
})

-- crafts

minetest.register_craft( {
	output = "mesecons_materials:silicon 4",
	recipe = {
		{ "default:sand", "default:sand" },
		{ "default:sand", "default:steel_ingot" },
	},
})

minetest.register_craft( {
	output = "basic_materials:ic 4",
	recipe = {
		{ "mesecons_materials:silicon", "mesecons_materials:silicon" },
		{ "mesecons_materials:silicon", "default:copper_ingot" },
	},
})

minetest.register_craft( {
    output = "basic_materials:motor 2",
    recipe = {
		{ "default:mese_crystal_fragment", "basic_materials:copper_wire", "basic_materials:plastic_sheet" },
		{ "default:copper_ingot",          "default:steel_ingot",         "default:steel_ingot" },
		{ "default:mese_crystal_fragment", "basic_materials:copper_wire", "basic_materials:plastic_sheet" }
    },
	replacements = {
		{ "basic_materials:copper_wire", "basic_materials:empty_spool" },
		{ "basic_materials:copper_wire", "basic_materials:empty_spool" },
	}
})

minetest.register_craft( {
    output = "basic_materials:heating_element 2",
    recipe = {
		{ "default:copper_ingot", "default:mese_crystal_fragment", "default:copper_ingot" }
    },
})

minetest.register_craft({
	--type = "shapeless",
	output = "basic_materials:energy_crystal_simple 2",
	recipe = {
		{ "default:mese_crystal_fragment", "default:torch", "default:mese_crystal_fragment" },
		{ "default:diamond", "default:gold_ingot", "default:diamond" }
	},
})

-- aliases

minetest.register_alias("homedecor:ic",                     "basic_materials:ic")
minetest.register_alias("homedecor:motor",                  "basic_materials:motor")
minetest.register_alias("technic:motor",                    "basic_materials:motor")
minetest.register_alias("homedecor:heating_element",        "basic_materials:heating_element")
minetest.register_alias("homedecor:power_crystal",          "basic_materials:energy_crystal_simple")

minetest.register_alias_force("mesecons_materials:silicon", "basic_materials:silicon")


code:
-- Basic materials mod
-- by Vanessa Dannenberg

-- This mod supplies all those little random craft items that everyone always
-- seems to need, such as metal bars (ala rebar), plastic, wire, and so on.

local modpath = minetest.get_modpath("basic_materials")

basic_materials = {}

dofile(modpath.."/metals.lua")
dofile(modpath.."/plastics.lua")
dofile(modpath.."/electrical-electronic.lua")
dofile(modpath.."/misc.lua")


code:
-- items

minetest.register_craftitem("basic_materials:steel_wire", {
	description = "Spool of steel wire",
	inventory_image = "basic_materials_steel_wire.png"
})

minetest.register_craftitem("basic_materials:copper_wire", {
	description = "Spool of copper wire",
	inventory_image = "basic_materials_copper_wire.png"
})

minetest.register_craftitem("basic_materials:silver_wire", {
	description = "Spool of silver wire",
	inventory_image = "basic_materials_silver_wire.png"
})

minetest.register_craftitem("basic_materials:gold_wire", {
	description = "Spool of gold wire",
	inventory_image = "basic_materials_gold_wire.png"
})

minetest.register_craftitem("basic_materials:steel_strip", {
	description = "Steel Strip",
	inventory_image = "basic_materials_steel_strip.png"
})

minetest.register_craftitem("basic_materials:copper_strip", {
	description = "Copper Strip",
	inventory_image = "basic_materials_copper_strip.png"
})

minetest.register_craftitem("basic_materials:steel_bar", {
	description = "Steel Bar",
	inventory_image = "basic_materials_steel_bar.png",
})

minetest.register_craftitem("basic_materials:chainlink_brass", {
	description = "Chainlinks (brass)",
	inventory_image = "basic_materials_chainlink_brass.png"
})

minetest.register_craftitem("basic_materials:chainlink_steel", {
	description = "Chainlinks (steel)",
	inventory_image = "basic_materials_chainlink_steel.png"
})

minetest.register_craftitem("basic_materials:brass_ingot", {
	description = "Brass Ingot",
	inventory_image = "basic_materials_brass_ingot.png",
})

minetest.register_craftitem("basic_materials:gear_steel", {
	description = "Steel gear",
	inventory_image = "basic_materials_gear_steel.png"
})

minetest.register_craftitem("basic_materials:padlock", {
	description = "Padlock",
	inventory_image = "basic_materials_padlock.png"
})

-- nodes

local chains_sbox = {
	type = "fixed",
	fixed = { -0.1, -0.5, -0.1, 0.1, 0.5, 0.1 }
}

local topchains_sbox = {
	type = "fixed",
	fixed = {
		{ -0.25, 0.35, -0.25, 0.25, 0.5, 0.25 },
		{ -0.1, -0.5, -0.1, 0.1, 0.4, 0.1 }
	}
}

minetest.register_node("basic_materials:chain_steel", {
	description = "Chain (steel, hanging)",
	drawtype = "mesh",
	mesh = "basic_materials_chains.obj",
	tiles = {"basic_materials_chain_steel.png"},
	walkable = false,
	climbable = true,
	sunlight_propagates = true,
	paramtype = "light",
	inventory_image = "basic_materials_chain_steel_inv.png",
	groups = {cracky=3},
	selection_box = chains_sbox,
})

minetest.register_node("basic_materials:chain_brass", {
	description = "Chain (brass, hanging)",
	drawtype = "mesh",
	mesh = "basic_materials_chains.obj",
	tiles = {"basic_materials_chain_brass.png"},
	walkable = false,
	climbable = true,
	sunlight_propagates = true,
	paramtype = "light",
	inventory_image = "basic_materials_chain_brass_inv.png",
	groups = {cracky=3},
	selection_box = chains_sbox,
})

minetest.register_node("basic_materials:brass_block", {
	description = "Brass Block",
	tiles = { "basic_materials_brass_block.png" },
	is_ground_content = false,
	groups = {cracky=1, level=2},
	sounds = default.node_sound_metal_defaults()
})

-- crafts

minetest.register_craft( {
	output = "basic_materials:copper_wire 2",
	type = "shapeless",
	recipe = {
		"default:copper_ingot",
		"basic_materials:empty_spool",
		"basic_materials:empty_spool",
	},
})

minetest.register_craft( {
	output = "basic_materials:silver_wire 2",
	type = "shapeless",
	recipe = {
		"moreores:silver_ingot",
		"basic_materials:empty_spool",
		"basic_materials:empty_spool",
	},
})

minetest.register_craft( {
	output = "basic_materials:gold_wire 2",
	type = "shapeless",
	recipe = {
		"default:gold_ingot",
		"basic_materials:empty_spool",
		"basic_materials:empty_spool",
	},
})

minetest.register_craft( {
	output = "basic_materials:steel_wire 2",
	type = "shapeless",
	recipe = {
		"default:steel_ingot",
		"basic_materials:empty_spool",
		"basic_materials:empty_spool",
	},
})

minetest.register_craft( {
	output = "basic_materials:steel_strip 12",
	recipe = {
		{ "", "default:steel_ingot", "" },
		{ "default:steel_ingot", "", "" },
	},
})

minetest.register_craft( {
	output = "basic_materials:copper_strip 12",
	recipe = {
		{ "", "default:copper_ingot", "" },
		{ "default:copper_ingot", "", "" },
	},
})

minetest.register_craft( {
	output = "basic_materials:steel_bar 6",
	recipe = {
		{ "", "", "default:steel_ingot" },
		{ "", "default:steel_ingot", "" },
		{ "default:steel_ingot", "", "" },
	},
})

minetest.register_craft( {
	output = "basic_materials:padlock 2",
	recipe = {
		{ "basic_materials:steel_bar" },
		{ "default:steel_ingot" },
		{ "default:steel_ingot" },
	},
})

minetest.register_craft({
	output = "basic_materials:chainlink_steel 12",
	recipe = {
		{"", "default:steel_ingot", "default:steel_ingot"},
		{ "default:steel_ingot", "", "default:steel_ingot" },
		{ "default:steel_ingot", "default:steel_ingot", "" },
	},
})

minetest.register_craft({
	output = "basic_materials:chainlink_brass 12",
	recipe = {
		{"", "basic_materials:brass_ingot", "basic_materials:brass_ingot"},
		{ "basic_materials:brass_ingot", "", "basic_materials:brass_ingot" },
		{ "basic_materials:brass_ingot", "basic_materials:brass_ingot", "" },
	},
})

minetest.register_craft({
	output = 'basic_materials:chain_steel 2',
	recipe = {
		{"basic_materials:chainlink_steel"},
		{"basic_materials:chainlink_steel"},
		{"basic_materials:chainlink_steel"}
	}
})

minetest.register_craft({
	output = 'basic_materials:chain_brass 2',
	recipe = {
		{"basic_materials:chainlink_brass"},
		{"basic_materials:chainlink_brass"},
		{"basic_materials:chainlink_brass"}
	}
})

minetest.register_craft( {
	output = "basic_materials:gear_steel 6",
	recipe = {
		{ "", "default:steel_ingot", "" },
		{ "default:steel_ingot","basic_materials:chainlink_steel", "default:steel_ingot" },
		{ "", "default:steel_ingot", "" }
	},
})

minetest.register_craft( {
	type = "shapeless",
	output = "basic_materials:brass_ingot 3",
	recipe = {
		"default:copper_ingot",
		"default:copper_ingot",
		"moreores:silver_ingot",
	},
})

minetest.register_craft( {
	type = "shapeless",
	output = "basic_materials:brass_ingot 9",
	recipe = { "basic_materials:brass_block" },
})

minetest.register_craft( {
	output = "basic_materials:brass_block",
	recipe = {
		{ "basic_materials:brass_ingot", "basic_materials:brass_ingot", "basic_materials:brass_ingot" },
		{ "basic_materials:brass_ingot", "basic_materials:brass_ingot", "basic_materials:brass_ingot" },
		{ "basic_materials:brass_ingot", "basic_materials:brass_ingot", "basic_materials:brass_ingot" },
	},
})

-- aliases

minetest.register_alias("homedecor:copper_wire",           "basic_materials:copper_wire")
minetest.register_alias("technic:fine_copper_wire",        "basic_materials:copper_wire")
minetest.register_alias("technic:fine_silver_wire",        "basic_materials:silver_wire")
minetest.register_alias("technic:fine_gold_wire",          "basic_materials:gold_wire")

minetest.register_alias("homedecor:steel_wire",            "basic_materials:steel_wire")

minetest.register_alias("homedecor:brass_ingot",           "basic_materials:brass_ingot")
minetest.register_alias("technic:brass_ingot",             "basic_materials:brass_ingot")
minetest.register_alias("technic:brass_block",             "basic_materials:brass_block")

minetest.register_alias("homedecor:copper_strip",          "basic_materials:copper_strip")
minetest.register_alias("homedecor:steel_strip",           "basic_materials:steel_strip")

minetest.register_alias_force("glooptest:chainlink",       "basic_materials:chainlink_steel")
minetest.register_alias_force("homedecor:chainlink_steel", "basic_materials:chainlink_steel")
minetest.register_alias("homedecor:chainlink_brass",       "basic_materials:chainlink_brass")
minetest.register_alias("chains:chain",                    "basic_materials:chain_steel")
minetest.register_alias("chains:chain_brass",              "basic_materials:chain_brass")

minetest.register_alias("pipeworks:gear",                  "basic_materials:gear_steel")

minetest.register_alias("technic:rebar",                  "basic_materials:steel_bar")


code:
--items

minetest.register_craftitem("basic_materials:oil_extract", {
	description = "Oil extract",
	inventory_image = "basic_materials_oil_extract.png",
})

minetest.register_craftitem("basic_materials:paraffin", {
	description = "Unprocessed paraffin",
	inventory_image = "basic_materials_paraffin.png",
})

minetest.register_craftitem("basic_materials:terracotta_base", {
	description = "Uncooked Terracotta Base",
	inventory_image = "basic_materials_terracotta_base.png",
})

minetest.register_craftitem("basic_materials:wet_cement", {
	description = "Wet Cement",
	inventory_image = "basic_materials_wet_cement.png",
})

-- nodes

minetest.register_node("basic_materials:cement_block", {
	description = "Cement",
	tiles = {"basic_materials_cement_block.png"},
	is_ground_content = true,
	groups = {cracky=2},
	sounds = default.node_sound_stone_defaults(),
})

minetest.register_node("basic_materials:concrete_block", {
	description = "Concrete Block",
	tiles = {"basic_materials_concrete_block.png",},
	groups = {cracky=1, level=2, concrete=1},
	sounds = default.node_sound_stone_defaults(),
})

-- crafts

minetest.register_craft({
	type = "shapeless",
	output = "basic_materials:oil_extract 2",
	recipe = {
		"group:leaves",
		"group:leaves",
		"group:leaves",
		"group:leaves",
		"group:leaves",
		"group:leaves"
	}
})

minetest.register_craft({
	type = "cooking",
	output = "basic_materials:paraffin",
	recipe = "basic_materials:oil_extract",
})

minetest.register_craft({
	type = "fuel",
	recipe = "basic_materials:oil_extract",
	burntime = 30,
})

minetest.register_craft({
	type = "fuel",
	recipe = "basic_materials:paraffin",
	burntime = 30,
})

minetest.register_craft( {
	type = "shapeless",
	output = "basic_materials:terracotta_base 8",
	recipe = {
		"mesecraft_bucket:bucket_water",
		"default:clay_lump",
		"default:gravel",
	},
	replacements = { {"mesecraft_bucket:bucket_water", "mesecraft_bucket:bucket_empty"}, },
})

minetest.register_craft({
	type = "shapeless",
	output = "basic_materials:wet_cement 3",
	recipe = {
		"default:dirt",
		"dye:dark_grey",
		"dye:dark_grey",
		"dye:dark_grey",
		"mesecraft_bucket:bucket_water"
	},
	replacements = {{'mesecraft_bucket:bucket_water', 'mesecraft_bucket:bucket_empty'},},
})

minetest.register_craft({
	type = "cooking",
	output = "basic_materials:cement_block",
	recipe = "basic_materials:wet_cement",
	cooktime = 8
})

minetest.register_craft({
	output = 'basic_materials:concrete_block 6',
	recipe = {
		{'group:sand',                'basic_materials:wet_cement', 'default:gravel'},
		{'basic_materials:steel_bar', 'basic_materials:wet_cement', 'basic_materials:steel_bar'},
		{'default:gravel',            'basic_materials:wet_cement', 'group:sand'},
	}
})

-- aliases

minetest.register_alias("homedecor:oil_extract",      "basic_materials:oil_extract")
minetest.register_alias("homedecor:paraffin",         "basic_materials:paraffin")
minetest.register_alias("homedecor:plastic_base",     "basic_materials:paraffin")
minetest.register_alias("homedecor:terracotta_base",  "basic_materials:terracotta_base")

minetest.register_alias("gloopblocks:wet_cement",     "basic_materials:wet_cement")
minetest.register_alias("gloopblocks:cement",         "basic_materials:cement_block")

minetest.register_alias("technic:concrete",           "basic_materials:concrete_block")


code:
name = basic_materials
description = This mod supplies all those little random craft items that everyone always seems to need, such as metal bars (ala rebar), plastic, wire, and so on.
depends = default
optional_depends = moreores
author = VanessaE
title = Basic Materials


code:
-- items

minetest.register_craftitem("basic_materials:plastic_sheet", {
	description = "Plastic sheet",
	inventory_image = "basic_materials_plastic_sheet.png",
})

minetest.register_craftitem("basic_materials:plastic_strip", {
	description = "Plastic strips",
	inventory_image = "basic_materials_plastic_strip.png",
})

minetest.register_craftitem("basic_materials:empty_spool", {
	description = "Empty wire spool",
	inventory_image = "basic_materials_empty_spool.png"
})

-- crafts

minetest.register_craft({
	type = "cooking",
	output = "basic_materials:plastic_sheet",
	recipe = "basic_materials:paraffin",
})

minetest.register_craft({
	type = "fuel",
	recipe = "basic_materials:plastic_sheet",
	burntime = 30,
})

minetest.register_craft( {
    output = "basic_materials:plastic_strip 9",
    recipe = {
		{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
    },
})

minetest.register_craft( {
	output = "basic_materials:empty_spool 3",
	recipe = {
		{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
		{ "", "basic_materials:plastic_sheet", "" },
		{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
	},
})

-- aliases

minetest.register_alias("homedecor:plastic_sheeting", "basic_materials:plastic_sheet")
minetest.register_alias("homedecor:plastic_strips",   "basic_materials:plastic_strip")
minetest.register_alias("homedecor:empty_spool",      "basic_materials:empty_spool")


code:
-- Register the recipe for the honey extractor.
  minetest.register_craft({
    output = 'bees:extractor',
    recipe = {
      {'','default:steel_ingot',''},
      {'default:steel_ingot','default:stick','default:steel_ingot'},
      {'default:mese_crystal','default:steel_ingot','default:mese_crystal'},
    }
  })
-- Register the recipe for the hive smoker.
  minetest.register_craft({
    output = 'bees:smoker',
    recipe = {
      {'default:steel_ingot', 'wool:red', ''},
      {'', 'default:torch', ''},
      {'', 'default:steel_ingot',''},
    }
  })
-- Register the recipe for artificial bee hive.
  minetest.register_craft({
    output = 'bees:hive_artificial',
    recipe = {
      {'group:wood','group:wood','group:wood'},
      {'group:wood','default:stick','group:wood'},
      {'group:wood','default:stick','group:wood'},
    }
  })
-- Register the recipe for bee hive grafting tool.
  minetest.register_craft({
    output = 'bees:grafting_tool',
    recipe = {
      {'', '', 'default:steel_ingot'},
      {'', 'default:stick', ''},
      {'', '', ''},
    }
  })
-- Register the recipe for empty hive frames.
  minetest.register_craft({
    output = 'bees:frame_empty',
    recipe = {
      {'group:wood',  'group:wood',  'group:wood'},
      {'default:stick', 'default:stick', 'default:stick'},
      {'default:stick', 'default:stick', 'default:stick'},
    }
  })
-- Register the recipe for the honeycomb block.
minetest.register_craft({
	output = "bees:honeycomb 8",
	recipe = {
		{"bees:honeycomb_block"},
	}
})
-- Register the recipe for honeycombs --> honeycomb_block.
minetest.register_craft({
	output = "bees:honeycomb_block",
	recipe = {
		{"bees:honeycomb", "bees:honeycomb", "bees:honeycomb"},
		{"bees:honeycomb", "", "bees:honeycomb"},
		{"bees:honeycomb", "bees:honeycomb", "bees:honeycomb"},
	}
})


code:
-- Register the empty hive frame.
  minetest.register_craftitem('bees:frame_empty', {
    description = 'Empty Hive Frame',
    inventory_image = 'bees_frame_empty.png',
    stack_max = 24,
  })
-- Register the full hive frame.
  minetest.register_craftitem('bees:frame_full', {
    description = 'Filled Hive Frame',
    inventory_image = 'bees_frame_full.png',
    stack_max = 12,
  })
-- Register the bottle of honey.
  minetest.register_craftitem('bees:bottle_honey', {
    description = 'Bottle of Honey',
    inventory_image = 'bees_bottle_honey.png',
    stack_max = 12,
    on_use = minetest.item_eat(3, "vessels:glass_bottle"),
  })
-- Register Bees Wax.
  minetest.register_craftitem('bees:wax', {
    description = 'Bees Wax',
    inventory_image = 'bees_wax.png',
    stack_max = 48,
  })
-- Register honeycomb.
  minetest.register_craftitem('bees:honeycomb', {
    description = 'Honeycomb',
    inventory_image = 'bees_honeycomb.png',
    on_use = minetest.item_eat(2),
    stack_max = 8,
  })
-- Register Queen Bee.
  minetest.register_craftitem('bees:queen', {
    description = 'Queen Bee',
    inventory_image = 'bees_particle_bee.png',
    stack_max = 1,
  })


code:
-- EDITED BY MESECRAFT, Fall, 2019
-- CHANGES:
-- INCLUDED NICER TEXTURES FROM CHURCH_CANDLES MOD
-- USED TEXTURES FROM DEFAULT TO REDUCE REDUNDANCY,
-- REMOVED AUTOMATION VIA INDUSTRIAL HIVE & PIPEWORKS SUPPORT TO RETAIN PLAYER ENGAGEMENT.
-- CLEANED UP DESCRIPTION FIELDS' CASING
-- REMOVE BACKWARDS COMPATIBLITY
-- ADDED LOCATIONAL SOUND EFFECTS.
-- TODO: ADD HONEY LIQUID / BUCKET, maybe a honey/bee biomes.
-- TODO: Giant Bee Mob for mobs_Creatures.
-- TODO: Add honey dripping particles from wild hives.
-- TODO: Right click wild hive with jar to get honey, spawns angry bee.
-- TODO: Right click wild hive with sheer to get honey comb, spawns angry bee.
-- TODO: Break wild hive / artificial hive spawns angry bee(s).
-- TODO: Bee sting poisons players.
--Bees by Bas080
--Note: This branch was modified by clockgen in summer, 2019.
--Version	2.2
--License	WTFPL

--VARIABLES
  local bees = {}
  local formspecs = {}

--FUNCTIONS
  function formspecs.hive_wild(pos, grafting)
    local spos = pos.x .. ',' .. pos.y .. ',' ..pos.z
    local formspec =
      'size[8,9]'..
      'list[nodemeta:'.. spos .. ';combs;1.5,3;5,1;]'..
      'list[current_player;main;0,5;8,4;]'
    if grafting then
      formspec = formspec..'list[nodemeta:'.. spos .. ';queen;3.5,1;1,1;]'
    end
    return formspec
  end

  function formspecs.hive_artificial(pos)
    local spos = pos.x..','..pos.y..','..pos.z
    local formspec =
      'size[8,9]'..
      'list[nodemeta:'..spos..';queen;3.5,1;1,1;]'..
      'list[nodemeta:'..spos..';frames;0,3;8,1;]'..
      'list[current_player;main;0,5;8,4;]'
    return formspec
  end

  function bees.polinate_flower(pos, flower)
    local spawn_pos = { x=pos.x+math.random(-3,3) , y=pos.y+math.random(-3,3) , z=pos.z+math.random(-3,3) }
    local floor_pos = { x=spawn_pos.x , y=spawn_pos.y-1 , z=spawn_pos.z }
    local spawn = minetest.get_node(spawn_pos).name
    local floor = minetest.get_node(floor_pos).name
    if floor == 'default:dirt_with_grass' and spawn == 'air' then
      minetest.set_node(spawn_pos, {name=flower})
    end
  end
  minetest.register_node('bees:extractor', {
    description = 'Honey Extractor Machine',
    tiles = {"bees_extractor_top.png", "bees_extractor_bottom.png", "bees_extractor_side.png", "bees_extractor_side.png", "bees_extractor_side.png", "bees_extractor_front.png"},
    paramtype = "light",
    paramtype2 = "facedir",
    drawtype = "nodebox",
    place_param2 = 0,
    groups = {choppy=2,oddly_breakable_by_hand=2},
    sounds = default.node_sound_wood_defaults(),
    node_box = {
	type = "fixed",
	fixed = {
			{-0.4375, -0.5, -0.4375, 0.4375, 0, 0.4375},
			{-0.375, -0.0625, -0.375, 0.375, 0.5, 0.375},
			{-0.4375, 0.375, -0.4375, 0.4375, 0.4375, 0.4375},
			{0.375, 0, -0.4375, 0.4375, 0.4375, -0.375},
			{-0.4375, 0, -0.4375, -0.375, 0.4375, -0.375},
			{-0.4375, 0, 0.375, -0.375, 0.4375, 0.4375},
			{0.375, 0, 0.375, 0.4375, 0.4375, 0.4375},
		},
    },
    selection_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
	},
    on_construct = function(pos, node)
      local meta = minetest.get_meta(pos)
      local inv  = meta:get_inventory()
      local pos = pos.x..','..pos.y..','..pos.z
      inv:set_size('frames_filled'  ,1)
      inv:set_size('frames_emptied' ,1)
      inv:set_size('bottles_empty'  ,1)
      inv:set_size('bottles_full' ,1)
      inv:set_size('wax',1)
      meta:set_string('formspec',
        'size[8,9]'..
        --input
        'list[nodemeta:'..pos..';frames_filled;2,1;1,1;]'..
        'list[nodemeta:'..pos..';bottles_empty;2,3;1,1;]'..
        --output
        'list[nodemeta:'..pos..';frames_emptied;5,0.5;1,1;]'..
        'list[nodemeta:'..pos..';wax;5,2;1,1;]'..
        'list[nodemeta:'..pos..';bottles_full;5,3.5;1,1;]'..
        --player inventory
        'list[current_player;main;0,5;8,4;]'
      )
    end,
    on_timer = function(pos, node)
      local meta = minetest.get_meta(pos)
      local inv  = meta:get_inventory()
      if not inv:contains_item('frames_filled','bees:frame_full') or not inv:contains_item('bottles_empty','vessels:glass_bottle') then
        return
      end
      if inv:room_for_item('frames_emptied', 'bees:frame_empty')
      and inv:room_for_item('wax','bees:wax')
      and inv:room_for_item('bottles_full', 'bees:bottle_honey') then
        --add to output
        inv:add_item('frames_emptied', 'bees:frame_empty')
        inv:add_item('wax', 'bees:wax')
        inv:add_item('bottles_full', 'bees:bottle_honey')
        --remove from input
        inv:remove_item('bottles_empty','vessels:glass_bottle')
        inv:remove_item('frames_filled','bees:frame_full')
        local p = {x=pos.x+math.random()-0.5, y=pos.y+math.random()-0.5, z=pos.z+math.random()-0.5}
        --wax flying all over the place
        minetest.add_particle({
          pos = {x=pos.x, y=pos.y, z=pos.z},
          vel = {x=math.random(-4,4),y=math.random(8),z=math.random(-4,4)},
          acc = {x=0,y=-6,z=0},
          expirationtime = 2,
          size = math.random(1,3),
          collisiondetection = false,
          texture = 'bees_wax_particle.png',
        })
        local timer = minetest.get_node_timer(pos)
        timer:start(5)
      else
        local timer = minetest.get_node_timer(pos)
        timer:start(1) -- Try again in 1 second
      end
    end,
    tube = {
      insert_object = function(pos, node, stack, direction)
        local meta = minetest.get_meta(pos)
        local inv = meta:get_inventory()
        local timer = minetest.get_node_timer(pos)
        if stack:get_name() == "bees:frame_full" then
          if inv:is_empty("frames_filled") then
            timer:start(5)
          end
          return inv:add_item("frames_filled",stack)
        elseif stack:get_name() == "vessels:glass_bottle" then
          if inv:is_empty("bottles_empty") then
            timer:start(5)
          end
          return inv:add_item("bottles_empty",stack)
        end
        return stack
      end,
      can_insert = function(pos,node,stack,direction)
        local meta = minetest.get_meta(pos)
        local inv = meta:get_inventory()
        if stack:get_name() == "bees:frame_full" then
          return inv:room_for_item("frames_filled",stack)
        elseif stack:get_name() == "vessels:glass_bottle" then
          return inv:room_for_item("bottles_empty",stack)
        end
        return false
      end,
      input_inventory = {"frames_emptied", "bottles_full", "wax"},
      connect_sides = {left=1, right=1, back=1, front=1, bottom=1, top=1}
    },
    on_metadata_inventory_put = function(pos, listname, index, stack, player)
      local timer = minetest.get_node_timer(pos)
      local meta = minetest.get_meta(pos)
      local inv = meta:get_inventory()
      if inv:get_stack(listname, 1):get_count() == stack:get_count() then -- inv was empty -> start the timer
          timer:start(5) --create a honey bottle and empty frame and wax every 5 seconds
      end
    end,
    allow_metadata_inventory_put = function(pos, listname, index, stack, player)
      if minetest.is_protected(pos, player:get_player_name()) then
        return 0
      end
      if (listname == 'bottles_empty' and stack:get_name() == 'vessels:glass_bottle') or (listname == 'frames_filled' and stack:get_name() == 'bees:frame_full') then
        return stack:get_count()
      else
        return 0
      end
    end,
    allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
      return 0
    end,
    allow_metadata_inventory_take = function(pos, listname, index, stack, player)
      if minetest.is_protected(pos,player:get_player_name()) then
        return 0
      end
      return stack:get_count()
    end,
  })

  minetest.register_node('bees:bees', {
    description = 'Flying Bees',
    drawtype = 'plantlike',
    paramtype = 'light',
    groups = { not_in_creative_inventory=1 },
    tiles = {
      {
        name='bees_strip.png',
        animation={type='vertical_frames', aspect_w=16,aspect_h=16, length=2.0}
      }
    },
    damage_per_second = 1,
    walkable = false,
    buildable_to = true,
    pointable = false,
  })
  minetest.register_node('bees:hive_wild', {
    description = 'Wild Bee Hive',
    tiles = {"bees_hive_wild.png"}, --texture from church_candles.
    drawtype = "plantlike",
    paramtype = 'light',
    walkable = true,
    drop = {
      max_items = 6,
      items = {
        { items = {'bees:honeycomb'}, rarity = 5}
      }
    },
    groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,attached_node=1},
    on_timer = function(pos)
      local meta = minetest.get_meta(pos)
      local inv  = meta:get_inventory()
      local timer= minetest.get_node_timer(pos)
      local rad  = 10
      local minp = {x=pos.x-rad, y=pos.y-rad, z=pos.z-rad}
      local maxp = {x=pos.x+rad, y=pos.y+rad, z=pos.z+rad}
      local flowers = minetest.find_nodes_in_area(minp, maxp, 'group:flower')
      if #flowers == 0 then
        inv:set_stack('queen', 1, '')
        meta:set_string('infotext', 'This hive colony died! Not enough flowers in area.')
        return
      end --not any flowers nearby The queen dies!
      if #flowers < 3 then return end --requires 2 or more flowers before can make honey
      local flower = flowers[math.random(#flowers)]
      bees.polinate_flower(flower, minetest.get_node(flower).name)
      local stacks = inv:get_list('combs')
      for k, v in pairs(stacks) do
        if inv:get_stack('combs', k):is_empty() then --then replace that with a full one and reset pro..
          inv:set_stack('combs',k,'bees:honeycomb')
          timer:start(1000/#flowers)
          return
        end
      end
      --what to do if all combs are filled
    end,
    on_construct = function(pos)
      minetest.get_node(pos).param2 = 0
      local meta = minetest.get_meta(pos)
      local inv  = meta:get_inventory()
      local timer = minetest.get_node_timer(pos)
      meta:set_int('agressive', 1)
      timer:start(100+math.random(100))
      inv:set_size('queen', 1)
      inv:set_size('combs', 5)
      inv:set_stack('queen', 1, 'bees:queen')
      for i=1,math.random(3) do
        inv:set_stack('combs', i, 'bees:honeycomb')
      end
    end,
    on_punch = function(pos, node, puncher)
      local meta = minetest.get_meta(pos)
      local inv = meta:get_inventory()
    end,
    on_metadata_inventory_take = function(pos, listname, index, stack, taker)
      local meta = minetest.get_meta(pos)
      local inv  = meta:get_inventory()
      local timer= minetest.get_node_timer(pos)
      if listname == 'combs' and inv:contains_item('queen', 'bees:queen') then
        timer:start(10)
      end
    end,
    on_metadata_inventory_put = function(pos, listname, index, stack, taker) --restart the colony by adding a queen
      local timer = minetest.get_node_timer(pos)
      if not timer:is_started() then
        timer:start(10)
      end
    end,
    allow_metadata_inventory_put = function(pos, listname, index, stack, player)
      if listname == 'queen' and stack:get_name() == 'bees:queen' then
        return 1
      else
        return 0
      end
    end,
    on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
      minetest.show_formspec(
        clicker:get_player_name(),
        'bees:hive_artificial',
        formspecs.hive_wild(pos, (itemstack:get_name() == 'bees:grafting_tool'))
      )
      local meta = minetest.get_meta(pos)
      local inv  = meta:get_inventory()
    end,
    can_dig = function(pos,player)
      local meta = minetest.get_meta(pos)
      local inv  = meta:get_inventory()
      if inv:is_empty('queen') and inv:is_empty('combs') then
        return true
      else
        return false
      end
    end,
    after_dig_node = function(pos, oldnode, oldmetadata, user)
      local wielded if user:get_wielded_item() ~= nil then wielded = user:get_wielded_item() else return end
      if 'bees:grafting_tool' == wielded:get_name() then
        local inv = user:get_inventory()
        if inv then
          inv:add_item('main', ItemStack('bees:queen'))
        end
      end
    end
  })

  minetest.register_node('bees:hive_artificial', {
    description = 'Bee Hive',
    tiles = {'default_wood.png','default_wood.png','default_wood.png', 'default_wood.png','default_wood.png','bees_hive_artificial.png'},
    drawtype = 'nodebox',
    paramtype = 'light',
    paramtype2 = 'facedir',
    groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
    sounds = default.node_sound_wood_defaults(),
    node_box = {
      type = 'fixed',
      fixed = {
        {-4/8, 2/8, -4/8, 4/8, 3/8, 4/8},
        {-3/8, -4/8, -2/8, 3/8, 2/8, 3/8},
        {-3/8, 0/8, -3/8, 3/8, 2/8, -2/8},
        {-3/8, -4/8, -3/8, 3/8, -1/8, -2/8},
        {-3/8, -1/8, -3/8, -1/8, 0/8, -2/8},
        {1/8, -1/8, -3/8, 3/8, 0/8, -2/8},
      }
    },
    on_construct = function(pos)
      local timer = minetest.get_node_timer(pos)
      local meta = minetest.get_meta(pos)
      local inv = meta:get_inventory()
      meta:set_int('agressive', 1)
      inv:set_size('queen', 1)
      inv:set_size('frames', 8)
      meta:set_string('infotext','Requires a queen bee to function.')
    end,
    on_rightclick = function(pos, node, clicker, itemstack)
      minetest.show_formspec(
        clicker:get_player_name(),
        'bees:hive_artificial',
        formspecs.hive_artificial(pos)
      )
      local meta = minetest.get_meta(pos)
      local inv  = meta:get_inventory()
    end,
    on_timer = function(pos,elapsed)
      local meta = minetest.get_meta(pos)
      local inv = meta:get_inventory()
      local timer = minetest.get_node_timer(pos)
      if inv:contains_item('queen', 'bees:queen') then
        if inv:contains_item('frames', 'bees:frame_empty') then
          timer:start(30)
          local rad  = 10
          local minp = {x=pos.x-rad, y=pos.y-rad, z=pos.z-rad}
          local maxp = {x=pos.x+rad, y=pos.y+rad, z=pos.z+rad}
          local flowers = minetest.find_nodes_in_area(minp, maxp, 'group:flower')
          local progress = meta:get_int('progress')
          progress = progress + #flowers
          meta:set_int('progress', progress)
          if progress > 1000 then
            local flower = flowers[math.random(#flowers)]
            bees.polinate_flower(flower, minetest.get_node(flower).name)
            local stacks = inv:get_list('frames')
            for k, v in pairs(stacks) do
              if inv:get_stack('frames', k):get_name() == 'bees:frame_empty' then
                meta:set_int('progress', 0)
                inv:set_stack('frames',k,'bees:frame_full')
                return
              end
            end
          else
            meta:set_string('infotext', 'Bees are busy making honey!')
          end
        else
          meta:set_string('infotext', 'Hive does not have empty frame(s)!')
          timer:stop()
        end
      end
    end,
    on_metadata_inventory_take = function(pos, listname, index, stack, player)
      if listname == 'queen' then
        local timer = minetest.get_node_timer(pos)
        local meta = minetest.get_meta(pos)
        meta:set_string('infotext','Hive requires a queen bee to function!')
        timer:stop()
      end
    end,
    allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
      if minetest.is_protected(pos, player:get_player_name()) then
        return 0
      end
      local inv = minetest.get_meta(pos):get_inventory()
      if from_list == to_list then
        if inv:get_stack(to_list, to_index):is_empty() then
          return 1
        else
          return 0
        end
      else
        return 0
      end
    end,
    on_metadata_inventory_put = function(pos, listname, index, stack, player)
      local meta = minetest.get_meta(pos)
      local inv = meta:get_inventory()
      local timer = minetest.get_node_timer(pos)
      if listname == 'queen' or listname == 'frames' then
        meta:set_string('queen', stack:get_name())
        meta:set_string('infotext','A queen bee is inserted. Add empty frames!');
        if inv:contains_item('frames', 'bees:frame_empty') then
          timer:start(30)
          meta:set_string('infotext','Bees are settling in!');
        end
      end
    end,
    allow_metadata_inventory_put = function(pos, listname, index, stack, player)
      if minetest.is_protected(pos, player:get_player_name()) then
        return 0
      end
      if not minetest.get_meta(pos):get_inventory():get_stack(listname, index):is_empty() then return 0 end
      if listname == 'queen' then
        if stack:get_name():match('bees:queen*') then
          return 1
        end
      elseif listname == 'frames' then
        if stack:get_name() == ('bees:frame_empty') then
          return 1
        end
      end
      return 0
    end,
    allow_metadata_inventory_take = function(pos, listname, index, stack, player)
      if minetest.is_protected(pos,player:get_player_name()) then
        return 0
      end
      return stack:get_count()
    end,
  })

--ABMS
  minetest.register_abm({ --particles
    nodenames = {'bees:hive_artificial', 'bees:hive_wild'},
    interval  = 10,
    chance    = 4,
    action = function(pos)
      minetest.add_particle({
        pos = {x=pos.x, y=pos.y, z=pos.z},
        vel = {x=(math.random()-0.5)*5,y=(math.random()-0.5)*5,z=(math.random()-0.5)*5},
        acc = {x=math.random()-0.5,y=math.random()-0.5,z=math.random()-0.5},
        expirationtime = math.random(2.5),
        size = math.random(3),
        collisiondetection = true,
        texture = 'bees_particle_bee.png',
      })
    end,
  })

  minetest.register_abm({ --spawn abm. This should be changed to a more realistic type of spawning
    nodenames = {'group:leaves'},
    interval = 1600,
    chance = 20,
    action = function(pos, node)
      local p = {x=pos.x, y=pos.y-1, z=pos.z}
      if minetest.get_node(pos).walkable == false then return end
      if (minetest.find_node_near(p, 5, 'group:flower') ~= nil and minetest.find_node_near(p, 40, 'bees:hive_wild') == nil) then
        minetest.add_node(p, {name='bees:hive_wild'})
	minetest.sound_play({name = "bees", gain = 1.0}, {pos=p, max_hear_distance = 8})
      end
    end,
  })

  minetest.register_abm({ --spawning bees around bee hive
    nodenames = {'bees:hive_wild', 'bees:hive_artificial'},
    neighbors = {'group:flower', 'group:leaves'},
    interval = 30,
    chance = 4,
    action = function(pos, node, _, _)
      local p = {x=pos.x+math.random(-5,5), y=pos.y-math.random(0,3), z=pos.z+math.random(-5,5)}
      if minetest.get_node(p).name == 'air' then
        minetest.add_node(p, {name='bees:bees'})
       	minetest.sound_play({name = "bees", gain = 1.0}, {pos=p, max_hear_distance = 8})
      end
    end,
  })

  minetest.register_abm({ --remove bees
    nodenames = {'bees:bees'},
    interval = 30,
    chance = 5,
    action = function(pos, node, _, _)
      minetest.remove_node(pos)
    end,
  })

-- Load other modules for the mod.
local default_path = minetest.get_modpath("bees")

dofile(default_path.."/crafting.lua")
dofile(default_path.."/craftitems.lua")
dofile(default_path.."/nodes.lua")
dofile(default_path.."/tools.lua")


code:
local S = mobs.intllib

-- Bee by KrupnoPavel (.b3d model by sirrobzeroone)

mobs:register_mob("mobs_animal:bee", {
	type = "animal",
	passive = true,
	hp_min = 1,
	hp_max = 2,
	armor = 200,
	collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.5, 0.2},
	visual = "mesh",
	mesh = "mobs_bee.b3d",
	textures = {
		{"mobs_bee.png"},
	},
	blood_texture = "mobs_bee_inv.png",
	blood_amount = 1,
	makes_footstep_sound = false,
	sounds = {
		random = "mobs_bee",
	},
	walk_velocity = 1,
	jump = true,
	drops = {
		{name = "mobs:honey", chance = 2, min = 1, max = 2},
	},
	water_damage = 1,
	lava_damage = 2,
	light_damage = 0,
	fall_damage = 0,
	fall_speed = -3,
	animation = {
		speed_normal = 15,
		stand_start = 0,
		stand_end = 30,
		walk_start = 35,
		walk_end = 65,
	},
	on_rightclick = function(self, clicker)
		mobs:capture_mob(self, clicker, 50, 90, 0, true, "mobs_animal:bee")
	end,
--	after_activate = function(self, staticdata, def, dtime)
--		print ("------", self.name, dtime, self.health)
--	end,
})

if not mobs.custom_spawn_animal then
mobs:spawn({
	name = "mobs_animal:bee",
	nodes = {"group:flower"},
	min_light = 14,
	interval = 60,
	chance = 7000,
	min_height = 3,
	max_height = 200,
	day_toggle = true,
})
end

mobs:register_egg("mobs_animal:bee", S("Bee"), "mobs_bee_inv.png")

-- compatibility
mobs:alias_mob("mobs:bee", "mobs_animal:bee")

-- honey
minetest.register_craftitem(":mobs:honey", {
	description = S("Honey"),
	inventory_image = "mobs_honey_inv.png",
	on_use = minetest.item_eat(4),
	groups = {food_honey = 1, food_sugar = 1, flammable = 1},
})

-- beehive (when placed spawns bee)
minetest.register_node(":mobs:beehive", {
	description = S("Beehive"),
	drawtype = "plantlike",
	tiles = {"mobs_beehive.png"},
	inventory_image = "mobs_beehive.png",
	paramtype = "light",
	sunlight_propagates = true,
	walkable = true,
	groups = {oddly_breakable_by_hand = 3, flammable = 1, disable_suffocation = 1},
	sounds = default.node_sound_defaults(),

	on_construct = function(pos)

		local meta = minetest.get_meta(pos)

		meta:set_string("formspec", "size[8,6]"
			..default.gui_bg..default.gui_bg_img..default.gui_slots
			.. "image[3,0.8;0.8,0.8;mobs_bee_inv.png]"
			.. "list[current_name;beehive;4,0.5;1,1;]"
			.. "list[current_player;main;0,2.35;8,4;]"
			.. "listring[]")

		meta:get_inventory():set_size("beehive", 1)
	end,

	after_place_node = function(pos, placer, itemstack)

		if placer and placer:is_player() then

			minetest.set_node(pos, {name = "mobs:beehive", param2 = 1})

			if math.random(1, 4) == 1 then
				minetest.add_entity(pos, "mobs_animal:bee")
			end
		end
	end,

	on_punch = function(pos, node, puncher)

		-- yep, bee's don't like having their home punched by players
		puncher:set_hp(puncher:get_hp() - 4)
	end,

	allow_metadata_inventory_put = function(pos, listname, index, stack, player)

		if listname == "beehive" then
			return 0
		end

		return stack:get_count()
	end,

	can_dig = function(pos,player)

		local meta = minetest.get_meta(pos)

		-- only dig beehive if no honey inside
		return meta:get_inventory():is_empty("beehive")
	end,

})

minetest.register_craft({
	output = "mobs:beehive",
	recipe = {
		{"mobs:bee","mobs:bee","mobs:bee"},
	}
})

-- honey block
minetest.register_node(":mobs:honey_block", {
	description = S("Honey Block"),
	tiles = {"mobs_honey_block.png"},
	groups = {snappy = 3, flammable = 2},
	sounds = default.node_sound_dirt_defaults(),
})

minetest.register_craft({
	output = "mobs:honey_block",
	recipe = {
		{"mobs:honey", "mobs:honey", "mobs:honey"},
		{"mobs:honey", "mobs:honey", "mobs:honey"},
		{"mobs:honey", "mobs:honey", "mobs:honey"},
	}
})

minetest.register_craft({
	output = "mobs:honey 9",
	recipe = {
		{"mobs:honey_block"},
	}
})

-- beehive workings
minetest.register_abm({
	nodenames = {"mobs:beehive"},
	interval = 12,
	chance = 6,
	catch_up = false,
	action = function(pos, node)

		-- bee's only make honey during the day
		local tod = (minetest.get_timeofday() or 0) * 24000

		if tod < 5500 or tod > 18500 then
			return
		end

		-- is hive full?
		local meta = minetest.get_meta(pos)
		if not meta then return end -- for older beehives
		local inv = meta:get_inventory()
		local honey = inv:get_stack("beehive", 1):get_count()

		-- is hive full?
		if honey > 11 then
			return
		end

		-- no flowers no honey, nuff said!
		if #minetest.find_nodes_in_area_under_air(
			{x = pos.x - 4, y = pos.y - 3, z = pos.z - 4},
			{x = pos.x + 4, y = pos.y + 3, z = pos.z + 4},
			"group:flower") > 3 then

			inv:add_item("beehive", "mobs:honey")
		end
	end
})


code:
name = bees
author = Bas080
description = Adds bees and bee-keeping.
depends = default


code:
-- Nodes.

minetest.register_node("bees:honeycomb_block", {
        description = "Honeycomb Block",
        tiles = {"bees_honeycomb_block.png"},
        groups = {oddly_breakable_by_hand = 3, dig_immediate = 1},
        sounds = default.node_sound_dirt_defaults(),
})


code:
--TOOLS
  minetest.register_tool('bees:smoker', {
    description = 'Hive Smoker',
    inventory_image = 'bees_smoker.png',
    tool_capabilities = {
      full_punch_interval = 3.0,
      max_drop_level=0,
      damage_groups = {fleshy=2},
    },
    on_use = function(tool, user, node)
      if node then
        local pos = node.under
        if pos then
          for i=1,6 do
            minetest.add_particle({
              pos = {x=pos.x+math.random()-0.5, y=pos.y, z=pos.z+math.random()-0.5},
              vel = {x=0,y=0.5+math.random(),z=0},
              acc = {x=0,y=0,z=0},
              expirationtime = 2+math.random(2.5),
              size = math.random(3),
              collisiondetection = false,
              texture = 'tnt_smoke.png',
            })
          end
          --tool:add_wear(2)
          local meta = minetest.get_meta(pos)
          meta:set_int('agressive', 0)
          return nil
        end
      end
    end,
  })

  minetest.register_tool('bees:grafting_tool', {
    description = 'Beehive Grafting Tool',
    inventory_image = 'bees_grafting_tool.png',
    tool_capabilities = {
      full_punch_interval = 3.0,
      max_drop_level=0,
      damage_groups = {fleshy=2},
    },
  })


code:
Bell that rings every hour as many times as the hour counts (1-12 times)
Works like a church bell.

The positions of placed bells are saved. Thus, each bell can ring independently of the load status of the area the bell is in.

You can ring a bell manually.

There is also a small bell (looks like the normal one) that can be crafted from gold blocks. Unlike the normal bell, this craftable one won't ring automaticly and has a much smaller hear distance.

If you actually want to use this mod, you need to create a folder sounds/ in it (on the same level as textures/) and put sound files named bell_bell.ogg (for the large, uncraftable bell) and bell_small.ogg (for the craftable one) into the folder.

License: GPLv3


code:
S = minetest.get_translator("bell")

-- bell_positions are saved through server restart
-- bells ring every hour
-- they ring as many times as a bell ought to

local RING_INTERVAL = 3600 --60*60 -- ring each hour

local BELL_SAVE_FILE = minetest.get_worldpath().."/bell_positions.data"

local bell_positions = {}

local ring_big_bell = function(pos)
	minetest.sound_play( "bell_bell",
		{ pos = pos, gain = 1.5, max_hear_distance = 300,})
end
-- actually ring the bell
local ring_bell_once = function()
   for i,v in ipairs( bell_positions ) do
      ring_big_bell(v)
   end
end

local ring_bell_multiple = function(rings)
	for i=1, rings do
		minetest.after( (i-1)*5,  ring_bell_once )
	end
end

---------------------------------------------------------
--- Persistence

local save_bell_positions = function()

   local str = minetest.serialize( ({ bell_data = bell_positions}) )

   local file, err = io.open( BELL_SAVE_FILE, "wb")
   if (err ~= nil) then
      return
   end
   file:write( str )
   file:flush()
   file:close()
   --minetest.chat_send_all("Wrote data to savefile "..tostring( BELL_SAVE_FILE ))
end

local restore_bell_data = function()

   local bell_position_table

   local file, err = io.open(BELL_SAVE_FILE, "rb")
   if (err ~= nil) then
      return
   end
   local str = file:read()
   file:close()

   local bell_positions_table = minetest.deserialize( str )
   if( bell_positions_table and bell_positions_table.bell_data ) then
     bell_positions = bell_positions_table.bell_data
   end
end

---------------------------------------------------------
--- Local time handling

local rings_at_dawn = tonumber(minetest.settings:get("bell_tolls_at_dawn")) or 0
local rings_at_noon = tonumber(minetest.settings:get("bell_tolls_at_noon")) or 0
local rings_at_dusk = tonumber(minetest.settings:get("bell_tolls_at_dusk")) or 0
local rings_at_midnight = tonumber(minetest.settings:get("bell_tolls_at_midnight")) or 0

local ring_at_dawn =     rings_at_dawn > 0
local ring_at_noon =     rings_at_noon > 0
local ring_at_dusk =     rings_at_dusk > 0
local ring_at_midnight = rings_at_midnight > 0
local local_time = ring_at_dawn or ring_at_noon or ring_at_dusk or ring_at_midnight

local last_timeofday = 0
local dawn = 0.2 -- day and night in Minetest isn't exactly even
local noon = 0.5
local dusk = 0.8

if local_time then
	minetest.register_globalstep(function(dtime)
		local timeofday = minetest.get_timeofday()
		if ring_at_dawn and timeofday >= dawn and last_timeofday < dawn then
			ring_bell_multiple(rings_at_dawn)
			last_timeofday = timeofday
			return
		end
		if ring_at_noon and timeofday >= noon and last_timeofday < noon then
			ring_bell_multiple(rings_at_noon)
			last_timeofday = timeofday
			return
		end
		if ring_at_dusk and timeofday >= dusk and last_timeofday < dusk then
			ring_bell_multiple(rings_at_dusk)
			last_timeofday = timeofday
			return
		end
		if ring_at_midnight and timeofday < last_timeofday then
			-- day rolled over, it's midnight
			ring_bell_multiple(rings_at_midnight)
			last_timeofday = timeofday
			return
		end
		last_timeofday = timeofday
	end)
end

---------------------------------------------------------
--- Global time handling

local global_time = minetest.settings:get_bool("bell_tolls_at_server_hours", true)

local ring_bell
ring_bell = function()
	if not global_time then
		return
	end

   -- figure out if this is the right time to ring
   local sekunde = tonumber( os.date( "%S"))
   local minute  = tonumber( os.date( "%M"))
   local stunde  = tonumber( os.date( "%I")) -- in 12h-format (a bell that rings 24x at once would not survive long...)
   local delay   = RING_INTERVAL

   --print("[bells]It is now H:"..tostring( stunde ).." M:"..tostring(minute).." S:"..tostring( sekunde ))

   --local datum = os.date( "Stunde:%l Minute:%M Sekunde:%S")
   --print('[bells] ringing bells at '..tostring( datum ))

   delay = RING_INTERVAL - sekunde - (minute*60)

   -- make sure the bell rings the next hour
   minetest.after( delay, ring_bell )

   -- if no bells are around then don't ring
   if( bell_positions == nil or #bell_positions < 1 ) then
      return
   end

   if( sekunde > 10 ) then
--      print("[bells] Too late. Waiting for "..tostring( delay ).." seconds.")
      return
   end

   -- ring the bell for each hour once
   ring_bell_multiple(stunde)
end

-- first call (after the server has been started)
minetest.after( 10, ring_bell )
-- read data about bell positions
restore_bell_data()

---------------------------------------------------------
--- Node definitions

local bell_base = {
	paramtype = "light",
    description = S("Bell"),
    stack_max = 1,

    on_punch = function (pos,node,puncher)
        ring_big_bell(pos)
	end,

	on_construct = function(pos)
       -- remember that there is a bell at that position
       table.insert( bell_positions, pos )
       save_bell_positions()
	end,

	on_destruct = function(pos)
       local found = 0
       -- actually remove the bell from the list
       for i,v in ipairs( bell_positions ) do
          if(v ~= nil and vector.equals(v, pos)) then
             table.remove( bell_positions, i)
			 save_bell_positions()
			 break
          end
       end
    end,

    groups = {cracky=2},
}

if minetest.get_modpath("mesecons") then
	bell_base.mesecons = {
		effector = {
			action_on = ring_big_bell,
		}
	}
end

local ring_small_bell = function(pos)
	minetest.sound_play( "bell_small",
		{ pos = pos, gain = 1.5, max_hear_distance = 60,})
end

local small_bell_base = {
    description = S("Small bell"),
	paramtype = "light",
    stack_max = 1,
    on_punch = function (pos,node,puncher)
        ring_small_bell(pos)
	end,
    groups = {cracky=2},
}

if minetest.get_modpath("mesecons") then
	small_bell_base.mesecons = {
		effector = {
			action_on = ring_small_bell,
		}
	}
end

----------------------------------------------------
bell_enable_model = false
if minetest.settings:get_bool("bell_enable_model", true) then
----------------
-- Model-type bell
	local bell_def = {
		drawtype = "mesh",
		mesh = "bell_bell.obj",
		tiles = {
			{ name = "bell_hull.png", backface_culling = true }, --
			{ name = "bell_hull.png", backface_culling = true }, --
			{ name = "bell_hull.png", backface_culling = true }, --
			{ name = "default_wood.png", backface_culling = true }, --
			},
		collision_box = {
			type = "fixed",
			fixed = {
				{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
			},
		},
		selection_box = {
			type = "fixed",
			fixed = {
				{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
			},
		},
		paramtype2 = "facedir",
	}

	for k, v in pairs(bell_base) do
		bell_def[k] = v
	end

	minetest.register_node("bell:bell", bell_def)

	local small_bell_def =
	{	drawtype = "mesh",
		mesh = "bell_small_bell.obj",
		tiles = {
			{ name = "bell_hull.png", backface_culling = true }, --
			{ name = "bell_hull.png", backface_culling = true }, --
			{ name = "bell_hull.png", backface_culling = true }, --
			{ name = "default_wood.png", backface_culling = true }, --
			},
		collision_box = {
			type = "fixed",
			fixed = {
				{-0.375, -0.25, -0.375, 0.375, 0.5, 0.375},
			},
		},
		selection_box = {
			type = "fixed",
			fixed = {
				{-0.375, -0.25, -0.375, 0.375, 0.5, 0.375},
			},
		},
		paramtype2 = "facedir",
	}

	for k, v in pairs(small_bell_base) do
		small_bell_def[k] = v
	end

	minetest.register_node("bell:bell_small", small_bell_def)

else
--------------------
-- Plantlike-type bell
	local bell_def = {
		tiles = {"bell_bell.png"},
		inventory_image = 'bell_bell.png',
		wield_image = 'bell_bell.png',
		drawtype = "plantlike",
	}
	for k, v in pairs(bell_base) do
		bell_def[k] = v
	end

	minetest.register_node("bell:bell", bell_def)

	local small_bell_def = {
		tiles = {"bell_bell.png"},
		inventory_image = 'bell_bell.png',
		wield_image = 'bell_bell.png',
		drawtype = "plantlike",
	}
	for k, v in pairs(small_bell_base) do
		small_bell_def[k] = v
	end

	minetest.register_node("bell:bell_small", small_bell_def)
end

---------------------------------------------------------
--- Recipes

if minetest.get_modpath("default") then
	minetest.register_craft({
		output = "bell:bell_small",
		recipe = {
			{"",                  "default:goldblock", ""                 },
			{"default:goldblock", "default:goldblock", "default:goldblock"},
			{"default:goldblock", "",                  "default:goldblock"},
		},
	})
	minetest.register_craft({
		output = "bell:bell",
		recipe = {
			{"default:goldblock", "default:goldblock", "default:goldblock"},
			{"default:goldblock", "default:goldblock", "default:goldblock"},
			{"default:goldblock", "",                  "default:goldblock"},
		},
	})
end


code:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-19 19:07-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: init.lua:156
msgid "Bell"
msgstr ""

#: init.lua:228
msgid "Small bell"
msgstr ""


code:
@echo off
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
cd ..
set LIST=
for /r %%X in (*.lua) do set LIST=!LIST! %%X
..\intllib\tools\xgettext.bat %LIST%


code:
name = bell
description = Adds a bell the player can ring and a bell that auto-tolls on the hour.
optional_depends = default, mesecons


code:
#Number of times the big bells will toll at local midnight (0 to disable)
#Caution: default Minetest settings cause this to happen once per 20 minutes
bell_tolls_at_midnight (Bell tolls at midnight) int 0
#Number of times the big bells will toll at local dawn (0 to disable)
#Caution: default Minetest settings cause this to happen once per 20 minutes
bell_tolls_at_dawn (Bell tolls at dawn) int 0
#Number of times the big bells will toll at local noon (0 to disable)
#Caution: default Minetest settings cause this to happen once per 20 minutes
bell_tolls_at_noon (Bell tolls at noon) int 0
#Number of times the big bells will toll at local dusk (0 to disable)
#Caution: default Minetest settings cause this to happen once per 20 minutes
bell_tolls_at_dusk (Bell tolls at dusk) int 0

#Bell tolls the number of hours (per the real-world server timezone) on the hour
bell_tolls_at_server_hours (Bell tolls at server hours) bool true

bell_enable_model (Use model-based bell nodes) bool true


code:
Bonemeal mod [bonemeal]

This mod adds four new items into the game, bones which can be dug from normal
dirt which can be made into bonemeal, mulch which is is crafted using a tree and
8x leaves, and fertiliser which is a mixture of them both.

Each item can be used on saplings and crops for a chance to grow them quicker as
well as dirt which will generate random grass, flowers or whichever decoration
is registered.

Mulch has a strength of 1, Bonemeal 2 and Fertiliser 3 which means the stronger
the item, the more chance of growing saplings in low light, making crops sprout
quicker or simply decorate a larger area with grass and flowers.

The api.txt document shows how to add your own saplings, crops and grasses to
the list by using one of the 3 commands included and the mod.lua file gives you
many examples by using some of the popular mods available.

https://forum.minetest.net/viewtopic.php?f=9&t=16446

Changelog:

- 0.1 - Initial release
- 0.2 - Added global on_use function for bonemeal growth
- 0.3 - Added strength to on_use global for new items (mulch and fertiliser)
- 0.4 - Added Intllib support and fr.txt file
- 0.5 - Added support for default bush and acacia bush saplings
- 0.6 - Using newer functions, Minetest 0.4.16 and above needed to run
- 0.7 - Can be used on papyrus and cactus now, added coral recipe, api addition
- 0.8 - Added support for farming redo's new garlic, pepper and onion crops
- 0.9 - Added support for farming redo's pea and beetroot crops, checks for place_param
- 1.0 - add_deco() now adds to existing item list while set_deco() replaces item list (thanks h-v-smacker)
- 1.1 - Added {can_bonemeal=1} group for special nodes
- 1.2 - Added support for minetest 5.0 cactus seedling, blueberry bush sapling and emergent jungle tree saplings, additional flowers and pine bush sapling.

Lucky Blocks: 6


code:
Bonemeal API
============

This guide will show you how to add saplings, crops and dirt types for the
bonemeal mod to use from withhin your own mods.  Please make sure that bonemeal
appears in the depends.txt file of your mod so everything work properly.

Function Usage
==============

Adding Crops
------------

bonemeal:add_crop({
	{ nodename_start, growing_steps, seed_name }
})

This command is used to add new crops for bonemeal to work on.

e.g.

bonemeal:add_crop({
	{"farming:cotton_", 8, "farming:seed_cotton"},
	{"farming:wheat_", 8, "farming:seed_wheat"},
})

Adding Saplings
---------------

bonemeal:add_sapling({
	{ sapling_node, function, soil_type[sand, dirt, nodename] }
})

This command will add new saplings for bonemeal to grow on sand, soil or a
specified node type.

bonemeal:add_sapling({
	{"ethereal:palm_sapling", ethereal.grow_palm_tree, "soil"},
	{"ethereal:palm_sapling", ethereal.grow_palm_tree, "sand"},
})

Adding Dirt Decoration
----------------------

bonemeal:add_deco({
	{ dirt_node, {grass_node_list}, {decor_node_list} }
})

This command will add grass and decoration to specific dirt types, use "" to
add an empty node. If some decorations have been already defined for this dirt type, new
will be added to the respective list. All empty ("") entries will be added regardless,
which allows to decrease the frequency of decoration emergence, if needed.

e.g.

bonemeal:add_deco({
	{"default:dirt_with_dry_grass", {"default:dry_grass_1", ""},
		{"flowers:rose", "flowers:viola"} }
})

Thus, add_deco() always adds (to) a definition, and never overrides. To discard an existing
definiton in favor of the new one, use

bonemeal:set_deco({
	{ dirt_node, {grass_node_list}, {decor_node_list} }
})

This command will set decoration for a given dirt type, fully replacing any existing definition.

Global ON_USE Function
----------------------

bonemeal:on_use(pos, strength, node)

This function can be called from other mods to grow plants using alternative
bonemeal items and have the same effect.

  {pos} is the location to apply growing
  {strength} is how strong to grow [low of 1 to high of 4]
  {node} is the node at pos, but can be left nil to get_node itself

Note: Higher strength items require lower light levels, and a strength of 4
needs no light at all.

Final Words
===========

I hope this guide helps you add your own plants so you can grow them quickly
with the items included.  Please check the mods.lua for more examples.