Add files via upload

This commit is contained in:
Tim7900 2021-12-29 18:53:45 -09:00 committed by GitHub
parent b32f688491
commit c673632e66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 4084 additions and 0 deletions

2
mods/nether/LICENSE.txt Normal file
View File

@ -0,0 +1,2 @@
GPLv3 (lkloel's version)
MIT for the changes

15
mods/nether/README.md Normal file
View File

@ -0,0 +1,15 @@
For a description of this Minetest mod, please refer to the forum topic:
https://forum.minetest.net/viewtopic.php?f=9&t=10265
TODO:
* Find a way to get the perlin noise inside [-1; 1] or use another noise
* Add some node which containing items to the simple pyramid "buildings"
* Change the sky background, fog, etc. in the nether
* Improve the guide formspec.
Writing it in Markdown would be nice.
These could be useful:
* https://forum.minetest.net/viewtopic.php?t=23855
Minetest Bedrock Markup Language
* https://github.com/mpeterv/markdown
Markdown to HTML converter; Minetest formspecs support HTML

1
mods/nether/modpack.txt Normal file
View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,253 @@
minetest.register_craft({
output = "nether:fim",
recipe = {
{"nether:shroom_head"},
{"nether:fruit_no_leaf"},
{"nether:shroom_head"},
}
})
minetest.register_craft({
output = "nether:fruit_leaves",
recipe = {
{"nether:fruit_leaf", "nether:fruit_leaf", "nether:fruit_leaf"},
{"nether:fruit_leaf", "nether:fruit_leaf", "nether:fruit_leaf"},
{"nether:fruit_leaf", "nether:fruit_leaf", "nether:fruit_leaf"},
}
})
minetest.register_craft({
output = "nether:pick_mushroom",
recipe = {
{"nether:shroom_head", "nether:shroom_head", "nether:shroom_head"},
{"", "nether:shroom_stem", ""},
{"", "nether:shroom_stem", ""},
}
})
minetest.register_craft({
output = "nether:pick_wood",
recipe = {
{"nether:wood_cooked", "nether:wood_cooked", "nether:wood_cooked"},
{"", "group:stick", ""},
{"", "group:stick", ""},
}
})
for _,m in pairs({"netherrack", "netherrack_blue", "white"}) do
local input = "nether:"..m
minetest.register_craft({
output = "nether:pick_"..m,
recipe = {
{input, input, input},
{"", "group:stick", ""},
{"", "group:stick", ""},
}
})
minetest.register_craft({
output = "nether:axe_"..m,
recipe = {
{input, input},
{input, "group:stick"},
{"", "group:stick"},
}
})
minetest.register_craft({
output = "nether:sword_"..m,
recipe = {
{input},
{input},
{"group:stick"},
}
})
minetest.register_craft({
output = "nether:shovel_"..m,
recipe = {
{input},
{"group:stick"},
{"group:stick"},
}
})
end
minetest.register_craft({
output = "nether:netherrack_brick 4",
recipe = {
{"nether:netherrack", "nether:netherrack"},
{"nether:netherrack", "nether:netherrack"},
}
})
minetest.register_craft({
output = "nether:netherrack_brick_black 4",
recipe = {
{"nether:netherrack_black", "nether:netherrack_black"},
{"nether:netherrack_black", "nether:netherrack_black"},
}
})
minetest.register_craft({
output = "nether:netherrack_brick_blue 4",
recipe = {
{"nether:netherrack_blue", "nether:netherrack_blue"},
{"nether:netherrack_blue", "nether:netherrack_blue"},
}
})
minetest.register_craft({
output = "default:furnace",
recipe = {
{"nether:netherrack_brick", "nether:netherrack_brick", "nether:netherrack_brick"},
{"nether:netherrack_brick", "", "nether:netherrack_brick"},
{"nether:netherrack_brick", "nether:netherrack_brick", "nether:netherrack_brick"},
}
})
minetest.register_craft({
output = "nether:extractor",
recipe = {
{"nether:netherrack_brick", "nether:blood_top_cooked", "nether:netherrack_brick"},
{"nether:blood_cooked", "nether:shroom_stem", "nether:blood_cooked"},
{"nether:netherrack_brick", "nether:blood_stem_cooked", "nether:netherrack_brick"},
}
})
minetest.register_craft({
output = "nether:wood 4",
recipe = {
{"nether:blood_stem"},
}
})
minetest.register_craft({
output = "nether:wood_empty 4",
recipe = {
{"nether:blood_stem_empty"},
}
})
minetest.register_craft({
output = "nether:stick 4",
recipe = {
{"nether:wood_empty"},
}
})
minetest.register_craft({
output = "nether:torch",
recipe = {
{"nether:bark"},
{"group:stick"},
}
})
minetest.register_craft({
output = "nether:forest_wood",
recipe = {
{"nether:forest_planks", "nether:forest_planks", "nether:forest_planks"},
{"nether:forest_planks", "", "nether:forest_planks"},
{"nether:forest_planks", "nether:forest_planks", "nether:forest_planks"},
}
})
minetest.register_craft({
output = "nether:forest_planks 8",
recipe = {
{"nether:forest_wood"},
}
})
minetest.register_craft({
output = "nether:forest_planks 7",
recipe = {
{"nether:tree"},
},
})
local sound_allowed = true
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
if itemstack:get_name() ~= "nether:forest_planks"
or itemstack:get_count() ~= 7 then
return
end
local tree
for i = 1,9 do
if old_craft_grid[i]:get_name() == "nether:tree" then
tree = i
break
end
end
if not tree then -- do nth if theres no tree
return
end
local rdif = math.random(-1,1) -- add a bit randomness
local barkstack = ItemStack("nether:bark "..4-rdif)
local inv = player:get_inventory()
if not inv:room_for_item("main", barkstack) then -- disallow crafting if there's not enough free space
craft_inv:set_list("craft", old_craft_grid)
itemstack:set_name("")
return
end
itemstack:set_count(7+rdif)
inv:add_item("main", barkstack)
if not sound_allowed then -- avoid playing the sound multiple times, e.g. when middle mouse click
return
end
minetest.sound_play("default_wood_footstep", {pos=player:get_pos(), gain=0.25})
sound_allowed = false
minetest.after(0, function()
sound_allowed = true
end)
end)
minetest.register_craft({
output = "default:paper",
recipe = {
{"nether:grass_dried", "nether:grass_dried", "nether:grass_dried"},
}
})
minetest.register_craft({
type = "cooking",
output = "default:coal_lump",
recipe = "nether:tree",
})
minetest.register_craft({
type = "cooking",
output = "nether:grass_dried",
recipe = "nether:grass",
})
minetest.register_craft({
type = "cooking",
output = "nether:pearl",
recipe = "nether:fim",
})
minetest.register_craft({
type = "cooking",
output = "nether:hotbed",
recipe = "nether:blood_extracted",
})
for _,i in ipairs({"nether:blood", "nether:blood_top", "nether:blood_stem", "nether:wood"}) do
local cooked = i.."_cooked"
minetest.register_craft({
type = "cooking",
output = cooked,
recipe = i,
})
minetest.register_craft({
type = "fuel",
recipe = cooked,
burntime = 30,
})
end

View File

@ -0,0 +1,346 @@
-- minetest time speed
local time_speed = tonumber(minetest.settings:get("time_speed"))
if not time_speed then
time_speed = 1
else
time_speed = time_speed/72
end
local function get_date()
return os.date("%y %d %H %M %S")
end
-- returns the time difference in seconds
local function get_timediff(d1, d2)
local d = string.split(d1, " ")
for n,i in pairs(string.split(d2, " ")) do
d[n] = i-d[n]
end
local secs = 0
local y,d,h,m,s = unpack(d)
if s ~= 0 then
secs = secs+s
end
if m ~= 0 then
secs = secs+m*60
end
if h ~= 0 then
secs = secs+h*3600 -- 60*60
end
if d ~= 0 then
secs = secs+d*86400 -- 60*60*24
end
if y ~= 0 then
secs = secs+y*31557600 -- 60*60*24*365.25
end
--secs = math.floor(secs+0.5)
if secs < 0 then
minetest.log("action", "play warzone2100?")
end
return secs*time_speed
end
-- copied from older default furnace code and edited a bit
function nether.get_furnace_active_formspec(pos, percent)
local formspec =
"size[8,9]"..
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
(100-percent)..":default_furnace_fire_fg.png]"..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
return formspec
end
nether.furnace_inactive_formspec =
"size[8,9]"..
"image[2,2;1,1;default_furnace_fire_bg.png]"..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("nether:furnace", {
description = "Furnace",
tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", nether.furnace_inactive_formspec)
meta:set_string("infotext", "Furnace")
local inv = meta:get_inventory()
inv:set_size("fuel", 1)
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
elseif not inv:is_empty("dst") then
return false
elseif not inv:is_empty("src") then
return false
end
return true
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
meta:set_string("last_active", get_date())
local inv = meta:get_inventory()
if listname == "fuel" then
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
if inv:is_empty("src") then
meta:set_string("infotext","Furnace is empty")
end
return stack:get_count()
else
return 0
end
elseif listname == "src" then
return stack:get_count()
elseif listname == "dst" then
return 0
end
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
meta:set_string("last_active", get_date())
local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index)
if to_list == "fuel" then
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
if inv:is_empty("src") then
meta:set_string("infotext","Furnace is empty")
end
return count
else
return 0
end
elseif to_list == "src" then
return count
elseif to_list == "dst" then
return 0
end
end,
})
minetest.register_node("nether:furnace_active", {
description = "Furnace",
tiles = {
"default_furnace_top.png",
"default_furnace_bottom.png",
"default_furnace_side.png",
"default_furnace_side.png",
"default_furnace_side.png",
{
image = "default_furnace_front_active.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5
},
}
},
paramtype2 = "facedir",
light_source = 8,
drop = "nether:furnace",
groups = {cracky=2, not_in_creative_inventory=1,hot=1},
legacy_facedir_simple = true,
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", nether.furnace_inactive_formspec)
meta:set_string("infotext", "Furnace");
local inv = meta:get_inventory()
inv:set_size("fuel", 1)
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
elseif not inv:is_empty("dst") then
return false
elseif not inv:is_empty("src") then
return false
end
return true
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
meta:set_string("last_active", get_date())
local inv = meta:get_inventory()
if listname == "fuel" then
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
if inv:is_empty("src") then
meta:set_string("infotext","Furnace is empty")
end
return stack:get_count()
else
return 0
end
elseif listname == "src" then
return stack:get_count()
elseif listname == "dst" then
return 0
end
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
meta:set_string("last_active", get_date())
local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index)
if to_list == "fuel" then
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
if inv:is_empty("src") then
meta:set_string("infotext","Furnace is empty")
end
return count
else
return 0
end
elseif to_list == "src" then
return count
elseif to_list == "dst" then
return 0
end
end,
})
local function swap_node(pos,name)
local node = minetest.get_node(pos)
if node.name == name then
return
end
node.name = name
minetest.swap_node(pos,node)
end
minetest.register_abm({
nodenames = {"nether:furnace","nether:furnace_active"},
interval = 1.0,
chance = 1,
action = function(pos)
local meta = minetest.get_meta(pos)
if meta:get_string("timedif") == "" then
meta:set_float("timedif", 0.0)
end
-- lag shouldn't control the furnace speed
local current_time = get_date()
local last_time = meta:get_string("last_active")
if last_time == "" then
meta:set_string("last_active", current_time)
return
end
if last_time == current_time then
return
end
local timediff = get_timediff(last_time, current_time)+meta:get_string("timedif")
local times = math.floor(timediff)
meta:set_string("last_active", current_time)
meta:set_float("timedif", timediff-times)
for _ = 1,times do
for _,name in pairs({
"fuel_totaltime",
"fuel_time",
"src_totaltime",
"src_time",
}) do
if meta:get_string(name) == "" then
meta:set_float(name, 0.0)
end
end
local inv = meta:get_inventory()
local srclist = inv:get_list("src")
local cooked = nil
local aftercooked
if srclist then
cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
end
local was_active = false
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
was_active = true
meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
meta:set_float("src_time", meta:get_float("src_time") + 1)
if cooked
and cooked.item
and meta:get_float("src_time") >= cooked.time then
-- check if there's room for output in "dst" list
if inv:room_for_item("dst",cooked.item) then
-- Put result in "dst" list
inv:add_item("dst", cooked.item)
-- take stuff from "src" list
inv:set_stack("src", 1, aftercooked.items[1])
--~ else
--print("Could not insert '"..cooked.item:to_string().."'")
end
meta:set_string("src_time", 0)
end
end
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext","Furnace active: "..percent.."%")
swap_node(pos,"nether:furnace_active")
meta:set_string("formspec",nether.get_furnace_active_formspec(pos, percent))
return
end
local fuel = nil
local afterfuel
local cooked = nil
local fuellist = inv:get_list("fuel")
local srclist = inv:get_list("src")
if srclist then
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
end
if fuellist then
fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
end
if not fuel or fuel.time <= 0 then
meta:set_string("infotext","Furnace out of fuel")
swap_node(pos,"nether:furnace")
meta:set_string("formspec", nether.furnace_inactive_formspec)
return
end
if cooked.item:is_empty() then
if was_active then
meta:set_string("infotext","Furnace is empty")
swap_node(pos,"nether:furnace")
meta:set_string("formspec", nether.furnace_inactive_formspec)
end
return
end
meta:set_string("fuel_totaltime", fuel.time)
meta:set_string("fuel_time", 0)
inv:set_stack("fuel", 1, afterfuel.items[1])
end
end,
})

View File

@ -0,0 +1,411 @@
local cube = minetest.inventorycube
-- the content of the guide
local guide_infos = {
{
description = "Mushrooms",
{"text", "Nether mushrooms can be found on the nether's ground and\n"..
"on netherrack soil, it can be dug by hand."},
{"image", {1, 1, "riesenpilz_nether_shroom_side.png"}},
{"y", 0.2},
{"text", "If you drop it without holding the fast key, you can split it into its stem and head:"},
{"image", {1, 1, "nether_shroom_top.png", 1}},
{"image", {1, 1, "nether_shroom_stem.png"}},
{"y", 0.1},
{"text", "You can get more mushrooms by using a netherrack soil:\n"..
"1. search a dark place and, if necessary, place netherrack with air about it\n"..
"2. right click with cooked blood onto the netherrack to make it soiled\n"..
"3. right click onto the netherrack soil with a nether mushroom head to add some spores\n"..
"4. dig the mushroom which grew after some time to make place for another one"},
{"image", {1, 1, "riesenpilz_nether_shroom_side.png", 6, 0.12}},
{"y", 1},
{"image", {1, 1, "nether_netherrack.png^nether_netherrack_soil.png", 1.8}},
{"image", {1, 1, "nether_hotbed.png", 1.3, -0.4}},
{"image", {1, 1, "nether_netherrack.png^nether_netherrack_soil.png", 3.6}},
{"image", {1, 1, "nether_shroom_top.png", 3.1, -0.5}},
{"image", {1, 1, "nether_netherrack.png^nether_netherrack_soil.png", 6}},
{"image", {1, 1, "nether_netherrack.png"}},
},
{
description = "Tools",
{"text", "You can craft 5 kinds of tools in the nether,\n"..
"which (except the mushroom pick) require sticks to be crafted:"},
{"image", {1, 1, "nether_pick_mushroom.png"}},
{"y", 0.1},
{"text", "strength : 1\n"..
"The mushroom pick needs mushroom stems and heads to be crafted."},
{"image", {1, 1, "nether_pick_wood.png"}},
{"y", 0.1},
{"text", "strength : 2\n"..
"The nether wood pick can be crafted with cooked nether blood wood."},
{"image", {1, 1, "nether_axe_netherrack.png", 1.5}},
{"image", {1, 1, "nether_shovel_netherrack.png", 3}},
{"image", {1, 1, "nether_sword_netherrack.png", 4.5}},
{"image", {1, 1, "nether_pick_netherrack.png"}},
{"y", 0.1},
{"text", "strength : 3\n"..
"The red netherrack tools can be crafted with usual netherrack."},
{"image", {1, 1, "nether_axe_netherrack_blue.png", 1.5}},
{"image", {1, 1, "nether_shovel_netherrack_blue.png", 3}},
{"image", {1, 1, "nether_sword_netherrack_blue.png", 4.5}},
{"image", {1, 1, "nether_pick_netherrack_blue.png"}},
{"y", 0.1},
{"text", "strength : 3\n"..
"The blue netherrack tools can be crafted with blue netherrack."},
{"image", {1, 1, "nether_axe_white.png", 1.5}},
{"image", {1, 1, "nether_shovel_white.png", 3}},
{"image", {1, 1, "nether_sword_white.png", 4.5}},
{"image", {1, 1, "nether_pick_white.png"}},
{"y", 0.1},
{"text", "strength : 3\n"..
"The siwtonic tools can be crafted with the siwtonic ore."},
},
{
description = "Blood structures",
{"text", "You can find blood structures on the ground and\n"..
"dig their nodes even with the bare hand."},
{"y", 0.5},
{"text", "One contains 4 kinds of blocks :"},
{"image", {1, 1, cube("nether_blood.png"), 1}},
{"image", {1, 1,
cube("nether_blood_top.png",
"nether_blood.png^nether_blood_side.png",
"nether_blood.png^nether_blood_side.png"),
2}},
{"image", {1, 1, "nether_fruit.png", 3}},
{"image", {1, 1, cube("nether_blood_stem_top.png",
"nether_blood_stem.png", "nether_blood_stem.png")}},
{"y", 0.1},
{"text", "Blood stem, blood, blood head and nether fruit"},
{"y", 0.1},
{"text", "You can craft 4 blood wood with the stem :"},
{"image", {1, 1, cube("nether_wood.png")}},
{"y", 0.1},
{"text", "The 4 blood nodes can be cooked and, except\n"..
"blood wood, their blood can be extracted."},
},
{
description = "Fruits",
{"text", "You can find the nether fruits on blood structures\n"..
"and dig them even with the bare hand."},
{"image", {1, 1, "nether_fruit.png"}},
{"text", "Eating it will make you lose life but\n"..
"it might feed you and give you blood :"},
{"image", {1, 1, "nether_blood_extracted.png"}},
{"y", 0.2},
{"text", "If you eat it at the right place inside a portal,\n"..
"you will teleport instead of getting blood."},
{"y", 0.2},
{"text", "If you drop it without holding the fast key,\n"..
"you can split it into its fruit and leaf:"},
{"image", {1, 1, "nether_fruit_leaf.png", 1}},
{"image", {1, 1, "nether_fruit_no_leaf.png"}},
{"y", 0.2},
{"text", "Craft a fruit leave block out of 9 fruit leaves\n"..
"The fruit can be used to craft a nether pearl."},
{"image", {1, 1, cube("nether_fruit_leaves.png")}},
{"y", 0.2},
{"text", "A fruit leaves block"},
},
{
description = "Cooking",
{"text", "To get a furnace you need to dig at least 8 netherrack bricks.\n"..
"They can be found at pyramid like constructions and require at least\n"..
"a strength 1 nether pick to be dug.\n"..
"To craft the furnace, use the netherrack bricks like cobble:"},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png"), 0.5}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png"), 1}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png")}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png"), 1}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png")}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png"), 0.5}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png"), 1}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png")}},
{"y", 0.2},
{"text", "To begin cooking stuff, you can use a mushroom or fruit.\n"..
"After that it's recommended to use cooked blood nodes."},
{"y", 0.1},
{"text", "Some nether items can be cooked:"},
{"image", {1, 1, cube("nether_blood_stem_top_cooked.png",
"nether_blood_stem_cooked.png", "nether_blood_stem_cooked.png"),
0.35}},
{"image", {1, 1, cube("nether_blood_cooked.png"), 1.6}},
{"image", {1, 1,
cube("nether_blood_top_cooked.png",
"nether_blood_cooked.png^nether_blood_side_cooked.png",
"nether_blood_cooked.png^nether_blood_side_cooked.png"),
2.9}},
{"image", {1, 1, cube("nether_wood_cooked.png"), 4.3}},
{"y", 1.2},
{"text", "Some cooked blood stem, cooked blood,\n"..
"cooked blood head and cooked blood wood,"},
{"image", {1, 1, "nether_hotbed.png", 0.3}},
{"image", {1, 1, "nether_pearl.png", 2}},
{"y", 1.2},
{"text", "Some cooked extracted blood and a nether pearl"},
},
{
description = "Extractors",
{"text", "Here you can find out information about the nether extractor."},
{"y", 0.2},
{"text", "Here you can see its craft recipe:"},
{"image", {0.5, 0.5, cube("nether_blood_top_cooked.png",
"nether_blood_cooked.png^nether_blood_side_cooked.png",
"nether_blood_cooked.png^nether_blood_side_cooked.png"), 0.5}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png"), 1}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png")}},
{"image", {0.5, 0.5, cube("nether_blood_extractor.png"), 2.5}},
{"image", {0.5, 0.5, "nether_shroom_stem.png", 0.5}},
{"image", {0.5, 0.5, cube("nether_blood_cooked.png"), 1}},
{"image", {0.5, 0.5, cube("nether_blood_cooked.png")}},
{"image", {0.5, 0.5, cube("nether_blood_stem_top_cooked.png",
"nether_blood_stem_cooked.png", "nether_blood_stem_cooked.png"),
0.5}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png"), 1}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png")}},
{"y", 0.2},
{"text", "Extract blood from the blood nodes you get from the blood structures.\n"..
"You can also get blood with a nether fruit."},
{"y", 0.2},
{"text", "So you can use it:\n"..
"1. place it somewhere\n"..
"2. place blood blocks next to it (4 or less)\n"..
"3. right click with extracted blood onto it to power it\n"..
"4. take the new extracted blood and dig the extracted nodes"},
{"y", 0.2},
{"text", "Example (view from the top):"},
{"y", 0.88},
{"image", {1, 1, "nether_blood_stem_top.png", 0.82, -0.88}},
{"image", {1, 1, "nether_blood.png", 1.63}},
{"image", {1, 1, "nether_blood_extractor.png", 0.82}},
{"image", {1, 1, "nether_blood_stem_top_empty.png", 3.82, -0.88}},
{"image", {1, 1, "nether_blood_empty.png", 4.63}},
{"image", {1, 1, "nether_blood_empty.png", 3.001}},
{"image", {1, 1, "nether_blood_extractor.png", 3.82}},
{"image", {1, 1, "nether_blood.png"}},
{"image", {1, 1, "nether_blood.png", 0.82, -0.12}},
{"image", {1, 1, "nether_blood_empty.png", 3.82, -0.12}},
{"y", 1.2},
{"text", "The empty blood stem can be crafted into empty nether wood,\n"..
"which can be crafted into nether sticks."},
},
{
description = "Ores",
{"text", "You can find 5 types of ores:"},
{"image", {1, 1, cube("nether_netherrack_black.png"), 4}},
{"image", {1, 1, cube("nether_netherrack.png")}},
{"y", 0.2},
{"text", "The red netherrack is generated like stone.\n"..
"The black netherrack is generated like gravel.\n"..
"Both require at least a strength 2 nether pick to be dug."},
{"image", {1, 1, cube("nether_white.png"), 4}},
{"image", {1, 1, cube("nether_netherrack_blue.png")}},
{"y", 0.2},
{"text", "The blue netherrack is generated like diamond ore.\n"..
"The siwtonic ore is generated like mese blocks.\n"..
"Both require at least a strength 3 nether pick to be dug."},
{"image", {1, 1, cube("nether_netherrack_tiled.png"), 4}},
{"image", {1, 1, cube("glow_stone.png")}},
{"y", 0.2},
{"text", "Glow stone can be used for lighting.\n"..
"Tiled netherrack is generated like coal ore.\n"..
"Glow stone requires at least a strength 1 pick to be dug.\n"..
"Dig tiled netherrack with at least a level 2 pickaxe."},
},
{
description = "Vines",
{"text", "Feed nether vines with blood.\n"..
"Dig them with anything."},
{"image", {1, 1, "nether_vine.png"}},
{"y", 0.2},
{"text", "Grow nether child by placing\n"..
"placing it to a dark place onto a\n"..
"blood structure head node."},
{"image", {1, 1, "nether_sapling.png"}},
{"y", -0.10},
{"image", {1, 1, "nether_blood.png^nether_blood_side.png"}},
},
{
description = "Pearls",
{"text", "The nether pearl can be used to teleport by throwing it.\n"..
"Here is how to get one :"},
{"y", 0.2},
{"text", "First of all craft 2 mushroom heads and 1 nether fruit\n"..
"without leaf together :"},
{"image", {1, 1, "nether_shroom_top.png"}},
{"image", {1, 1, "nether_fim.png", 3}},
{"image", {1, 1, "nether_fruit_no_leaf.png"}},
{"image", {1, 1, "nether_shroom_top.png"}},
{"y", 0.2},
{"text", "Put the result into the furnace\n"..
"to cook it into a nether pearl :"},
{"image", {1, 1, "nether_pearl.png"}},
},
{
description = "Bricks",
{"text", "Craft bricks out of red,\n"..
"black and blue netherrack."},
{"image", {1, 1, cube("nether_netherrack_brick_black.png"), 1}},
{"image", {1, 1, cube("nether_netherrack_brick_blue.png"), 2}},
{"image", {1, 1, cube("nether_netherrack_brick.png")}},
{"y", 0.4},
{"text", "Dig them with at least a level 1 pickaxe."},
{"y", 0.2},
},
{
description = "Portals",
{"text", "Here you can find out how to built the nether portal."},
{"y", 0.3},
{"text", "A nether portal requires following nodes:"},
{"y", 0.05},
{"text", "25 empty nether wooden planks\n"..
"16 black netherrack\n"..
"12 blue netherrack bricks\n"..
"8 red netherrack\n"..
"8 cooked nether blood\n"..
"4 nether fruits\n"..
"2 siwtonic blocks"},
{"y", 0.2},
{"text", "It should look approximately like this one:"},
{"image", {5.625, 6, "nether_teleporter.png", 0, -1.5}},
{"y", 5.5},
{"text", "Activate it by standing in the middle,\n"..
"on the siwtonic block and eating a nether fruit.\n"..
"Take enough stuff with you to build a portal when you'll come back."},
},
{
description = "Forests",
{"text", "The nether forest is generated in caves,\n"..
"above the usual nether."},
{"y", 0.2},
{"text", "There you can find some plants:"},
{"image", {1, 1, "nether_grass_middle.png", 1}},
{"image", {1, 1, "nether_grass_big.png", 2}},
{"image", {1, 1, "nether_grass_small.png"}},
{"y", 0.2},
{"text", "Use the nether forest grass to get paper.\n"..
"Craft paper out of the dried grass."},
{"image", {1, 1, cube("nether_tree_top.png", "nether_tree.png", "nether_tree.png")}},
{"y", 0.2},
{"text", "Nether trunks can be found at nether trees.\n"..
"Craft nether wood out of nether trunk."},
{"image", {1, 1, "nether_glowflower.png"}},
{"y", 0.2},
{"text", "Use it for lighting and decoration."},
},
}
-- the size of guide pages
local guide_size = {x=40, y=10, cx=0.2, cy=0.2}
-- informations about settings and ...
local formspec_offset = {x=0.25, y=0.50}
local font_size
if minetest.is_singleplayer() then
font_size = tonumber(minetest.settings:get("font_size")) or 13
else
font_size = 13
end
guide_size.fx = math.floor((40*(guide_size.cx+formspec_offset.x))*font_size)
guide_size.fy = font_size/40
-- the default guide formspecs
local guide_forms = {
contents = "size[3.6,"..(#guide_infos)-2 ..";]label["..guide_size.cx+0.7 ..","..guide_size.cy+0.2 ..";Contents:]",
}
-- change the infos to formspecs
for n,data in ipairs(guide_infos) do
local form = ""
local y = 0
local x = guide_size.cx
for _,i in ipairs(data) do
local typ, content = unpack(i)
if typ == "y" then
y = y+content
elseif typ == "x" then
x = math.max(x, content)
elseif typ == "text" then
local tab = minetest.wrap_text(content, guide_size.fx, true)
local l = guide_size.cx
for _,str in ipairs(tab) do
form = form.."label["..guide_size.cx ..","..guide_size.cy+y..";"..str.."]"
y = y+guide_size.fy
l = math.max(l, #str)
end
x = math.max(x, l/font_size)
elseif typ == "image" then
local w, h, texture_name, px, py = unpack(content)
if not px then
form = form.."image["..guide_size.cx..","..guide_size.cy+y+h*0.3 ..";"..w..","..h..";"..texture_name.."]"
y = y+h
else
px = guide_size.cx+px
py = py or 0
form = form.."image["..px..","..
guide_size.cy+y+h*0.3+py ..";"..w..","..h..";"..texture_name.."]"
x = math.max(x, px+w)
end
end
end
form = "size["..x*1.8 ..","..y+1 ..";]"..form.."button["..x/2-0.5 ..","..y ..";1,2;quit;Back]"
guide_forms[n] = {data.description, form}
end
local desc_tab = {}
for n,i in ipairs(guide_forms) do
desc_tab[i[1]] = n
end
-- creates contents formspec
for y,i in ipairs(guide_forms) do
local desc = i[1]
local s = #desc * 1.3 / font_size + 1.5
guide_forms.contents = guide_forms.contents ..
"button[" .. guide_size.cx * 12 / s - 0.5 .. "," ..
guide_size.cy + y / 1.3 .. ";" .. s .. ",1;name;" .. desc .. "]"
end
-- shows the contents of the formspec
local function show_guide(pname)
minetest.show_formspec(pname, "nether_guide_contents", guide_forms["contents"])
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname == "nether_guide_contents" then
local fname = fields.name
local pname = player:get_player_name()
if fname
and pname then
minetest.show_formspec(pname, "nether_guide", guide_forms[desc_tab[fname]][2])
end
elseif formname == "nether_guide" then
local fname = fields.quit
local pname = player:get_player_name()
if fname
and pname then
minetest.show_formspec(pname, "nether_guide_contents", guide_forms["contents"])
end
end
end)
minetest.register_chatcommand("nether_help", {
params = "",
description = "Shows a nether guide",
func = function(name)
local player = minetest.get_player_by_name(name)
if not player then
minetest.chat_send_player(name, "Something went wrong.")
return false
end
if player:get_pos().y > nether.start then
minetest.chat_send_player(name,
"Usually you don't neet this guide here. " ..
"You can view it in the nether.")
return false
end
minetest.chat_send_player(name, "Showing guide...")
show_guide(name)
return true
end
})

1046
mods/nether/nether/init.lua Normal file

File diff suppressed because it is too large Load Diff

1030
mods/nether/nether/items.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
name = nether
depends = default,glow,riesenpilz,stairs,vector_extras
optional_depends = creative,fence_registration,function_delayer,watershed

View File

@ -0,0 +1,190 @@
local function throw_pearl(item, player)
local playerpos = player:get_pos()
playerpos.y = playerpos.y+1.625
local obj = minetest.add_entity(playerpos, "nether:pearl_entity")
local dir = player:get_look_dir()
obj:setvelocity(vector.multiply(dir, 30))
obj:setacceleration({x=dir.x*-3, y=-dir.y^8*80-10, z=dir.z*-3})
local pname = player:get_player_name()
obj:get_luaentity().player = pname
if not minetest.is_creative_enabled(pname) then
item:take_item()
return item
end
end
local function get_node(pos)
local name = minetest.get_node(pos).name
if name ~= "ignore" then
return name
end
minetest.get_voxel_manip():read_from_map(pos, pos)
name = minetest.get_node_or_nil(pos)
if not name then
return
end
return name.name
end
local softs = {}
local function is_soft(pos)
local name = get_node(pos)
if not name then
return false
end
local is_soft = softs[name]
if is_soft ~= nil then
return is_soft
end
if not minetest.registered_nodes[name] then
softs[name] = false
return false
end
is_soft = minetest.registered_nodes[name].walkable == false
softs[name] = is_soft
return is_soft
end
-- teleports the player there if there's free space
local function teleport_player(pos, player)
if not is_soft(pos) then
return false
end
if not is_soft({x=pos.x, y=pos.y+1, z=pos.z})
and not is_soft({x=pos.x, y=pos.y-1, z=pos.z}) then
return false
end
pos.y = pos.y+0.05
player:moveto(pos)
return true
end
--[[
local dg_ps = {}
local function forceload(pos)
dg_ps[#dg_ps+1] = pos
minetest.forceload_block(pos)
minetest.after(5, function(pos)
minetest.forceload_free_block(pos)
for i,p in pairs(dg_ps) do
if vector.equals(p, pos) then
dg_ps[i] = nil
return
end
end
end, pos)
end
minetest.register_on_shutdown(function()
for _,p in pairs(dg_ps) do
minetest.forceload_free_block(p)
end
end)--]]
minetest.register_entity("nether:pearl_entity", {
collisionbox = {0,0,0,0,0,0}, --not pointable
visual_size = {x=0.1, y=0.1},
physical = false, -- Collides with things
textures = {"nether_pearl.png"},
on_activate = function(self, staticdata)
if not staticdata
or staticdata == "" then
return
end
local tmp = minetest.deserialize(staticdata)
if not tmp then
minetest.log("error", "[nether] pearl: invalid staticdata ")
return
end
self.player = tmp.player
end,
get_staticdata = function(self)
--forceload(vector.round(self.object:get_pos()))
return minetest.serialize({
player = self.player,
})
end,
timer = 0,
on_step = function(self, dtime)
self.timer = self.timer+dtime
--[[
local delay = self.delay
if delay < 0.1 then
self.delay = delay+dtime
return
end
self.delay = 0--]]
if self.timer > 20 then
self.object:remove()
return
end
local pos = self.object:get_pos()
local rpos = vector.round(pos)
local lastpos = self.lastpos
if not lastpos then
self.lastpos = vector.new(rpos)
return
end
if lastpos.x
and vector.equals(vector.round(lastpos), rpos) then
return
end
local player = self.player
if not player then
minetest.log("error", "[nether] pearl: missing playername")
self.object:remove()
return
end
player = minetest.get_player_by_name(player)
if not player then
minetest.log("error", "[nether] pearl: missing player")
self.object:remove()
return
end
if not get_node(rpos) then
minetest.log("error", "[nether] pearl: missing node")
self.object:remove()
return
end
self.lastpos = vector.new(pos)
local free, p = minetest.line_of_sight(lastpos, pos)
if free then
return
end
if is_soft(p) then
return
end
self.object:remove()
minetest.after(0, function(p) --minetest.after is used that the sound is played after the teleportation
minetest.sound_play("nether_pearl", {pos=p, max_hear_distance=10})
end, p)
p.y = p.y+1
if teleport_player(vector.new(p), player) then
return
end
p.y = p.y-2
for i = -1,1,2 do
for _,j in pairs({{i, 0}, {0, i}}) do
if teleport_player({x=p.x+j[1], y=p.y, z=p.z+j[2]}, player) then
return
end
end
end
for i = -1,1,2 do
for j = -1,1,2 do
if teleport_player({x=p.x+j, y=p.y, z=p.z+i}, player) then
return
end
end
end
end
})
minetest.override_item("nether:pearl", {on_use = throw_pearl})

View File

@ -0,0 +1,697 @@
--code copied from Pilzadam's nether mod and edited
-- kills the player if he uses PilzAdam portal
local portal_target = nether.buildings+1
local nether_prisons = minetest.settings:get_bool("enable_damage")
local obsidian_portal_kills = nether_prisons and true
local mclike_portal = false
local abm_allowed
minetest.after(5, function()
abm_allowed = true
end)
local save_path = minetest.get_worldpath() .. "/nether_players"
local players_in_nether = {}
-- only get info from file if nether prisons
if nether_prisons then
local file = io.open(save_path, "r")
if not file then
return
end
local contents = file:read"*all"
io.close(file)
if not contents then
return
end
local playernames = string.split(contents, " ")
for i = 1,#playernames do
players_in_nether[playernames[i]] = true
end
end
local function save_nether_players()
local playernames,n = {},1
for name in pairs(players_in_nether) do
playernames[n] = name
n = n+1
end
local f = io.open(save_path, "w")
assert(f, "Could not open nether_players file for writing.")
f:write(table.concat(playernames, " "))
io.close(f)
end
local update_background
if nether_prisons then
function update_background(player, down)
if down then
player:set_sky({r=15, g=0, b=0}, "plain")
else
player:set_sky(nil, "regular")
end
end
else
function update_background()end
end
-- returns nodename if area is generated, else calls generation function
local function generated_or_generate(pos)
local node = minetest.get_node_or_nil(pos)
if node then
return node.name
end
minetest.get_voxel_manip():read_from_map(pos, pos)
node = minetest.get_node_or_nil(pos)
if not node then
minetest.emerge_area(vector.subtract(pos, 80), vector.add(pos, 80))
return false
end
return node.name
end
-- where the player appears after dying
local function get_player_died_target(player)
local target = vector.add(player:get_pos(),
{x=math.random(-100,100), y=0, z=math.random(-100,100)})
target.y = portal_target + math.random(4)
return target
end
-- used for obsidian portal
local function obsidian_teleport(player, pname, target)
minetest.chat_send_player(pname, "For any reason you arrived here. Type " ..
"/nether_help to find out things like craft recipes.")
players_in_nether[pname] = true
save_nether_players()
update_background(player, true)
if target then
player:set_pos(target)
else
player:set_hp(0)
end
end
-- teleports players to nether or helps it
local function player_to_nether(player, pos)
local pname = player:get_player_name()
if players_in_nether[pname] then
return
end
players_in_nether[pname] = true
save_nether_players()
update_background(player, true)
if pos then
player:set_pos(pos)
return
end
minetest.chat_send_player(pname, "For any reason you arrived here. " ..
"Type /nether_help to find out things like craft recipes.")
player:set_hp(0)
if not nether_prisons then
player:set_pos(get_player_died_target(player))
end
end
local function player_from_nether(player, pos)
local pname = player:get_player_name()
if players_in_nether[pname] then
players_in_nether[pname] = nil
save_nether_players()
end
update_background(player)
player:set_pos(pos)
end
local function player_exists(name)
local players = minetest.get_connected_players()
for i = 1,#players do
if players[i]:get_player_name() == name then
return true
end
end
return false
end
-- Chatcommands (edited) written by sss
minetest.register_chatcommand("to_hell", {
params = "[<player_name>]",
description = "Send someone to hell",
func = function(name, pname)
if not minetest.check_player_privs(name, {nether=true}) then
return false,
"You need the nether privilege to execute this chatcommand."
end
if not player_exists(pname) then
pname = name
end
local player = minetest.get_player_by_name(pname)
if not player then
return false, "Something went wrong."
end
minetest.chat_send_player(pname, "Go to hell !!!")
player_to_nether(player)
return true, pname.." is now in the nether."
end
})
minetest.register_chatcommand("from_hell", {
params = "[<player_name>]",
description = "Extract from hell",
func = function(name, pname)
if not minetest.check_player_privs(name, {nether=true}) then
return false,
"You need the nether priv to execute this chatcommand."
end
if not player_exists(pname) then
pname = name
end
local player = minetest.get_player_by_name(pname)
if not player then
return false, "Something went wrong."
end
minetest.chat_send_player(pname, "You are free now")
local pos = player:get_pos()
player_from_nether(player, {x=pos.x, y=100, z=pos.z})
return true, pname.." is now out of the nether."
end
})
if nether_prisons then
-- randomly set player position when he/she dies in nether
minetest.register_on_respawnplayer(function(player)
local pname = player:get_player_name()
if not players_in_nether[pname] then
return
end
local target = get_player_died_target(player)
player:set_pos(target)
minetest.after(0, function(pname, target)
-- fixes respawn bug
local player = minetest.get_player_by_name(pname)
if player then
player:moveto(target)
end
end, pname, target)
return true
end)
-- override set_pos etc. to disallow player teleportion by e.g. travelnet
local function can_teleport(player, pos)
if not player:is_player() then
-- the same metatable is used for entities
return true
end
local pname = player:get_player_name()
local in_nether = players_in_nether[pname] == true
-- test if the target is valid
if pos.y < nether.start then
if in_nether then
return true
end
elseif not in_nether then
return true
end
-- test if the current position is valid
local current_pos = player:get_pos()
local now_in_nether = current_pos.y < nether.start
if now_in_nether ~= in_nether then
if in_nether then
minetest.log("action", "Player \"" .. pname ..
"\" has to be in the nether, teleporting it!")
update_background(player, true)
current_pos.y = portal_target
player:set_pos(current_pos)
else
minetest.log("action", "Player \"" .. pname ..
"\" must not be in the nether, teleporting it!")
update_background(player)
current_pos.y = 20
player:set_pos(current_pos)
end
return false
end
minetest.chat_send_player(pname,
"You can not simply teleport to or from the nether!")
minetest.log("action", "Player \"" .. pname ..
"\" attempted to teleport from or to the nether, ignoring.")
return false
end
local methods = {"set_pos", "move_to", "setpos", "moveto"}
local metatable_overridden
minetest.register_on_joinplayer(function(player)
-- set the background when the player joins
if player:get_pos().y < nether.start then
update_background(player, true)
end
-- overide set_pos etc. if not yet done
if metatable_overridden then
return
end
metatable_overridden = true
local mt = getmetatable(player)
for i = 1,#methods do
local methodname = methods[i]
local origfunc = mt[methodname]
mt[methodname] = function(...)
if can_teleport(...) then
origfunc(...)
end
end
end
end)
else
-- test if player is in nether when he/she joins
minetest.register_on_joinplayer(function(player)
players_in_nether[player:get_player_name()] =
player:get_pos().y < nether.start or nil
end)
end
-- removes the violet stuff from the obsidian portal
local function remove_portal_essence(pos)
for z = -1,1 do
for y = -2,2 do
for x = -1,1 do
local p = {x=pos.x+x, y=pos.y+y, z=pos.z+z}
if minetest.get_node(p).name == "nether:portal" then
minetest.remove_node(p)
end
end
end
end
end
-- change parts of the particledefinition instead of recreating it every time
local particledef = {
amount = 32,
time = 4,
minvel = {x=0, y=1, z=0},
maxvel = {x=0, y=2, z=0},
minacc = {x=-0.5,y=-3,z=-0.3},
maxacc = {x=0.5,y=-0.4,z=0.3},
minexptime = 1,
maxexptime = 1,
minsize = 0.4,
maxsize = 3,
collisiondetection = true,
}
-- teleports player to neter (obsidian portal)
local function obsi_teleport_player(player, pos, target)
local pname = player:get_player_name()
if players_in_nether[pname] then
return
end
local objpos = player:get_pos()
objpos.y = objpos.y+0.1 -- Fix some glitches at -8000
if minetest.get_node(vector.round(objpos)).name ~= "nether:portal" then
return
end
local has_teleported
if obsidian_portal_kills then
obsidian_teleport(player, pname)
has_teleported = true
elseif not mclike_portal then
local target = vector.round(get_player_died_target(player))
if generated_or_generate(target) then
obsidian_teleport(player, pname, target)
has_teleported = true
end
end
if not has_teleported then
-- e.g. ungenerated area
return
end
remove_portal_essence(pos)
minetest.sound_play("nether_portal_usual", {to_player=pname, gain=1})
end
-- abm for particles of the obsidian portal essence and for teleporting
minetest.register_abm({
nodenames = {"nether:portal"},
interval = 1,
chance = 2,
catch_up = false,
action = function(pos, node)
if not abm_allowed then
return
end
particledef.minpos = {x=pos.x-0.25, y=pos.y-0.5, z=pos.z-0.25}
particledef.maxpos = {x=pos.x+0.25, y=pos.y+0.34, z=pos.z+0.25}
particledef.texture = "nether_portal_particle.png^[transform" ..
math.random(0, 7)
minetest.add_particlespawner(particledef)
for _,obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do
if obj:is_player() then
local meta = minetest.get_meta(pos)
local target = minetest.string_to_pos(meta:get_string("target"))
if target then
minetest.after(3, obsi_teleport_player, obj, pos, target)
end
end
end
end,
})
local function move_check(p1, max, dir)
local p = {x=p1.x, y=p1.y, z=p1.z}
local d = math.abs(max-p1[dir]) / (max-p1[dir])
while p[dir] ~= max do
p[dir] = p[dir] + d
if minetest.get_node(p).name ~= "default:obsidian" then
return false
end
end
return true
end
local function check_portal(p1, p2)
if p1.x ~= p2.x then
if not move_check(p1, p2.x, "x") then
return false
end
if not move_check(p2, p1.x, "x") then
return false
end
elseif p1.z ~= p2.z then
if not move_check(p1, p2.z, "z") then
return false
end
if not move_check(p2, p1.z, "z") then
return false
end
else
return false
end
if not move_check(p1, p2.y, "y") then
return false
end
if not move_check(p2, p1.y, "y") then
return false
end
return true
end
-- tests if it's an obsidian portal
local function is_portal(pos)
for d=-3,3 do
for y=-4,4 do
local px = {x=pos.x+d, y=pos.y+y, z=pos.z}
local pz = {x=pos.x, y=pos.y+y, z=pos.z+d}
if check_portal(px, {x=px.x+3, y=px.y+4, z=px.z}) then
return px, {x=px.x+3, y=px.y+4, z=px.z}
end
if check_portal(pz, {x=pz.x, y=pz.y+4, z=pz.z+3}) then
return pz, {x=pz.x, y=pz.y+4, z=pz.z+3}
end
end
end
end
-- put here the function for creating a second portal
local create_second_portal
if mclike_portal then
function create_second_portal(target)
-- change target here
end
end
-- adds the violet portal essence
local function make_portal(pos)
local p1, p2 = is_portal(pos)
if not p1
or not p2 then
print("[nether] something failed.")
return false
end
local in_nether = p1.y < nether.start
if in_nether
and not mclike_portal then
print("[nether] aborted, obsidian portals can't be used to get out")
return
end
for d=1,2 do
for y=p1.y+1,p2.y-1 do
local p
if p1.z == p2.z then
p = {x=p1.x+d, y=y, z=p1.z}
else
p = {x=p1.x, y=y, z=p1.z+d}
end
if minetest.get_node(p).name ~= "air" then
return false
end
end
end
local param2
if p1.z == p2.z then
param2 = 0
else
param2 = 1
end
local target = {x=p1.x, y=p1.y, z=p1.z}
target.x = target.x + 1
if in_nether then
target.y = 0
create_second_portal(target)
else
target.y = portal_target + math.random(4)
end
if not generated_or_generate(target)
and mclike_portal then
return false
end
for d=0,3 do
for y=p1.y,p2.y do
local p
if param2 == 0 then
p = {x=p1.x+d, y=y, z=p1.z}
else
p = {x=p1.x, y=y, z=p1.z+d}
end
if minetest.get_node(p).name == "air" then
minetest.set_node(p, {name="nether:portal", param2=param2})
end
local meta = minetest.get_meta(p)
meta:set_string("p1", minetest.pos_to_string(p1))
meta:set_string("p2", minetest.pos_to_string(p2))
meta:set_string("target", minetest.pos_to_string(target))
end
end
print("[nether] construction accepted.")
return true
end
-- destroy the portal when destroying obsidian
minetest.override_item("default:obsidian", {
on_destruct = function(pos)
local meta = minetest.get_meta(pos)
local p1 = minetest.string_to_pos(meta:get_string("p1"))
local p2 = minetest.string_to_pos(meta:get_string("p2"))
local target = minetest.string_to_pos(meta:get_string("target"))
if not p1 or not p2 then
return
end
for x=p1.x,p2.x do
for y=p1.y,p2.y do
for z=p1.z,p2.z do
local nn = minetest.get_node({x=x,y=y,z=z}).name
if nn == "default:obsidian" or nn == "nether:portal" then
if nn == "nether:portal" then
minetest.remove_node({x=x,y=y,z=z})
end
local m = minetest.get_meta({x=x,y=y,z=z})
m:set_string("p1", "")
m:set_string("p2", "")
m:set_string("target", "")
end
end
end
end
meta = minetest.get_meta(target)
if not meta then
return
end
p1 = minetest.string_to_pos(meta:get_string("p1"))
p2 = minetest.string_to_pos(meta:get_string("p2"))
if not p1 or not p2 then
return
end
for x=p1.x,p2.x do
for y=p1.y,p2.y do
for z=p1.z,p2.z do
local nn = minetest.get_node({x=x,y=y,z=z}).name
if nn == "default:obsidian" or nn == "nether:portal" then
if nn == "nether:portal" then
minetest.remove_node({x=x,y=y,z=z})
end
local m = minetest.get_meta({x=x,y=y,z=z})
m:set_string("p1", "")
m:set_string("p2", "")
m:set_string("target", "")
end
end
end
end
end
})
-- override mese crystal fragment for making an obsidian portal
minetest.after(0.1, function()
minetest.override_item("default:mese_crystal_fragment", {
on_place = function(stack, player, pt)
if pt.under
and minetest.get_node(pt.under).name == "default:obsidian" then
local done = make_portal(pt.under)
if done then
minetest.chat_send_player(player:get_player_name(),
"Warning: If you are in the nether you may not be " ..
"able to find the way out!")
if not minetest.settings:get_bool("creative_mode") then
stack:take_item()
end
end
end
return stack
end
})
end)
-- a not filled square
local function vector_square(r)
local tab, n = {}, 1
for i = -r+1, r do
for j = -1, 1, 2 do
local a, b = r*j, i*j
tab[n] = {a, b}
tab[n+1] = {b, a}
n=n+2
end
end
return tab
end
local function is_netherportal(pos)
local x, y, z = pos.x, pos.y, pos.z
for _,i in pairs({-1, 3}) do
if minetest.get_node({x=x, y=y+i, z=z}).name ~= "nether:white" then
return
end
end
for _,sn in pairs(vector_square(1)) do
if minetest.get_node({x=x+sn[1], y=y-1, z=z+sn[2]}).name ~= "nether:netherrack"
or minetest.get_node({x=x+sn[1], y=y+3, z=z+sn[2]}).name ~= "nether:blood_cooked" then
return
end
end
for _,sn in pairs(vector_square(2)) do
if minetest.get_node({x=x+sn[1], y=y-1, z=z+sn[2]}).name ~= "nether:netherrack_black"
or minetest.get_node({x=x+sn[1], y=y+3, z=z+sn[2]}).name ~= "nether:wood_empty" then
return
end
end
for i = -1,1,2 do
for j = -1,1,2 do
if minetest.get_node({x=x+i, y=y+2, z=z+j}).name ~= "nether:apple" then
return
end
end
end
for i = -2,2,4 do
for j = 0,2 do
for k = -2,2,4 do
if minetest.get_node({x=x+i, y=y+j, z=z+k}).name ~= "nether:netherrack_brick_blue" then
return
end
end
end
end
for i = -1,1 do
for j = -1,1 do
if minetest.get_node({x=x+i, y=y+4, z=z+j}).name ~= "nether:wood_empty" then
return
end
end
end
return true
end
-- cache known portals
local known_portals_d = {}
local known_portals_u = {}
local function get_portal(t, z,x)
return t[z] and t[z][x]
end
local function set_portal(t, z,x, y)
t[z] = t[z] or {}
t[z][x] = y
end
-- used when a player eats that fruit in a portal
function nether.teleport_player(player)
if not player then
minetest.log("error", "[nether] Missing player.")
return
end
local pos = vector.round(player:get_pos())
if not is_netherportal(pos) then
return
end
minetest.sound_play("nether_teleporter", {pos=pos})
local meta = minetest.get_meta({x=pos.x, y=pos.y-1, z=pos.z})
if pos.y < nether.start then
set_portal(known_portals_d, pos.z,pos.x, pos.y)
local my = tonumber(meta:get_string("y"))
local y = get_portal(known_portals_u, pos.z,pos.x)
if y then
if y ~= my then
meta:set_string("y", y)
end
else
y = my or 100
end
pos.y = y - 0.3
player_from_nether(player, pos)
else
set_portal(known_portals_u, pos.z,pos.x, pos.y)
local my = tonumber(meta:get_string("y"))
local y = get_portal(known_portals_d, pos.z,pos.x)
if y then
if y ~= my then
meta:set_string("y", y)
end
else
y = my or portal_target+math.random(4)
end
pos.y = y - 0.3
player_to_nether(player, pos)
end
minetest.sound_play("nether_teleporter", {pos=pos})
return true
end

View File

@ -0,0 +1,90 @@
--V2
local function get_random(a, b, seed)
return PseudoRandom(math.abs(a+b*5)+seed)
end
local r_chs = {}
local function nether_weird_noise(minp, fct, s, seed, range, scale)
if not r_chs[s] then
r_chs[s] = math.floor(s/3+0.5)
end
scale = scale or 15
local r_ch = r_chs[s]
local maxp = vector.add(minp, scale)
local tab,n = {},1
local sm = range or (s+r_ch)*2
for z = -sm, scale+sm do
local pz = z+minp.z
if pz%s == 0 then
for x = -sm, scale+sm do
local px = x+minp.x
if px%s == 0 then
local pr = get_random(px, pz, seed)
tab[n] = {x=px+pr:next(-r_ch, r_ch), y=0, z=pz+pr:next(-r_ch, r_ch)}
n = n+1
end
end
end
end
local tab2,n = {},1
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
local h = sm
for _,i in ipairs(tab) do
h = math.min(h, fct(x, i.x, z, i.z))
end
tab2[n] = {x=x, y=maxp.y-h, z=z}
n = n+1
end
end
return tab2
end
--[[
local function dif(z1, z2)
return math.abs(z1-z2)
end
local function pymg(x1, x2, z1, z2)
return math.max(dif(x1, x2), dif(z1, z2))
end
local function romg(x1, x2, z1, z2)
return math.hypot(dif(x1, x2), dif(z1, z2))
end
local function py2mg(x1, x2, z1, z2)
return dif(x1, x2) + dif(z1, z2)
end
minetest.register_node("ac:wmg", {
description = "wmg",
tiles = {"ac_block.png"},
groups = {snappy=1,bendy=2,cracky=1},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local minp = vector.chunkcorner(pos)
for _,p in ipairs(weird_noise(minp, pymg, 20, 8, 4)) do
local p2 = {x=p.x, y=p.y+1, z=p.z}
if p.y <= minp.y+7 then
local p2 = {x=p.x, y=minp.y+6, z=p.z}
local p3 = {x=p.x, y=p2.y+1, z=p.z}
if minetest.get_node(p2).name ~= "default:desert_stone" then
minetest.set_node(p2, {name="default:desert_stone"})
end
if minetest.get_node(p3).name ~= "default:desert_sand" then
minetest.set_node(p3, {name="default:desert_sand"})
end
else
if minetest.get_node(p).name ~= "default:desert_stone" then
minetest.set_node(p, {name="default:desert_stone"})
end
end
end
end,
})]]
return nether_weird_noise