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"
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 = {
enchanting = { "table" },
experience = { "bottle" },
heads = { "skeleton", "zombie", "creeper", "wither_skeleton" },
mobitems = { "rabbit", "chicken" },
walls = {
@ -18,9 +38,11 @@ local same_id = {
tt.register_snippet(function(itemstring)
local def = minetest.registered_items[itemstring]
local desc = def.description
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 _, id in pairs(ids) do
if itemstring == "mcl_" .. mod .. ":" .. id then
@ -28,12 +50,13 @@ tt.register_snippet(function(itemstring)
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)
end
if minetest.settings:get_bool("mcl_item_id_debug", false) then
return new_id, "#555555"
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
@1 uses=@1 Verwendungen
Unlimited uses=Unbegrenzte Verwendungen
Durability: @1=Haltbarkeit: @1

View file

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

View file

@ -107,3 +107,8 @@ tt.register_snippet(function(itemstring)
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
* 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
* 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)
* name: user-visible bucket description
* longdesc: long explanatory description (for help)
* usagehelp: short usage explanation (for 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
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 MineClone2.
License of source code:
-----------------------
This mod add buckets to the game, including an API to register your own (see `API.md`).
## License
Copyright (C) 2011-2012 Kahrl <kahrl@gmx.net>
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
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 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_water", "mcl_buckets:bucket_water")
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_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
minetest.register_craft({
output = "mcl_buckets:bucket_empty 1",
recipe = {
{"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
{"", "mcl_core:iron_ingot", ""},
}
},
})
end
@ -25,41 +37,135 @@ mcl_buckets = {}
mcl_buckets.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]
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)
end
end
local sound_take = function(itemname, pos)
local function sound_take(itemname, pos)
local def = minetest.registered_nodes[itemname]
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)
end
end
local place_liquid = function(pos, itemstring)
local function place_liquid(pos, itemstring)
local fullness = minetest.registered_nodes[itemstring].liquid_range
sound_place(itemstring, pos)
minetest.add_node(pos, {name=itemstring, param2=fullness})
end
function mcl_buckets.register_liquid(def)
for i=1, #def.source_take do
mcl_buckets.liquids[def.source_take[i]] = {
source_place = def.source_place,
source_take = def.source_take[i],
on_take = def.on_take,
itemname = def.itemname,
}
if type(def.source_place) == "string" then
mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[def.source_take[i]]
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
if def.itemname then
minetest.register_craftitem(def.itemname, {
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)
for _,source in ipairs(def.source_take) do
mcl_buckets.liquids[source] = {
source_place = def.source_place,
source_take = source,
on_take = def.on_take,
bucketname = def.bucketname,
}
pointable_sources[source] = true
if type(def.source_place) == "string" then
mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[source]
end
end
if def.bucketname == nil or def.bucketname == "" then
error(string.format("[mcl_bucket] Invalid itemname then registering [%s]!", def.name))
end
minetest.register_craftitem(def.bucketname, {
description = def.name,
_doc_items_longdesc = def.longdesc,
_doc_items_usagehelp = def.usagehelp,
@ -72,109 +178,85 @@ function mcl_buckets.register_liquid(def)
if pointed_thing.type ~= "node" then
return
end
local node = minetest.get_node(pointed_thing.under)
local place_pos = pointed_thing.under
local nn = node.name
local nodedef = minetest.registered_nodes[nn]
-- Call on_rightclick if the pointed node defines it
if user and not user:get_player_control().sneak then
if nodedef and nodedef.on_rightclick then
return nodedef.on_rightclick(place_pos, node, user, itemstack) or itemstack
end
local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing)
if new_stack then
return new_stack
end
local node_place
if type(def.source_place) == "function" then
node_place = def.source_place(place_pos)
else
node_place = def.source_place
end
-- Check if pointing to a buildable node
--local item = itemstack:get_name()
local undernode = get_node(pointed_thing.under)
local abovenode = get_node(pointed_thing.above)
local buildable1 = minetest.registered_nodes[undernode.name] and minetest.registered_nodes[undernode.name].buildable_to
local buildable2 = minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to
if not buildable1 and not buildable2 then return itemstack end --if both nodes aren't buildable_to, skip
if def.extra_check and def.extra_check(place_pos, user) == true and nodedef and nodedef.buildable_to then
-- buildable; replace the node
if buildable1 then
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()
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
end
place_liquid(place_pos, 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
-- 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
-- Handle bucket item and inventory stuff
if 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
minetest.add_item(user:get_pos(), new_bucket)
-- Place liquid
place_liquid(pointed_thing.under, node_place)
-- Update doc mod
if mod_doc and doc.entry_exists("nodes", node_place) then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place)
end
itemstack:take_item()
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()
-- Check protection
if minetest.is_protected(pointed_thing.above, pns) then
minetest.record_protection_violation(pointed_thing.above, pns)
return itemstack
end
-- Place liquid
place_liquid(pointed_thing.above, node_place)
-- Update doc mod
if mod_doc and doc.entry_exists("nodes", node_place) then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place)
end
end
return get_bucket_drop(itemstack, user, take_bucket)
else
return
return itemstack
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
-- Fail placement of liquid
if def.extra_check and def.extra_check(droppos, nil) == true and buildable then
-- buildable; replace the node
local node_place
if type(def.source_place) == "function" then
node_place = def.source_place(droppos)
else
node_place = def.source_place
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
place_liquid(droppos, node_place)
if take_bucket then
stack:set_name("mcl_buckets:bucket_empty")
end
return stack
end,
})
end
end
minetest.register_craftitem("mcl_buckets:bucket_empty", {
description = S("Empty Bucket"),
_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."),
_tt_help = S("Collects liquids"),
liquids_pointable = true,
--liquids_pointable = true,
inventory_image = "bucket.png",
stack_max = 16,
on_place = function(itemstack, user, pointed_thing)
@ -184,41 +266,51 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
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 = minetest.get_node(pointed_thing.under)
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
if liquiddef and liquiddef.itemname and (nn == liquiddef.source_take) then
local liquid_node = bucket_raycast(user)
if liquid_node then
if minetest.is_protected(liquid_node.above, user:get_player_name()) then
minetest.record_protection_violation(liquid_node.above, user:get_player_name())
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
if not minetest.is_creative_enabled(user:get_player_name()) then
new_bucket = ItemStack({name = liquiddef.itemname})
if liquiddef.on_take then
liquiddef.on_take(user)
-- 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"})
sound_take(nn, pointed_thing.under)
if mod_doc and doc.entry_exists("nodes", nn) then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", nn)
if mod_doc and doc.entry_exists("nodes", liquid_name) then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", liquid_name)
end
elseif nn == "mcl_cauldrons:cauldron_3" then
if new_bucket then
return give_bucket(new_bucket, itemstack, user)
end
else
minetest.log("error", string.format("[mcl_buckets] Node [%s] has invalid group [_mcl_bucket_pointable]!", liquid_name))
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
@ -233,25 +325,11 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
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
minetest.add_item(user:get_pos(), new_bucket)
return give_bucket(new_bucket, itemstack, user)
end
if not minetest.is_creative_enabled(user:get_player_name()) then
itemstack:take_item()
end
return itemstack
end
end
end,
_on_dispense = function(stack, pos, droppos, dropnode, dropdir)
-- 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 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
new_bucket = ItemStack({name = liquiddef.itemname})
new_bucket = ItemStack({name = liquiddef.bucketname})
sound_take(dropnode.name, droppos)
collect_liquid = true
end

View file

@ -1,6 +1,6 @@
name = mcl_buckets
author = Kahrl
description =
depends = mcl_worlds
depends = mcl_worlds, mcl_util
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 has_awards = minetest.get_modpath("awards")
local sound_place = function(itemname, pos)
local function sound_place(itemname, pos)
local def = minetest.registered_nodes[itemname]
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)
@ -34,7 +34,7 @@ if mod_mcl_core then
awards.unlock(user:get_player_name(), "mcl:hotStuff")
end
end,
itemname = "mcl_buckets:bucket_lava",
bucketname = "mcl_buckets:bucket_lava",
inventory_image = "bucket_lava.png",
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."),
@ -46,22 +46,13 @@ if mod_mcl_core then
mcl_buckets.register_liquid({
source_place = "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",
name = S("Water Bucket"),
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."),
tt_help = S("Places a water source"),
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
-- Pour water into cauldron
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"})
end
sound_place("mcl_core:water_source", pos)
return false
return false, true
-- Evaporate water if used in Nether (except on cauldron)
else
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true)
return false
return false, true
end
end
end,
@ -89,22 +80,13 @@ if mod_mclx_core then
mcl_buckets.register_liquid({
source_place = "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",
name = S("River Water Bucket"),
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."),
tt_help = S("Places a river water source"),
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
-- Pour into cauldron
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"})
end
sound_place("mcl_core:water_source", pos)
return false
return false, true
else
-- Evaporate water if used in Nether (except on cauldron)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true)
return false
return false, true
end
end
end,

View file

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

View file

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

View file

@ -152,27 +152,19 @@ 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 def._food_particles ~= false and texture and texture ~= "" then
local v = user:get_velocity() or user:get_player_velocity()
local minvel = vector.add(v, {x=-1, y=1, z=-1})
local maxvel = vector.add(v, {x=1, y=2, z=1})
minetest.add_particlespawner({
amount = math.min(math.max(8, hunger_change*2), 25),
time = 0.1,
minpos = {x=pos.x, y=pos.y, z=pos.z},
maxpos = {x=pos.x, y=pos.y, z=pos.z},
minvel = minvel,
maxvel = maxvel,
minacc = {x=0, y=-5, z=0},
maxacc = {x=0, y=-9, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 2,
for i = 0, math.min(math.max(8, hunger_change*2), 25) do
minetest.add_particle({
pos = { x = pos.x, y = pos.y, z = pos.z },
velocity = vector.add(v, { x = math.random(-1, 1), y = math.random(1, 2), z = math.random(-1, 1) }),
acceleration = { x = 0, y = math.random(-9, -5), z = 0 },
expirationtime = 1,
size = math.random(1, 2),
collisiondetection = true,
vertical = false,
texture = texture,
texture = "[combine:3x3:" .. -i .. "," .. -i .. "=" .. texture,
})
end
end
minetest.sound_play("mcl_hunger_bite", {
max_hear_distance = 12,
gain = 1.0,