Merge pull request 'master' (#5) from MineClone2/MineClone2:master into master

Reviewed-on: https://git.minetest.land/NO11/MineClone2/pulls/5
This commit is contained in:
NO11 2021-08-11 15:38:44 +00:00
commit 7e0bb036f4
13 changed files with 371 additions and 229 deletions

View File

@ -0,0 +1,24 @@
# mcl_item_id
Show the item ID of an item in the description.
With this API, you can register a different name space than "mineclone" for your mod.
## mcl_item_id.set_mod_namespace(modname, namespace)
Set a name space for all items in a mod.
* param1: the modname
* param2: (optional) string of the desired name space, if nil, it is the name of the mod
## mcl_item_id.get_mod_namespace(modname)
Get the name space of a mod registered with mcl_item_id.set_mod_namespace(modname, namespace).
* param1: the modname
### Examples:
The name of the mod is "mod" which registered an item called "mod:itemname".
* mcl_item_id.set_mod_namespace("mod", "mymod") will show "mymod:itemname" in the description of "mod:itemname"
* mcl_item_id.set_mod_namespace(minetest.get_current_modname()) will show "mod:itemname" in the description of "mod:itemname"
* mcl_item_id.get_mod_namespace(minetest.get_current_modname()) will return "mod"
(If no namespace is set by a mod, mcl_item_id.get_mod_namespace(minetest.get_current_modname()) will return "mineclone")

View File

@ -1,6 +1,26 @@
mcl_item_id = {
mod_namespaces = {},
}
local game = "mineclone" local game = "mineclone"
function mcl_item_id.set_mod_namespace(modname, namespace)
local namespace = namespace or modname
mcl_item_id.mod_namespaces[modname] = namespace
end
function mcl_item_id.get_mod_namespace(modname)
local namespace = mcl_item_id.mod_namespaces[modname]
if namespace then
return namespace
else
return game
end
end
local same_id = { local same_id = {
enchanting = { "table" },
experience = { "bottle" },
heads = { "skeleton", "zombie", "creeper", "wither_skeleton" }, heads = { "skeleton", "zombie", "creeper", "wither_skeleton" },
mobitems = { "rabbit", "chicken" }, mobitems = { "rabbit", "chicken" },
walls = { walls = {
@ -10,7 +30,7 @@ local same_id = {
"stonebrick", "stonebrickmossy", "stonebrick", "stonebrickmossy",
}, },
wool = { wool = {
"black", "blue", "brown", "cyan", "green", "black", "blue", "brown", "cyan", "green",
"grey", "light_blue", "lime", "magenta", "orange", "grey", "light_blue", "lime", "magenta", "orange",
"pink", "purple", "red", "silver", "white", "yellow", "pink", "purple", "red", "silver", "white", "yellow",
}, },
@ -18,9 +38,11 @@ local same_id = {
tt.register_snippet(function(itemstring) tt.register_snippet(function(itemstring)
local def = minetest.registered_items[itemstring] local def = minetest.registered_items[itemstring]
local desc = def.description
local item_split = itemstring:find(":") local item_split = itemstring:find(":")
local new_id = game .. itemstring:sub(item_split) local id_string = itemstring:sub(item_split)
local id_modname = itemstring:sub(1, item_split - 1)
local new_id = game .. id_string
local mod_namespace = mcl_item_id.get_mod_namespace(id_modname)
for mod, ids in pairs(same_id) do for mod, ids in pairs(same_id) do
for _, id in pairs(ids) do for _, id in pairs(ids) do
if itemstring == "mcl_" .. mod .. ":" .. id then if itemstring == "mcl_" .. mod .. ":" .. id then
@ -28,12 +50,13 @@ tt.register_snippet(function(itemstring)
end end
end end
end end
if new_id ~= game .. ":book_enchanted" then if mod_namespace ~= game then
new_id = mod_namespace .. id_string
end
if mod_namespace ~= id_modname then
minetest.register_alias_force(new_id, itemstring) minetest.register_alias_force(new_id, itemstring)
end end
if minetest.settings:get_bool("mcl_item_id_debug", false) then if minetest.settings:get_bool("mcl_item_id_debug", false) then
return new_id, "#555555" return new_id, "#555555"
end end
end) end)
minetest.register_alias_force(game .. ":book_enchanted", "mcl_enchanting:book_enchanted")

View File

@ -45,3 +45,4 @@ Mining durability: @1=Grabehaltbarkeit: @1
Block breaking strength: @1=Blockbruchstärke: @1 Block breaking strength: @1=Blockbruchstärke: @1
@1 uses=@1 Verwendungen @1 uses=@1 Verwendungen
Unlimited uses=Unbegrenzte Verwendungen Unlimited uses=Unbegrenzte Verwendungen
Durability: @1=Haltbarkeit: @1

View File

@ -45,3 +45,4 @@ Mining durability: @1=
Block breaking strength: @1= Block breaking strength: @1=
@1 uses= @1 uses=
Unlimited uses= Unlimited uses=
Durability: @1=

View File

@ -107,3 +107,8 @@ tt.register_snippet(function(itemstring)
end end
end) end)
tt.register_snippet(function(itemstring, _, itemstack)
if itemstring:sub(1, 23) == "mcl_fishing:fishing_rod" or itemstring:sub(1, 12) == "mcl_bows:bow" then
return S("Durability: @1", S("@1 uses", mcl_util.calculate_durability(itemstack or ItemStack(itemstring))))
end
end)

View File

@ -9,13 +9,46 @@ Accept folowing params:
* string: name of the node to place * string: name of the node to place
* function(pos): will returns name of the node to place with pos being the placement position * function(pos): will returns name of the node to place with pos being the placement position
* source_take: table of liquid source node names to take * source_take: table of liquid source node names to take
* itemname: itemstring of the new bucket item (or nil if liquid is not takeable) * bucketname: itemstring of the new bucket item
* inventory_image: texture of the new bucket item (ignored if itemname == nil) * inventory_image: texture of the new bucket item (ignored if itemname == nil)
* name: user-visible bucket description * name: user-visible bucket description
* longdesc: long explanatory description (for help) * longdesc: long explanatory description (for help)
* usagehelp: short usage explanation (for help) * usagehelp: short usage explanation (for help)
* tt_help: very short tooltip help * tt_help: very short tooltip help
* extra_check(pos, placer): (optional) function(pos) which can returns false to avoid placing the liquid. Placer is object/player who is placing the liquid, can be nil. * extra_check(pos, placer): (optional) function(pos)
* groups: optional list of item groups * groups: optional list of item groups
This function can be called from any mod (which depends on this one)
**Usage exemple:**
```lua
mcl_buckets.register_liquid({
bucketname = "dummy:bucket_dummy",
--source_place = "dummy:dummy_source",
source_place = function(pos)
if condition then
return "dummy:dummy_source"
else
return "dummy:dummy_source_nether"
end
end,
source_take = {"dummy:dummy_source"},
inventory_image = "bucket_dummy.png",
name = S("Dummy liquid Bucket"),
longdesc = S("This bucket is filled with a dummy liquid."),
usagehelp = S("Place it to empty the bucket and create a dummy liquid source."),
tt_help = S("Places a dummy liquid source"),
extra_check = function(pos, placer)
--pos = pos where the liquid should be placed
--placer people who tried to place the bucket (can be nil)
--no liquid node will be placed
--the bucket will not be emptied
--return false, false
--liquid node will be placed
--the bucket will be emptied
return true, true
end,
groups = { dummy_group = 123 },
})
```

View File

@ -1,9 +1,12 @@
Bucket mod. # MineClone2 Bucket (`mcl_bucket`)
Originally taken from Minetest Game, adapted for MineClone 2. Originally taken from Minetest Game, adapted for MineClone2.
This mod add buckets to the game, including an API to register your own (see `API.md`).
## License
License of source code:
-----------------------
Copyright (C) 2011-2012 Kahrl <kahrl@gmx.net> Copyright (C) 2011-2012 Kahrl <kahrl@gmx.net>
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com> Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify

View File

@ -3,6 +3,7 @@ local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname) local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
-- Compatibility with old bucket mod
minetest.register_alias("bucket:bucket_empty", "mcl_buckets:bucket_empty") minetest.register_alias("bucket:bucket_empty", "mcl_buckets:bucket_empty")
minetest.register_alias("bucket:bucket_water", "mcl_buckets:bucket_water") minetest.register_alias("bucket:bucket_water", "mcl_buckets:bucket_water")
minetest.register_alias("bucket:bucket_lava", "mcl_buckets:bucket_lava") minetest.register_alias("bucket:bucket_lava", "mcl_buckets:bucket_lava")
@ -11,13 +12,24 @@ local mod_doc = minetest.get_modpath("doc")
local mod_mcl_core = minetest.get_modpath("mcl_core") local mod_mcl_core = minetest.get_modpath("mcl_core")
--local mod_mclx_core = minetest.get_modpath("mclx_core") --local mod_mclx_core = minetest.get_modpath("mclx_core")
-- Localize some functions for faster access
local vector = vector
local math = math
local string = string
local raycast = minetest.raycast
local get_node = minetest.get_node
local add_node = minetest.add_node
local add_item = minetest.add_item
if mod_mcl_core then if mod_mcl_core then
minetest.register_craft({ minetest.register_craft({
output = "mcl_buckets:bucket_empty 1", output = "mcl_buckets:bucket_empty 1",
recipe = { recipe = {
{"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
{"", "mcl_core:iron_ingot", ""}, {"", "mcl_core:iron_ingot", ""},
} },
}) })
end end
@ -25,147 +37,218 @@ mcl_buckets = {}
mcl_buckets.liquids = {} mcl_buckets.liquids = {}
-- Sound helper functions for placing and taking liquids -- Sound helper functions for placing and taking liquids
local sound_place = function(itemname, pos) local function sound_place(itemname, pos)
local def = minetest.registered_nodes[itemname] local def = minetest.registered_nodes[itemname]
if def and def.sounds and def.sounds.place then if def and def.sounds and def.sounds.place then
minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
end end
end end
local sound_take = function(itemname, pos) local function sound_take(itemname, pos)
local def = minetest.registered_nodes[itemname] local def = minetest.registered_nodes[itemname]
if def and def.sounds and def.sounds.dug then if def and def.sounds and def.sounds.dug then
minetest.sound_play(def.sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) minetest.sound_play(def.sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
end end
end end
local place_liquid = function(pos, itemstring) local function place_liquid(pos, itemstring)
local fullness = minetest.registered_nodes[itemstring].liquid_range local fullness = minetest.registered_nodes[itemstring].liquid_range
sound_place(itemstring, pos) sound_place(itemstring, pos)
minetest.add_node(pos, {name=itemstring, param2=fullness}) minetest.add_node(pos, {name=itemstring, param2=fullness})
end end
local function give_bucket(new_bucket, itemstack, user)
local inv = user:get_inventory()
if minetest.is_creative_enabled(user:get_player_name()) then
--TODO: is a full bucket added if inv doesn't contain one?
return itemstack
else
if itemstack:get_count() == 1 then
return new_bucket
else
if inv:room_for_item("main", new_bucket) then
inv:add_item("main", new_bucket)
else
add_item(user:get_pos(), new_bucket)
end
itemstack:take_item()
return itemstack
end
end
end
local pointable_sources = {}
local function bucket_raycast(user)
--local pos = user:get_pos()
local pos = user:get_pos()
--local pos = vector.add(user:get_pos(), user:get_bone_position("Head_Control"))
pos.y = pos.y + user:get_properties().eye_height
local look_dir = user:get_look_dir()
look_dir = vector.multiply(look_dir, 5)
local pos2 = vector.add(pos, look_dir)
local ray = raycast(pos, pos2, false, true)
if ray then
for pointed_thing in ray do
if pointed_thing and pointable_sources[get_node(pointed_thing.above).name] then
--minetest.chat_send_all("found!")
return {under=pointed_thing.under,above=pointed_thing.above}
end
end
end
return nil
end
local function get_node_place(source_place, place_pos)
local node_place
if type(source_place) == "function" then
node_place = source_place(place_pos)
else
node_place = source_place
end
return node_place
end
local function get_extra_check(check, pos, user)
local result
local take_bucket
if check then
result, take_bucket = check(pos, user)
if result == nil then result = true end
if take_bucket == nil then take_bucket = true end
else
result = true
take_bucket = true
end
return result, take_bucket
end
local function get_bucket_drop(itemstack, user, take_bucket)
-- Handle bucket item and inventory stuff
if take_bucket and not minetest.is_creative_enabled(user:get_player_name()) then
-- Add empty bucket and put it into inventory, if possible.
-- Drop empty bucket otherwise.
local new_bucket = ItemStack("mcl_buckets:bucket_empty")
if itemstack:get_count() == 1 then
return new_bucket
else
local inv = user:get_inventory()
if inv:room_for_item("main", new_bucket) then
inv:add_item("main", new_bucket)
else
add_item(user:get_pos(), new_bucket)
end
itemstack:take_item()
return itemstack
end
else
return itemstack
end
end
function mcl_buckets.register_liquid(def) function mcl_buckets.register_liquid(def)
for i=1, #def.source_take do for _,source in ipairs(def.source_take) do
mcl_buckets.liquids[def.source_take[i]] = { mcl_buckets.liquids[source] = {
source_place = def.source_place, source_place = def.source_place,
source_take = def.source_take[i], source_take = source,
on_take = def.on_take, on_take = def.on_take,
itemname = def.itemname, bucketname = def.bucketname,
} }
pointable_sources[source] = true
if type(def.source_place) == "string" then if type(def.source_place) == "string" then
mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[def.source_take[i]] mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[source]
end end
end end
if def.itemname then if def.bucketname == nil or def.bucketname == "" then
minetest.register_craftitem(def.itemname, { error(string.format("[mcl_bucket] Invalid itemname then registering [%s]!", def.name))
description = def.name, end
_doc_items_longdesc = def.longdesc,
_doc_items_usagehelp = def.usagehelp,
_tt_help = def.tt_help,
inventory_image = def.inventory_image,
stack_max = 1,
groups = def.groups,
on_place = function(itemstack, user, pointed_thing)
-- Must be pointing to node
if pointed_thing.type ~= "node" then
return
end
local node = minetest.get_node(pointed_thing.under) minetest.register_craftitem(def.bucketname, {
local place_pos = pointed_thing.under description = def.name,
local nn = node.name _doc_items_longdesc = def.longdesc,
local nodedef = minetest.registered_nodes[nn] _doc_items_usagehelp = def.usagehelp,
-- Call on_rightclick if the pointed node defines it _tt_help = def.tt_help,
if user and not user:get_player_control().sneak then inventory_image = def.inventory_image,
if nodedef and nodedef.on_rightclick then stack_max = 1,
return nodedef.on_rightclick(place_pos, node, user, itemstack) or itemstack groups = def.groups,
end on_place = function(itemstack, user, pointed_thing)
end -- Must be pointing to node
if pointed_thing.type ~= "node" then
return
end
-- Call on_rightclick if the pointed node defines it
local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing)
if new_stack then
return new_stack
end
local node_place local undernode = get_node(pointed_thing.under)
if type(def.source_place) == "function" then local abovenode = get_node(pointed_thing.above)
node_place = def.source_place(place_pos) local buildable1 = minetest.registered_nodes[undernode.name] and minetest.registered_nodes[undernode.name].buildable_to
else local buildable2 = minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to
node_place = def.source_place if not buildable1 and not buildable2 then return itemstack end --if both nodes aren't buildable_to, skip
end
-- Check if pointing to a buildable node
--local item = itemstack:get_name()
if def.extra_check and def.extra_check(place_pos, user) == true and nodedef and nodedef.buildable_to then if buildable1 then
-- buildable; replace the node local result, take_bucket = get_extra_check(def.extra_check, pointed_thing.under, user)
if result then
local node_place = get_node_place(def.source_place, pointed_thing.under)
local pns = user:get_player_name() local pns = user:get_player_name()
if minetest.is_protected(place_pos, pns) then
minetest.record_protection_violation(place_pos, pns) -- Check protection
if minetest.is_protected(pointed_thing.under, pns) then
minetest.record_protection_violation(pointed_thing.under, pns)
return itemstack return itemstack
end end
place_liquid(place_pos, node_place)
-- Place liquid
place_liquid(pointed_thing.under, node_place)
-- Update doc mod
if mod_doc and doc.entry_exists("nodes", node_place) then if mod_doc and doc.entry_exists("nodes", node_place) then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place)
end end
else
-- not buildable to; place the liquid above
-- check if the node above can be replaced
local abovenode = minetest.get_node(pointed_thing.above)
if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then
local pn = user:get_player_name()
if minetest.is_protected(pointed_thing.above, pn) then
minetest.record_protection_violation(pointed_thing.above, pn)
return itemstack
end
place_liquid(pointed_thing.above, node_place)
if mod_doc and doc.entry_exists("nodes", node_place) then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place)
end
else
-- do not remove the bucket with the liquid
return
end
end end
return get_bucket_drop(itemstack, user, take_bucket)
elseif buildable2 then
local result, take_bucket = get_extra_check(def.extra_check, pointed_thing.above, user)
if result then
local node_place = get_node_place(def.source_place, pointed_thing.above)
local pns = user:get_player_name()
-- Handle bucket item and inventory stuff -- Check protection
if not minetest.is_creative_enabled(user:get_player_name()) then if minetest.is_protected(pointed_thing.above, pns) then
-- Add empty bucket and put it into inventory, if possible. minetest.record_protection_violation(pointed_thing.above, pns)
-- Drop empty bucket otherwise.
local new_bucket = ItemStack("mcl_buckets:bucket_empty")
if itemstack:get_count() == 1 then
return new_bucket
else
local inv = user:get_inventory()
if inv:room_for_item("main", new_bucket) then
inv:add_item("main", new_bucket)
else
minetest.add_item(user:get_pos(), new_bucket)
end
itemstack:take_item()
return itemstack return itemstack
end end
else
return
end
end,
_on_dispense = function(stack, pos, droppos, dropnode, dropdir)
--local iname = stack:get_name()
local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal"
--if def.extra_check and def.extra_check(droppos, nil) == false then -- Place liquid
-- Fail placement of liquid place_liquid(pointed_thing.above, node_place)
if def.extra_check and def.extra_check(droppos, nil) == true and buildable then
-- buildable; replace the node -- Update doc mod
local node_place if mod_doc and doc.entry_exists("nodes", node_place) then
if type(def.source_place) == "function" then doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place)
node_place = def.source_place(droppos)
else
node_place = def.source_place
end end
place_liquid(droppos, node_place)
stack:set_name("mcl_buckets:bucket_empty")
end end
return stack return get_bucket_drop(itemstack, user, take_bucket)
end, else
}) return itemstack
end end
end,
_on_dispense = function(stack, pos, droppos, dropnode, dropdir)
local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal"
if not buildable then return stack end
local result, take_bucket = get_extra_check(def.extra_check, droppos, nil)
if result then -- Fail placement of liquid if result is false
place_liquid(droppos, get_node_place(def.source_place, droppos))
end
if take_bucket then
stack:set_name("mcl_buckets:bucket_empty")
end
return stack
end,
})
end end
minetest.register_craftitem("mcl_buckets:bucket_empty", { minetest.register_craftitem("mcl_buckets:bucket_empty", {
@ -173,8 +256,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
_doc_items_longdesc = S("A bucket can be used to collect and release liquids."), _doc_items_longdesc = S("A bucket can be used to collect and release liquids."),
_doc_items_usagehelp = S("Punch a liquid source to collect it. You can then use the filled bucket to place the liquid somewhere else."), _doc_items_usagehelp = S("Punch a liquid source to collect it. You can then use the filled bucket to place the liquid somewhere else."),
_tt_help = S("Collects liquids"), _tt_help = S("Collects liquids"),
--liquids_pointable = true,
liquids_pointable = true,
inventory_image = "bucket.png", inventory_image = "bucket.png",
stack_max = 16, stack_max = 16,
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
@ -184,74 +266,70 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
end end
-- Call on_rightclick if the pointed node defines it -- Call on_rightclick if the pointed node defines it
local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing)
if new_stack then
return new_stack
end
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
local nn = node.name local nn = node.name
if user and not user:get_player_control().sneak then
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then
return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
end
end
-- Can't steal liquids
if minetest.is_protected(pointed_thing.above, user:get_player_name()) then
minetest.record_protection_violation(pointed_thing.under, user:get_player_name())
return itemstack
end
-- Check if pointing to a liquid source
local liquiddef = mcl_buckets.liquids[nn]
local new_bucket local new_bucket
if liquiddef and liquiddef.itemname and (nn == liquiddef.source_take) then local liquid_node = bucket_raycast(user)
if liquid_node then
-- Fill bucket, but not in Creative Mode if minetest.is_protected(liquid_node.above, user:get_player_name()) then
if not minetest.is_creative_enabled(user:get_player_name()) then minetest.record_protection_violation(liquid_node.above, user:get_player_name())
new_bucket = ItemStack({name = liquiddef.itemname})
if liquiddef.on_take then
liquiddef.on_take(user)
end
end end
local liquid_name = get_node(liquid_node.above).name
if liquid_name then
local liquid_def = mcl_buckets.liquids[liquid_name]
if liquid_def then
--minetest.chat_send_all("test")
-- Fill bucket, but not in Creative Mode
-- FIXME: remove this line
--if not minetest.is_creative_enabled(user:get_player_name()) then
if not false then
new_bucket = ItemStack({name = liquid_def.bucketname})
if liquid_def.on_take then
liquid_def.on_take(user)
end
end
add_node(liquid_node.above, {name="air"})
sound_take(nn, liquid_node.above)
minetest.add_node(pointed_thing.under, {name="air"}) if mod_doc and doc.entry_exists("nodes", liquid_name) then
sound_take(nn, pointed_thing.under) doc.mark_entry_as_revealed(user:get_player_name(), "nodes", liquid_name)
end
if mod_doc and doc.entry_exists("nodes", nn) then if new_bucket then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", nn) return give_bucket(new_bucket, itemstack, user)
end end
elseif nn == "mcl_cauldrons:cauldron_3" then
-- Take water out of full cauldron
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
if not minetest.is_creative_enabled(user:get_player_name()) then
new_bucket = ItemStack("mcl_buckets:bucket_water")
end
sound_take("mcl_core:water_source", pointed_thing.under)
elseif nn == "mcl_cauldrons:cauldron_3r" then
-- Take river water out of full cauldron
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
if not minetest.is_creative_enabled(user:get_player_name()) then
new_bucket = ItemStack("mcl_buckets:bucket_river_water")
end
sound_take("mclx_core:river_water_source", pointed_thing.under)
end
-- Add liquid bucket and put it into inventory, if possible.
-- Drop new bucket otherwise.
if new_bucket then
if itemstack:get_count() == 1 then
return new_bucket
else
local inv = user:get_inventory()
if inv:room_for_item("main", new_bucket) then
inv:add_item("main", new_bucket)
else else
minetest.add_item(user:get_pos(), new_bucket) minetest.log("error", string.format("[mcl_buckets] Node [%s] has invalid group [_mcl_bucket_pointable]!", liquid_name))
end end
if not minetest.is_creative_enabled(user:get_player_name()) then
itemstack:take_item()
end
return itemstack
end end
end return itemstack
else
-- FIXME: replace this ugly code by cauldrons API
if nn == "mcl_cauldrons:cauldron_3" then
-- Take water out of full cauldron
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
if not minetest.is_creative_enabled(user:get_player_name()) then
new_bucket = ItemStack("mcl_buckets:bucket_water")
end
sound_take("mcl_core:water_source", pointed_thing.under)
elseif nn == "mcl_cauldrons:cauldron_3r" then
-- Take river water out of full cauldron
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
if not minetest.is_creative_enabled(user:get_player_name()) then
new_bucket = ItemStack("mcl_buckets:bucket_river_water")
end
sound_take("mclx_core:river_water_source", pointed_thing.under)
end
if new_bucket then
return give_bucket(new_bucket, itemstack, user)
end
end
return itemstack
end, end,
_on_dispense = function(stack, pos, droppos, dropnode, dropdir) _on_dispense = function(stack, pos, droppos, dropnode, dropdir)
-- Fill empty bucket with liquid or drop bucket if no liquid -- Fill empty bucket with liquid or drop bucket if no liquid
@ -259,9 +337,9 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
local liquiddef = mcl_buckets.liquids[dropnode.name] local liquiddef = mcl_buckets.liquids[dropnode.name]
local new_bucket local new_bucket
if liquiddef and liquiddef.itemname and (dropnode.name == liquiddef.source_take) then if liquiddef and liquiddef.bucketname and (dropnode.name == liquiddef.source_take) then
-- Fill bucket -- Fill bucket
new_bucket = ItemStack({name = liquiddef.itemname}) new_bucket = ItemStack({name = liquiddef.bucketname})
sound_take(dropnode.name, droppos) sound_take(dropnode.name, droppos)
collect_liquid = true collect_liquid = true
end end

View File

@ -1,6 +1,6 @@
name = mcl_buckets name = mcl_buckets
author = Kahrl author = Kahrl
description = description =
depends = mcl_worlds depends = mcl_worlds, mcl_util
optional_depends = mcl_core, mclx_core, doc optional_depends = mcl_core, mclx_core, doc

View File

@ -3,7 +3,7 @@ local mod_mcl_core = minetest.get_modpath("mcl_core")
local mod_mclx_core = minetest.get_modpath("mclx_core") local mod_mclx_core = minetest.get_modpath("mclx_core")
local has_awards = minetest.get_modpath("awards") local has_awards = minetest.get_modpath("awards")
local sound_place = function(itemname, pos) local function sound_place(itemname, pos)
local def = minetest.registered_nodes[itemname] local def = minetest.registered_nodes[itemname]
if def and def.sounds and def.sounds.place then if def and def.sounds and def.sounds.place then
minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
@ -34,7 +34,7 @@ if mod_mcl_core then
awards.unlock(user:get_player_name(), "mcl:hotStuff") awards.unlock(user:get_player_name(), "mcl:hotStuff")
end end
end, end,
itemname = "mcl_buckets:bucket_lava", bucketname = "mcl_buckets:bucket_lava",
inventory_image = "bucket_lava.png", inventory_image = "bucket_lava.png",
name = S("Lava Bucket"), name = S("Lava Bucket"),
longdesc = S("A bucket can be used to collect and release liquids. This one is filled with hot lava, safely contained inside. Use with caution."), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with hot lava, safely contained inside. Use with caution."),
@ -46,22 +46,13 @@ if mod_mcl_core then
mcl_buckets.register_liquid({ mcl_buckets.register_liquid({
source_place = "mcl_core:water_source", source_place = "mcl_core:water_source",
source_take = {"mcl_core:water_source"}, source_take = {"mcl_core:water_source"},
itemname = "mcl_buckets:bucket_water", bucketname = "mcl_buckets:bucket_water",
inventory_image = "bucket_water.png", inventory_image = "bucket_water.png",
name = S("Water Bucket"), name = S("Water Bucket"),
longdesc = S("A bucket can be used to collect and release liquids. This one is filled with water."), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with water."),
usagehelp = S("Place it to empty the bucket and create a water source."), usagehelp = S("Place it to empty the bucket and create a water source."),
tt_help = S("Places a water source"), tt_help = S("Places a water source"),
extra_check = function(pos, placer) extra_check = function(pos, placer)
-- Check protection
local placer_name = ""
if placer then
placer_name = placer:get_player_name()
end
if placer and minetest.is_protected(pos, placer_name) then
minetest.record_protection_violation(pos, placer_name)
return false
end
local nn = minetest.get_node(pos).name local nn = minetest.get_node(pos).name
-- Pour water into cauldron -- Pour water into cauldron
if minetest.get_item_group(nn, "cauldron") ~= 0 then if minetest.get_item_group(nn, "cauldron") ~= 0 then
@ -70,13 +61,13 @@ if mod_mcl_core then
minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3"}) minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3"})
end end
sound_place("mcl_core:water_source", pos) sound_place("mcl_core:water_source", pos)
return false return false, true
-- Evaporate water if used in Nether (except on cauldron) -- Evaporate water if used in Nether (except on cauldron)
else else
local dim = mcl_worlds.pos_to_dimension(pos) local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true)
return false return false, true
end end
end end
end, end,
@ -89,22 +80,13 @@ if mod_mclx_core then
mcl_buckets.register_liquid({ mcl_buckets.register_liquid({
source_place = "mclx_core:river_water_source", source_place = "mclx_core:river_water_source",
source_take = {"mclx_core:river_water_source"}, source_take = {"mclx_core:river_water_source"},
itemname = "mcl_buckets:bucket_river_water", bucketname = "mcl_buckets:bucket_river_water",
inventory_image = "bucket_river_water.png", inventory_image = "bucket_river_water.png",
name = S("River Water Bucket"), name = S("River Water Bucket"),
longdesc = S("A bucket can be used to collect and release liquids. This one is filled with river water."), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with river water."),
usagehelp = S("Place it to empty the bucket and create a river water source."), usagehelp = S("Place it to empty the bucket and create a river water source."),
tt_help = S("Places a river water source"), tt_help = S("Places a river water source"),
extra_check = function(pos, placer) extra_check = function(pos, placer)
-- Check protection
local placer_name = ""
if placer then
placer_name = placer:get_player_name()
end
if placer and minetest.is_protected(pos, placer_name) then
minetest.record_protection_violation(pos, placer_name)
return false
end
local nn = minetest.get_node(pos).name local nn = minetest.get_node(pos).name
-- Pour into cauldron -- Pour into cauldron
if minetest.get_item_group(nn, "cauldron") ~= 0 then if minetest.get_item_group(nn, "cauldron") ~= 0 then
@ -113,13 +95,13 @@ if mod_mclx_core then
minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3r"}) minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3r"})
end end
sound_place("mcl_core:water_source", pos) sound_place("mcl_core:water_source", pos)
return false return false, true
else else
-- Evaporate water if used in Nether (except on cauldron) -- Evaporate water if used in Nether (except on cauldron)
local dim = mcl_worlds.pos_to_dimension(pos) local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true)
return false return false, true
end end
end end
end, end,

View File

@ -453,7 +453,7 @@ function mcl_end.grow_chorus_plant_step(pos, node, pr)
end end
--- ABM --- --- ABM ---
local seed = minetest.get_mapgen_params().seed local seed = minetest.get_mapgen_setting("seed")
local pr = PseudoRandom(seed) local pr = PseudoRandom(seed)
minetest.register_abm({ minetest.register_abm({
label = "Chorus plant growth", label = "Chorus plant growth",

View File

@ -35,13 +35,13 @@ local function potions_init_icons(player)
local name = player:get_player_name() local name = player:get_player_name()
icon_ids[name] = {} icon_ids[name] = {}
for e=1, EFFECT_TYPES do for e=1, EFFECT_TYPES do
local x = -7 + -38 * e local x = -52 * e - 2
local id = player:hud_add({ local id = player:hud_add({
hud_elem_type = "image", hud_elem_type = "image",
text = "blank.png", text = "blank.png",
position = { x = 1, y = 0 }, position = { x = 1, y = 0 },
offset = { x = x, y = 272 }, offset = { x = x, y = 3 },
scale = { x = 2, y = 2 }, scale = { x = 3, y = 3 },
alignment = { x = 1, y = 1 }, alignment = { x = 1, y = 1 },
z_index = 100, z_index = 100,
}) })

View File

@ -152,26 +152,18 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso
-- If false, force item to not spawn any food partiles when eaten -- If false, force item to not spawn any food partiles when eaten
if def._food_particles ~= false and texture and texture ~= "" then if def._food_particles ~= false and texture and texture ~= "" then
local v = user:get_velocity() or user:get_player_velocity() local v = user:get_velocity() or user:get_player_velocity()
local minvel = vector.add(v, {x=-1, y=1, z=-1}) for i = 0, math.min(math.max(8, hunger_change*2), 25) do
local maxvel = vector.add(v, {x=1, y=2, z=1}) minetest.add_particle({
pos = { x = pos.x, y = pos.y, z = pos.z },
minetest.add_particlespawner({ velocity = vector.add(v, { x = math.random(-1, 1), y = math.random(1, 2), z = math.random(-1, 1) }),
amount = math.min(math.max(8, hunger_change*2), 25), acceleration = { x = 0, y = math.random(-9, -5), z = 0 },
time = 0.1, expirationtime = 1,
minpos = {x=pos.x, y=pos.y, z=pos.z}, size = math.random(1, 2),
maxpos = {x=pos.x, y=pos.y, z=pos.z}, collisiondetection = true,
minvel = minvel, vertical = false,
maxvel = maxvel, texture = "[combine:3x3:" .. -i .. "," .. -i .. "=" .. texture,
minacc = {x=0, y=-5, z=0}, })
maxacc = {x=0, y=-9, z=0}, end
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 2,
collisiondetection = true,
vertical = false,
texture = texture,
})
end end
minetest.sound_play("mcl_hunger_bite", { minetest.sound_play("mcl_hunger_bite", {
max_hear_distance = 12, max_hear_distance = 12,