Merge remote-tracking branch 'origin/master' into mapgen_issue

This commit is contained in:
kay27 2021-07-25 04:07:44 +04:00
commit 1d1378197b
13 changed files with 331 additions and 223 deletions

View File

@ -1,5 +1,5 @@
# MineClone 5 # MineClone 5
Version: 0.71.5 Version: 0.71.6
MineClone 5 is a fork of MineClone 2 with different workflow: MineClone 5 is a fork of MineClone 2 with different workflow:
* No Minecraft version limitation, target version is Latest Java Edition * No Minecraft version limitation, target version is Latest Java Edition

View File

@ -28,8 +28,12 @@ tt.register_snippet(function(itemstring)
end end
end end
end end
minetest.register_alias(new_id, itemstring) if new_id ~= game .. ":book_enchanted" then
if minetest.settings:get_bool("mcl_item_id_debug", true) then minetest.register_alias_force(new_id, itemstring)
end
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")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 409 B

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

@ -169,8 +169,8 @@ for _, s in pairs(stair_oxidation) do
register_oxidation_abm("Copper oxidation", "mcl_stairs:"..s[1].."_copper_"..s[2], "mcl_stairs:"..s[1].."_copper_"..s[3]) register_oxidation_abm("Copper oxidation", "mcl_stairs:"..s[1].."_copper_"..s[2], "mcl_stairs:"..s[1].."_copper_"..s[3])
end end
local axes = {"wood", "stone", "iron", "gold", "diamond"} local axes = {"wood", "stone", "iron", "gold", "diamond"}
--[[
for _, axe in pairs(axes) do for _, axe in pairs(axes) do
register_axe_override(axe) register_axe_override(axe)
end end
]]

View File

@ -1,4 +1,4 @@
name = mcl_portals name = mcl_portals
description = Adds buildable portals to the Nether and End dimensions. description = Adds buildable portals to the Nether and End dimensions.
depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn, mcl_credits
optional_depends = awards, doc optional_depends = awards, doc

View File

@ -4,6 +4,8 @@ local table = table
local vector = vector local vector = vector
local math = math local math = math
local has_doc = minetest.get_modpath("doc")
-- Parameters -- Parameters
--local SPAWN_MIN = mcl_vars.mg_end_min+70 --local SPAWN_MIN = mcl_vars.mg_end_min+70
--local SPAWN_MAX = mcl_vars.mg_end_min+98 --local SPAWN_MAX = mcl_vars.mg_end_min+98
@ -339,7 +341,7 @@ minetest.register_node("mcl_portals:end_portal_frame_eye", {
_mcl_hardness = -1, _mcl_hardness = -1,
}) })
if minetest.get_modpath("doc") then if has_doc then
doc.add_entry_alias("nodes", "mcl_portals:end_portal_frame", "nodes", "mcl_portals:end_portal_frame_eye") doc.add_entry_alias("nodes", "mcl_portals:end_portal_frame", "nodes", "mcl_portals:end_portal_frame_eye")
end end
@ -366,7 +368,7 @@ minetest.override_item("mcl_end:ender_eye", {
end end
minetest.set_node(pointed_thing.under, { name = "mcl_portals:end_portal_frame_eye", param2 = node.param2 }) minetest.set_node(pointed_thing.under, { name = "mcl_portals:end_portal_frame_eye", param2 = node.param2 })
if minetest.get_modpath("doc") then if has_doc then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:end_portal_frame") doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:end_portal_frame")
end end
minetest.sound_play( minetest.sound_play(
@ -381,7 +383,7 @@ minetest.override_item("mcl_end:ender_eye", {
-- Epic 'portal open' sound effect that can be heard everywhere -- Epic 'portal open' sound effect that can be heard everywhere
minetest.sound_play("mcl_portals_open_end_portal", {gain=0.8}, true) minetest.sound_play("mcl_portals_open_end_portal", {gain=0.8}, true)
end_portal_area(ppos) end_portal_area(ppos)
if minetest.get_modpath("doc") then if has_doc then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal_end") doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal_end")
end end
end end

View File

@ -137,19 +137,8 @@ local function find_exit(p, dx, dy, dz)
if not p or not p.y or not p.z or not p.x then return end if not p or not p.y or not p.z or not p.x then return end
local dx, dy, dz = dx or DISTANCE_MAX, dy or DISTANCE_MAX, dz or DISTANCE_MAX local dx, dy, dz = dx or DISTANCE_MAX, dy or DISTANCE_MAX, dz or DISTANCE_MAX
if dx < 1 or dy < 1 or dz < 1 then return false end if dx < 1 or dy < 1 or dz < 1 then return false end
local x, y, z = floor(p.x), floor(p.y), floor(p.z)
--y values aren't used local x1, y1, z1, x2, y2, z2 = x-dx+1, y-dy+1, z-dz+1, x+dx-1, y+dy-1, z+dz-1
local x = floor(p.x)
--local y = floor(p.y)
local z = floor(p.z)
local x1 = x-dx+1
--local y1 = y-dy+1
local z1 = z-dz+1
local x2 = x+dx-1
--local y2 = y+dy-1
local z2 = z+dz-1
local k1x, k2x = floor(x1/256), floor(x2/256) local k1x, k2x = floor(x1/256), floor(x2/256)
local k1z, k2z = floor(z1/256), floor(z2/256) local k1z, k2z = floor(z1/256), floor(z2/256)
@ -170,11 +159,27 @@ local function find_exit(p, dx, dy, dz)
end end
end end end end
if t and abs(t.x-p.x) <= dx and abs(t.y-p.y) <= dy and abs(t.z-p.z) <= dz then if t and abs(t.x-x) <= dx and abs(t.y-y) <= dy and abs(t.z-z) <= dz then
return t return t
end end
end end
-- This functon searches Nether portal nodes whitin distance specified and checks the node
local function find_exit_with_check(p, dx, dy, dz)
while true do
local pos = find_exit(p, dx, dy, dz)
if not pos then
-- not found:
return
end
if (get_node(pos).name == PORTAL) then
return pos
end
-- I don't know the reason why it can happen, but if we're here, let's log it, remove this record and try again:
log("warning", "[mcl_portals] Found faulty exit from Nether portal at " .. pos_to_string(pos) .. " - removed")
remove_exit(pos)
end
end
-- Ping-Pong the coordinate for Fast Travelling, https://git.minetest.land/Wuzzy/MineClone2/issues/795#issuecomment-11058 -- Ping-Pong the coordinate for Fast Travelling, https://git.minetest.land/Wuzzy/MineClone2/issues/795#issuecomment-11058
local function ping_pong(x, m, l1, l2) local function ping_pong(x, m, l1, l2)
@ -458,7 +463,7 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
for _, p in pairs(portals) do for _, p in pairs(portals) do
add_exit(p) add_exit(p)
end end
local exit = find_exit(pos) local exit = find_exit_with_check(pos)
if exit then if exit then
finalize_teleport(obj, exit) finalize_teleport(obj, exit)
end end
@ -676,7 +681,7 @@ local function teleport_no_delay(obj, pos)
name = obj:get_player_name() name = obj:get_player_name()
end end
local exit = find_exit(target) local exit = find_exit_with_check(target)
if exit then if exit then
finalize_teleport(obj, exit) finalize_teleport(obj, exit)
else else

View File

@ -43,6 +43,7 @@ local function remove_scope(player)
player:hud_remove(spyglass_scope[player]) player:hud_remove(spyglass_scope[player])
spyglass_scope[player] = nil spyglass_scope[player] = nil
player:hud_set_flags({wielditem = true}) player:hud_set_flags({wielditem = true})
player:set_fov(86.1)
end end
end end