ceiling clinging crystals in caves and swapping wand focus

This commit is contained in:
Evert Prants 2018-09-30 19:14:40 +03:00
parent 21f97b52f9
commit 0403167162
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
5 changed files with 104 additions and 12 deletions

View File

@ -146,6 +146,7 @@ function magicalities.register_crystal(element, description, color)
use_texture_alpha = true, use_texture_alpha = true,
mesh = "crystal.obj", mesh = "crystal.obj",
paramtype = "light", paramtype = "light",
paramtype2 = "wallmounted",
drawtype = "mesh", drawtype = "mesh",
light_source = 4, light_source = 4,
_element = element, _element = element,
@ -206,16 +207,19 @@ function magicalities.register_crystal(element, description, color)
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
}) })
-- Crystal clusters as ores -- Register cave crystal appearances
minetest.register_ore({ minetest.register_decoration({
ore_type = "scatter", deco_type = "simple",
ore = "magicalities:crystal_cluster_"..element, place_on = "default:stone",
wherein = "default:stone", sidelen = 16,
clust_scarcity = 19 * 19 * 19,
clust_num_ores = 1, y_max = -30,
clust_size = 1, y_min = -31000,
y_max = -30, flags = "all_floors, all_ceilings",
y_min = -31000,
fill_ratio = 0.0008,
decoration = "magicalities:crystal_cluster_"..element,
}) })
minetest.register_craft({ minetest.register_craft({
@ -278,3 +282,17 @@ minetest.register_abm({
end end
end end
}) })
minetest.register_on_generated(function (minp, maxp)
local clusters = minetest.find_nodes_in_area(minp, maxp, "group:crystal_cluster")
for _, pos in pairs(clusters) do
local stone = minetest.find_node_near(pos, 1, "default:stone")
if stone then
local param2 = minetest.dir_to_wallmounted(vector.direction(pos, stone))
local node = minetest.get_node(pos)
node.param2 = param2
minetest.set_node(pos, node)
end
end
end)

View File

@ -39,3 +39,77 @@ minetest.register_craftitem("magicalities:focus_teleport", {
return itemstack return itemstack
end end
}) })
minetest.register_craftitem("magicalities:focus_swap", {
description = "Wand Focus of Swapping",
groups = {wand_focus = 1},
inventory_image = "magicalities_focus_swap.png",
stack_max = 1,
_wand_requirements = {
["earth"] = 1
},
_wand_use = function (itemstack, user, pointed_thing)
local meta = itemstack:get_meta()
local tnode = meta:get_string("swapnode")
local pname = user:get_player_name()
if tnode == "" or pointed_thing.type ~= "node" then return itemstack end
local pos = pointed_thing.under
if minetest.is_protected(pos, pname) then
return itemstack
end
local node = minetest.get_node_or_nil(pos)
if not node or node.name == tnode then
return itemstack
end
local place_node_itm = ItemStack(tnode)
local inv = user:get_inventory()
local ndef = minetest.registered_nodes[tnode]
if not inv:contains_item("main", place_node_itm) then
minetest.chat_send_player(pname, ("You don't have enough %s in your inventory."):format(ndef.description))
return itemstack
end
local drops = minetest.get_node_drops(pos)
if ndef.can_dig ~= nil and not ndef.can_dig(pos, user) then
return itemstack
end
minetest.remove_node(pos)
itemstack = magicalities.wands.wand_take_contents(itemstack, {earth = 1})
magicalities.wands.update_wand_desc(itemstack)
inv:remove_item("main", place_node_itm)
for _, stk in pairs(drops) do
if inv:room_for_item("main", stk) then
inv:add_item("main", stk)
else
minetest.item_drop(ItemStack(stk), user, vector.add(pos, {x=0,y=1,z=0}))
end
end
minetest.place_node(pos, {name = tnode})
return itemstack
end,
_wand_node = function (pos, node, placer, itemstack, pointed_thing)
if not node or node.name == "air" or node.name == "ignore" then return itemstack end
local meta = itemstack:get_meta()
local tnode = meta:get_string("swapnode")
if tnode == node.name then return itemstack end
meta:set_string("swapnode", node.name)
local ndef = minetest.registered_nodes[node.name]
minetest.chat_send_player(placer:get_player_name(), "Selected replacement node " .. ndef.description)
return itemstack
end
})

View File

@ -3,10 +3,10 @@ magicalities.arcane = {}
magicalities.arcane.recipes = {} magicalities.arcane.recipes = {}
local fmspecelems = { local fmspecelems = {
["earth"] = {3, 0.15}, ["earth"] = {2.98, 0.15},
["water"] = {1, 1}, ["water"] = {1, 1},
["air"] = {5, 1}, ["air"] = {5, 1},
["fire"] = {3, 4.85}, ["fire"] = {2.98, 4.85},
["light"] = {1, 4}, ["light"] = {1, 4},
["dark"] = {5, 4} ["dark"] = {5, 4}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 34 KiB