Compare commits

...

5 Commits

4 changed files with 409 additions and 88 deletions

View File

@ -1,5 +1,15 @@
-- Nether Mod (based on Nyanland, Catapult and Livehouse)
-- lkjoel (Nyanland by Jeija, Catapult by XYZ, Livehouse by neko259)
-- Nether Mod (based on Nyanland by Jeija, Catapult by XYZ, and Livehouse by neko259)
-- lkjoel (main developer, code, ideas, textures)
-- == CONTRIBUTERS ==
-- jordan4ibanez (code, ideas, textures)
-- Gilli (code, ideas, textures, mainly for the Glowstone)
-- Death Dealer (code, ideas, textures)
-- LolManKuba (ideas, textures)
-- IPushButton2653 (ideas, textures)
-- Menche (textures)
-- sdzen (ideas)
-- godkiller447 (ideas)
-- If I didn't list you, please let me know!
--== EDITABLE OPTIONS ==--
@ -9,6 +19,10 @@ NETHER_DEPTH = -20000
NETHER_HEIGHT = 30
-- Maximum amount of randomness in the map generation
NETHER_RANDOM = 2
-- Frequency of Glowstone on the "roof" of the Nether (higher is less frequent)
GLOWSTONE_FREQ_ROOF = 500
-- Frequency of Glowstone on lava (higher is less frequent)
GLOWSTONE_FREQ_LAVA = 2
-- Frequency of lava (higher is less frequent)
LAVA_FREQ = 100
-- Maximum height of lava
@ -27,6 +41,37 @@ HADES_THRONE_STARTPOS = {x=0, y=1, z=0}
NETHER_SPAWNPOS = {x=0, y=5, z=0}
-- Throne of Hades
HADES_THRONE = {
-- Lava Moat
{pos={x=-1,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=0}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=1}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=2}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=3}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=4}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=5}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=6}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=7}, block="nether:lava_source"},
{pos={x=0,y=-1,z=7}, block="nether:lava_source"},
{pos={x=1,y=-1,z=7}, block="nether:lava_source"},
{pos={x=2,y=-1,z=7}, block="nether:lava_source"},
{pos={x=3,y=-1,z=7}, block="nether:lava_source"},
{pos={x=4,y=-1,z=7}, block="nether:lava_source"},
{pos={x=5,y=-1,z=7}, block="nether:lava_source"},
{pos={x=6,y=-1,z=7}, block="nether:lava_source"},
{pos={x=6,y=-1,z=6}, block="nether:lava_source"},
{pos={x=6,y=-1,z=5}, block="nether:lava_source"},
{pos={x=6,y=-1,z=4}, block="nether:lava_source"},
{pos={x=6,y=-1,z=3}, block="nether:lava_source"},
{pos={x=6,y=-1,z=2}, block="nether:lava_source"},
{pos={x=6,y=-1,z=1}, block="nether:lava_source"},
{pos={x=6,y=-1,z=0}, block="nether:lava_source"},
{pos={x=6,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=5,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=4,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=3,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=2,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=1,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=0,y=-1,z=-1}, block="nether:lava_source"},
-- Floor 1
{pos={x=0,y=0,z=0}, block="nether:netherrack"},
{pos={x=0,y=0,z=1}, block="nether:netherrack"},
@ -187,8 +232,10 @@ HADES_THRONE = {
{pos={x=5,y=4,z=3}, block="nether:nether_torch_bottom"},
{pos={x=4,y=4,z=6}, block="nether:nether_torch_bottom"},
{pos={x=5,y=4,z=6}, block="nether:nether_torch_bottom"},
-- Floor 6
{pos={x=1,y=5,z=6}, block="nether:nether_portal_creator"},
{pos={x=0,y=4,z=6}, block="nether:nether_torch_bottom"},
{pos={x=1,y=4,z=6}, block="nether:nether_torch_bottom"},
-- Nether Portal
{pos={x=1,y=5,z=6}, portalblock=true},
}
-- Structure of the nether portal (all is relative to the nether portal creator block)
NETHER_PORTAL = {
@ -246,13 +293,12 @@ NETHER_PORTAL = {
{pos={x=2,y=4,z=-1}, block="obsidian:obsidian_block"},
{pos={x=3,y=4,z=-1}, block="obsidian:obsidian_block"},
}
-- Time to teleport a player to the nether or teleport the player to the overworld
NETHER_PORTAL_SPEED = 5
--== END OF EDITABLE OPTIONS ==--
-- Generated variables
NETHER_BOTTOM = (NETHER_DEPTH - NETHER_HEIGHT)
NETHER_ROOF_ABS = (NETHER_DEPTH - NETHER_RANDOM)
HADES_THRONE_STARTPOS_ABS = {x=HADES_THRONE_STARTPOS.x, y=(NETHER_BOTTOM + HADES_THRONE_STARTPOS.y), z=HADES_THRONE_STARTPOS.z}
LAVA_Y = (NETHER_BOTTOM + LAVA_HEIGHT)
HADES_THRONE_ABS = {}
@ -326,13 +372,62 @@ function nether:inside_nether(pos)
return false
end
-- Nether Lava
minetest.register_node("nether:lava_flowing", {
description = "Nether Lava (flowing)",
inventory_image = minetest.inventorycube("default_lava.png"),
drawtype = "flowingliquid",
tile_images = {"default_lava.png"},
paramtype = "light",
light_source = LIGHT_MAX - 1,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
liquidtype = "flowing",
liquid_alternative_flowing = "nether:lava_flowing",
liquid_alternative_source = "nether:lava_source",
liquid_viscosity = LAVA_VISC,
damage_per_second = 4*2,
post_effect_color = {a=192, r=255, g=64, b=0},
special_materials = {
{image="default_lava.png", backface_culling=false},
{image="default_lava.png", backface_culling=true},
},
groups = {lava=3, liquid=2, hot=3},
})
minetest.register_node("nether:lava_source", {
description = "Nether Lava",
inventory_image = minetest.inventorycube("default_lava.png"),
drawtype = "liquid",
tile_images = {"default_lava.png"},
paramtype = "light",
light_source = LIGHT_MAX - 1,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
liquidtype = "source",
liquid_alternative_flowing = "nether:lava_flowing",
liquid_alternative_source = "nether:lava_source",
liquid_viscosity = LAVA_VISC,
damage_per_second = 4*2,
post_effect_color = {a=192, r=255, g=64, b=0},
special_materials = {
-- New-style lava source material (mostly unused)
{image="default_lava.png", backface_culling=false},
},
groups = {lava=3, liquid=2, hot=3},
})
-- Netherrack
minetest.register_node("nether:netherrack", {
description = "Netherrack",
tile_images = {"nether_netherrack.png"},
is_ground_content = true,
groups = {cracky=3},
drop = "nether_netherrack.png",
groups = {cracky=3, oddly_breakable_by_hand=3},
drop = "nether:netherrack",
sounds = default.node_sound_stone_defaults(),
})
@ -399,7 +494,7 @@ minetest.register_node("nether:nether_torch", {
minetest.register_node("nether:nether_torch_bottom", {
description = "Nether Torch Bottom Side (you hacker!)",
drawtype = "torchlike",
tile_images = {"nether_torch_on_floor.png", "nether_torch_on_floor.png", "nether_torch_floor.png"},
tile_images = {"nether_torch_on_floor.png", "nether_torch_on_floor.png", "nether_torch_on_floor.png"},
inventory_image = "nether_torch_on_floor.png",
wield_image = "nether_torch_on_floor.png",
paramtype = "light",
@ -429,6 +524,16 @@ minetest.register_craftitem("nether:nether_pearl", {
textures = {"nether_pearl.png"},
})
-- Nether Glowstone (Thanks to Gilli)
minetest.register_node( "nether:glowstone", {
description = "Nether Glowstone",
tile_images = {"nether_glowstone.png"},
light_source = 15, -- Like in Minecraft
inventory_inventory_image = minetest.inventorycube( "nether_glowstone.png" ),
is_ground_content = true,
groups = {snappy=2, choppy=2, oddly_breakable_by_hand = 1.5},
})
-- Create the Nether
minetest.register_on_generated(function(minp, maxp)
local addpos = {}
@ -443,9 +548,14 @@ minetest.register_on_generated(function(minp, maxp)
minetest.env:add_node(addpos, {name="nether:netherrack"})
elseif y == NETHER_BOTTOM then
minetest.env:add_node(addpos, {name="nether:netherrack"})
elseif (y == math.random((NETHER_DEPTH-NETHER_RANDOM), NETHER_DEPTH)) then
elseif (math.floor(math.random(0, GLOWSTONE_FREQ_ROOF)) == 1) and (y >= NETHER_ROOF_ABS-1) and (nether:can_add_sticky_node(addpos) == true) then
minetest.env:add_node(addpos, {name="nether:glowstone"})
--[[elseif (math.floor(math.random(0, GLOWSTONE_FREQ_LAVA)) == 1) and ((nether:nodebelow(addpos) == "nether:lava_source") or (nether:nodebelow(addpos) == "nether:lava_flowing")) then
minetest.env:add_node(addpos, {name="nether:glowstone"})
print("GLOWSTONE" .. "X:" .. addpos.x .. "Y:" .. addpos.y .. "Z:" .. addpos.z)]]
elseif (y == math.floor(math.random((NETHER_DEPTH-NETHER_RANDOM), NETHER_DEPTH))) and (nether:can_add_sticky_node(addpos) == true) then
minetest.env:add_node(addpos, {name="nether:netherrack"})
elseif (y == math.random(NETHER_BOTTOM, (NETHER_BOTTOM+NETHER_RANDOM))) then
elseif (y == math.floor(math.random(NETHER_BOTTOM, (NETHER_BOTTOM+NETHER_RANDOM)))) and (nether:can_add_sticky_node(addpos) == true) then
minetest.env:add_node(addpos, {name="nether:netherrack"})
elseif y <= NETHER_DEPTH and y >= NETHER_BOTTOM then
minetest.env:add_node(addpos, {name="air"})
@ -462,7 +572,7 @@ minetest.register_on_generated(function(minp, maxp)
if math.random(NETHER_TREE_FREQ) == 1 and y == (NETHER_BOTTOM + 1) then
nether:grow_nethertree(addpos)
elseif math.random(LAVA_FREQ) == 1 and y <= LAVA_Y then
minetest.env:add_node(addpos, {name="default:lava_source"})
minetest.env:add_node(addpos, {name="nether:lava_source"})
end
end
end
@ -483,13 +593,54 @@ minetest.register_on_generated(function(minp, maxp)
end
-- Pass 4: Throne of Hades
for i,v in ipairs(HADES_THRONE_ABS) do
minetest.env:add_node(v.pos, {name=v.block})
if v.portalblock == true then
NETHER_PORTALS_FROM_NETHER[table.getn(NETHER_PORTALS_FROM_NETHER)+1] = v.pos
nether:save_portal_from_nether(v.pos)
nether:createportal(v.pos)
else
minetest.env:add_node(v.pos, {name=v.block})
end
end
nether:touch(HADES_THRONE_GENERATED)
end
end
end)
-- Return the name of the node below a position
function nether:nodebelow(pos)
return minetest.env:get_node({x=pos.x, y=(pos.y-1), z=pos.z}).name
end
-- Check if we can add a "sticky" node (i.e. it has to stick to something else, or else it won't be added)
-- This is largely based on Gilli's code
function nether:can_add_sticky_node(pos)
local nodehere = false
local objname
for x = -1, 1 do
for y = -1, 1 do
for z = -1, 1 do
local p = {x=pos.x+x, y=pos.y+y, z=pos.z+z}
local n = minetest.env:get_node(p)
objname = n.name
if objname ~= "air" and minetest.registered_nodes[objname].walkable == true then
nodehere = true
end
end
end
end
return nodehere
end
-- Add a "sticky" node
function nether:add_sticky_node(pos, opts)
if nether:can_add_sticky_node(pos) == true then
minetest.env:add_node(pos, opts)
return true
else
return false
end
end
-- Create a nether tree
function nether:grow_nethertree(pos)
--TRUNK
@ -596,12 +747,12 @@ function nether:save_portals_to_nether()
if file ~= nil then
file:write("")
file:close()
for i,v in ipairs(NETHER_PORTALS_TO_NETHER) do
nether:save_portal_to_nether(v)
end
else
nether:printerror("Cannot create portal file!")
end
for i,v in ipairs(NETHER_PORTALS_TO_NETHER) do
nether:save_portal_to_nether(v)
end
end
-- Save a portal from nether
@ -623,12 +774,12 @@ function nether:save_portals_from_nether()
if file ~= nil then
file:write("")
file:close()
for i,v in ipairs(NETHER_PORTALS_FROM_NETHER) do
nether:save_portal_from_nether(v)
end
else
nether:printerror("Cannot create portal file!")
end
for i,v in ipairs(NETHER_PORTALS_FROM_NETHER) do
nether:save_portal_from_nether(v)
end
end
-- Read portals to nether
@ -699,13 +850,8 @@ nether:read_portals_from_nether()
-- Teleport the player
function nether:teleport_player(from_nether, player)
local randomportal = 1
local coin = math.floor(math.random(0, 1))
if coin == 0 then
coin = -1
else
coin = 1
end
local coin2 = math.floor(math.random(1, 2))
local coin = math.random(0, 1) * 2 - 1 -- result will be -1 or 1
local coin2 = math.random(1, 2) -- result will be 1 or 2
local num = 1
local forgetit = false
if from_nether == true then
@ -741,36 +887,47 @@ function nether:teleport_player(from_nether, player)
player:setpos(teleportpos)
end
-- Creates a portal
function nether:createportal(pos)
local currx
local curry
local currz
local currpos = {}
for i,v in ipairs(NETHER_PORTAL) do
currx = v.pos.x + pos.x
curry = v.pos.y + pos.y
currz = v.pos.z + pos.z
currpos = {x=currx, y=curry, z=currz}
minetest.env:add_node(currpos, {name=v.block})
end
end
-- Portal Creator
minetest.register_node("nether:nether_portal_creator", {
description = "Nether Portal Creator",
tile_images = {"nether_portal_creator.png"},
description = "Nether Portal Creator",
})
minetest.register_on_placenode(function(pos, node)
if node.name == "nether:nether_portal_creator" then
if nether:inside_nether(pos) then
NETHER_PORTALS_FROM_NETHER[table.getn(NETHER_PORTALS_FROM_NETHER)+1] = pos
nether:save_portal_from_nether(pos)
else
NETHER_PORTALS_TO_NETHER[table.getn(NETHER_PORTALS_TO_NETHER)+1] = pos
nether:save_portal_to_nether(pos)
end
nether:createportal(pos)
end
nodeupdate(pos)
end)
minetest.register_abm({
nodenames = "nether:nether_portal_creator",
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local nodemeta = minetest.env:get_meta(pos)
if nodemeta:get_string("generatingportal") == "" or nodemeta:get_string("generatingportal") == nil then
nodemeta:set_string("generatingportal", "true")
for i,v in ipairs(NETHER_PORTAL) do
v.pos.x = v.pos.x + pos.x
v.pos.y = v.pos.y + pos.y
v.pos.z = v.pos.z + pos.z
minetest.env:add_node(v.pos, {name=v.block})
end
if nether:inside_nether(pos) then
NETHER_PORTALS_FROM_NETHER[table.getn(NETHER_PORTALS_FROM_NETHER)+1] = pos
nether:save_portals_from_nether()
nether:read_portals_from_nether()
else
NETHER_PORTALS_TO_NETHER[table.getn(NETHER_PORTALS_TO_NETHER)+1] = pos
nether:save_portals_to_nether()
nether:read_portals_from_nether()
end
end
action = function(pos)
nether:createportal(pos)
end
})
@ -781,6 +938,7 @@ minetest.register_node("nether:nether_portal", {
tile_images = {"nether_portal_stuff.png"},
inventory_image = "nether_portal_stuff.png",
wield_image = "nether_portal_stuff.png",
light_source = LIGHT_MAX - 2,
paramtype = "light",
sunlight_propagates = true,
walkable = false,

View File

@ -1,5 +1,15 @@
-- Nether Mod (based on Nyanland, Catapult and Livehouse)
-- lkjoel (Nyanland by Jeija, Catapult by XYZ, Livehouse by neko259)
-- Nether Mod (based on Nyanland by Jeija, Catapult by XYZ, and Livehouse by neko259)
-- lkjoel (main developer, code, ideas, textures)
-- == CONTRIBUTERS ==
-- jordan4ibanez (code, ideas, textures)
-- Gilli (code, ideas, textures, mainly for the Glowstone)
-- Death Dealer (code, ideas, textures)
-- LolManKuba (ideas, textures)
-- IPushButton2653 (ideas, textures)
-- Menche (textures)
-- sdzen (ideas)
-- godkiller447 (ideas)
-- If I didn't list you, please let me know!
--== EDITABLE OPTIONS ==--
@ -9,6 +19,10 @@ NETHER_DEPTH = -20000
NETHER_HEIGHT = 30
-- Maximum amount of randomness in the map generation
NETHER_RANDOM = 2
-- Frequency of Glowstone on the "roof" of the Nether (higher is less frequent)
GLOWSTONE_FREQ_ROOF = 500
-- Frequency of Glowstone on lava (higher is less frequent)
GLOWSTONE_FREQ_LAVA = 2
-- Frequency of lava (higher is less frequent)
LAVA_FREQ = 100
-- Maximum height of lava
@ -27,6 +41,37 @@ HADES_THRONE_STARTPOS = {x=0, y=1, z=0}
NETHER_SPAWNPOS = {x=0, y=5, z=0}
-- Throne of Hades
HADES_THRONE = {
-- Lava Moat
{pos={x=-1,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=0}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=1}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=2}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=3}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=4}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=5}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=6}, block="nether:lava_source"},
{pos={x=-1,y=-1,z=7}, block="nether:lava_source"},
{pos={x=0,y=-1,z=7}, block="nether:lava_source"},
{pos={x=1,y=-1,z=7}, block="nether:lava_source"},
{pos={x=2,y=-1,z=7}, block="nether:lava_source"},
{pos={x=3,y=-1,z=7}, block="nether:lava_source"},
{pos={x=4,y=-1,z=7}, block="nether:lava_source"},
{pos={x=5,y=-1,z=7}, block="nether:lava_source"},
{pos={x=6,y=-1,z=7}, block="nether:lava_source"},
{pos={x=6,y=-1,z=6}, block="nether:lava_source"},
{pos={x=6,y=-1,z=5}, block="nether:lava_source"},
{pos={x=6,y=-1,z=4}, block="nether:lava_source"},
{pos={x=6,y=-1,z=3}, block="nether:lava_source"},
{pos={x=6,y=-1,z=2}, block="nether:lava_source"},
{pos={x=6,y=-1,z=1}, block="nether:lava_source"},
{pos={x=6,y=-1,z=0}, block="nether:lava_source"},
{pos={x=6,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=5,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=4,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=3,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=2,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=1,y=-1,z=-1}, block="nether:lava_source"},
{pos={x=0,y=-1,z=-1}, block="nether:lava_source"},
-- Floor 1
{pos={x=0,y=0,z=0}, block="nether:netherrack"},
{pos={x=0,y=0,z=1}, block="nether:netherrack"},
@ -187,8 +232,10 @@ HADES_THRONE = {
{pos={x=5,y=4,z=3}, block="nether:nether_torch_bottom"},
{pos={x=4,y=4,z=6}, block="nether:nether_torch_bottom"},
{pos={x=5,y=4,z=6}, block="nether:nether_torch_bottom"},
-- Floor 6
{pos={x=1,y=5,z=6}, block="nether:nether_portal_creator"},
{pos={x=0,y=4,z=6}, block="nether:nether_torch_bottom"},
{pos={x=1,y=4,z=6}, block="nether:nether_torch_bottom"},
-- Nether Portal
{pos={x=1,y=5,z=6}, portalblock=true},
}
-- Structure of the nether portal (all is relative to the nether portal creator block)
NETHER_PORTAL = {
@ -246,13 +293,12 @@ NETHER_PORTAL = {
{pos={x=2,y=4,z=-1}, block="obsidian:obsidian_block"},
{pos={x=3,y=4,z=-1}, block="obsidian:obsidian_block"},
}
-- Time to teleport a player to the nether or teleport the player to the overworld
NETHER_PORTAL_SPEED = 5
--== END OF EDITABLE OPTIONS ==--
-- Generated variables
NETHER_BOTTOM = (NETHER_DEPTH - NETHER_HEIGHT)
NETHER_ROOF_ABS = (NETHER_DEPTH - NETHER_RANDOM)
HADES_THRONE_STARTPOS_ABS = {x=HADES_THRONE_STARTPOS.x, y=(NETHER_BOTTOM + HADES_THRONE_STARTPOS.y), z=HADES_THRONE_STARTPOS.z}
LAVA_Y = (NETHER_BOTTOM + LAVA_HEIGHT)
HADES_THRONE_ABS = {}
@ -326,13 +372,62 @@ function nether:inside_nether(pos)
return false
end
-- Nether Lava
minetest.register_node("nether:lava_flowing", {
description = "Nether Lava (flowing)",
inventory_image = minetest.inventorycube("default_lava.png"),
drawtype = "flowingliquid",
tile_images = {"default_lava.png"},
paramtype = "light",
light_source = LIGHT_MAX - 1,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
liquidtype = "flowing",
liquid_alternative_flowing = "nether:lava_flowing",
liquid_alternative_source = "nether:lava_source",
liquid_viscosity = LAVA_VISC,
damage_per_second = 4*2,
post_effect_color = {a=192, r=255, g=64, b=0},
special_materials = {
{image="default_lava.png", backface_culling=false},
{image="default_lava.png", backface_culling=true},
},
groups = {lava=3, liquid=2, hot=3},
})
minetest.register_node("nether:lava_source", {
description = "Nether Lava",
inventory_image = minetest.inventorycube("default_lava.png"),
drawtype = "liquid",
tile_images = {"default_lava.png"},
paramtype = "light",
light_source = LIGHT_MAX - 1,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
liquidtype = "source",
liquid_alternative_flowing = "nether:lava_flowing",
liquid_alternative_source = "nether:lava_source",
liquid_viscosity = LAVA_VISC,
damage_per_second = 4*2,
post_effect_color = {a=192, r=255, g=64, b=0},
special_materials = {
-- New-style lava source material (mostly unused)
{image="default_lava.png", backface_culling=false},
},
groups = {lava=3, liquid=2, hot=3},
})
-- Netherrack
minetest.register_node("nether:netherrack", {
description = "Netherrack",
tile_images = {"nether_netherrack.png"},
is_ground_content = true,
groups = {cracky=3},
drop = "nether_netherrack.png",
groups = {cracky=3, oddly_breakable_by_hand=3},
drop = "nether:netherrack",
sounds = default.node_sound_stone_defaults(),
})
@ -399,7 +494,7 @@ minetest.register_node("nether:nether_torch", {
minetest.register_node("nether:nether_torch_bottom", {
description = "Nether Torch Bottom Side (you hacker!)",
drawtype = "torchlike",
tile_images = {"nether_torch_on_floor.png", "nether_torch_on_floor.png", "nether_torch_floor.png"},
tile_images = {"nether_torch_on_floor.png", "nether_torch_on_floor.png", "nether_torch_on_floor.png"},
inventory_image = "nether_torch_on_floor.png",
wield_image = "nether_torch_on_floor.png",
paramtype = "light",
@ -429,6 +524,16 @@ minetest.register_craftitem("nether:nether_pearl", {
textures = {"nether_pearl.png"},
})
-- Nether Glowstone (Thanks to Gilli)
minetest.register_node( "nether:glowstone", {
description = "Nether Glowstone",
tile_images = {"nether_glowstone.png"},
light_source = 15, -- Like in Minecraft
inventory_inventory_image = minetest.inventorycube( "nether_glowstone.png" ),
is_ground_content = true,
groups = {snappy=2, choppy=2, oddly_breakable_by_hand = 1.5},
})
-- Create the Nether
minetest.register_on_generated(function(minp, maxp)
local addpos = {}
@ -443,9 +548,14 @@ minetest.register_on_generated(function(minp, maxp)
minetest.env:add_node(addpos, {name="nether:netherrack"})
elseif y == NETHER_BOTTOM then
minetest.env:add_node(addpos, {name="nether:netherrack"})
elseif (y == math.random((NETHER_DEPTH-NETHER_RANDOM), NETHER_DEPTH)) then
elseif (math.floor(math.random(0, GLOWSTONE_FREQ_ROOF)) == 1) and (y >= NETHER_ROOF_ABS-1) and (nether:can_add_sticky_node(addpos) == true) then
minetest.env:add_node(addpos, {name="nether:glowstone"})
--[[elseif (math.floor(math.random(0, GLOWSTONE_FREQ_LAVA)) == 1) and ((nether:nodebelow(addpos) == "nether:lava_source") or (nether:nodebelow(addpos) == "nether:lava_flowing")) then
minetest.env:add_node(addpos, {name="nether:glowstone"})
print("GLOWSTONE" .. "X:" .. addpos.x .. "Y:" .. addpos.y .. "Z:" .. addpos.z)]]
elseif (y == math.floor(math.random((NETHER_DEPTH-NETHER_RANDOM), NETHER_DEPTH))) and (nether:can_add_sticky_node(addpos) == true) then
minetest.env:add_node(addpos, {name="nether:netherrack"})
elseif (y == math.random(NETHER_BOTTOM, (NETHER_BOTTOM+NETHER_RANDOM))) then
elseif (y == math.floor(math.random(NETHER_BOTTOM, (NETHER_BOTTOM+NETHER_RANDOM)))) and (nether:can_add_sticky_node(addpos) == true) then
minetest.env:add_node(addpos, {name="nether:netherrack"})
elseif y <= NETHER_DEPTH and y >= NETHER_BOTTOM then
minetest.env:add_node(addpos, {name="air"})
@ -462,7 +572,7 @@ minetest.register_on_generated(function(minp, maxp)
if math.random(NETHER_TREE_FREQ) == 1 and y == (NETHER_BOTTOM + 1) then
nether:grow_nethertree(addpos)
elseif math.random(LAVA_FREQ) == 1 and y <= LAVA_Y then
minetest.env:add_node(addpos, {name="default:lava_source"})
minetest.env:add_node(addpos, {name="nether:lava_source"})
end
end
end
@ -483,13 +593,54 @@ minetest.register_on_generated(function(minp, maxp)
end
-- Pass 4: Throne of Hades
for i,v in ipairs(HADES_THRONE_ABS) do
minetest.env:add_node(v.pos, {name=v.block})
if v.portalblock == true then
NETHER_PORTALS_FROM_NETHER[table.getn(NETHER_PORTALS_FROM_NETHER)+1] = v.pos
nether:save_portal_from_nether(v.pos)
nether:createportal(v.pos)
else
minetest.env:add_node(v.pos, {name=v.block})
end
end
nether:touch(HADES_THRONE_GENERATED)
end
end
end)
-- Return the name of the node below a position
function nether:nodebelow(pos)
return minetest.env:get_node({x=pos.x, y=(pos.y-1), z=pos.z}).name
end
-- Check if we can add a "sticky" node (i.e. it has to stick to something else, or else it won't be added)
-- This is largely based on Gilli's code
function nether:can_add_sticky_node(pos)
local nodehere = false
local objname
for x = -1, 1 do
for y = -1, 1 do
for z = -1, 1 do
local p = {x=pos.x+x, y=pos.y+y, z=pos.z+z}
local n = minetest.env:get_node(p)
objname = n.name
if objname ~= "air" and minetest.registered_nodes[objname].walkable == true then
nodehere = true
end
end
end
end
return nodehere
end
-- Add a "sticky" node
function nether:add_sticky_node(pos, opts)
if nether:can_add_sticky_node(pos) == true then
minetest.env:add_node(pos, opts)
return true
else
return false
end
end
-- Create a nether tree
function nether:grow_nethertree(pos)
--TRUNK
@ -596,12 +747,12 @@ function nether:save_portals_to_nether()
if file ~= nil then
file:write("")
file:close()
for i,v in ipairs(NETHER_PORTALS_TO_NETHER) do
nether:save_portal_to_nether(v)
end
else
nether:printerror("Cannot create portal file!")
end
for i,v in ipairs(NETHER_PORTALS_TO_NETHER) do
nether:save_portal_to_nether(v)
end
end
-- Save a portal from nether
@ -623,12 +774,12 @@ function nether:save_portals_from_nether()
if file ~= nil then
file:write("")
file:close()
for i,v in ipairs(NETHER_PORTALS_FROM_NETHER) do
nether:save_portal_from_nether(v)
end
else
nether:printerror("Cannot create portal file!")
end
for i,v in ipairs(NETHER_PORTALS_FROM_NETHER) do
nether:save_portal_from_nether(v)
end
end
-- Read portals to nether
@ -741,36 +892,47 @@ function nether:teleport_player(from_nether, player)
player:setpos(teleportpos)
end
-- Creates a portal
function nether:createportal(pos)
local currx
local curry
local currz
local currpos = {}
for i,v in ipairs(NETHER_PORTAL) do
currx = v.pos.x + pos.x
curry = v.pos.y + pos.y
currz = v.pos.z + pos.z
currpos = {x=currx, y=curry, z=currz}
minetest.env:add_node(v.pos, {name=v.block})
end
end
-- Portal Creator
minetest.register_node("nether:nether_portal_creator", {
description = "Nether Portal Creator",
tile_images = {"nether_portal_creator.png"},
description = "Nether Portal Creator",
})
minetest.register_on_placenode(function(pos, node)
if node.name == "nether:nether_portal_creator" then
if nether:inside_nether(pos) then
NETHER_PORTALS_FROM_NETHER[table.getn(NETHER_PORTALS_FROM_NETHER)+1] = pos
nether:save_portal_from_nether(pos)
else
NETHER_PORTALS_TO_NETHER[table.getn(NETHER_PORTALS_TO_NETHER)+1] = pos
nether:save_portal_to_nether(pos)
end
nether:createportal(pos)
end
nodeupdate(pos)
end)
minetest.register_abm({
nodenames = "nether:nether_portal_creator",
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local nodemeta = minetest.env:get_meta(pos)
if nodemeta:get_string("generatingportal") == "" or nodemeta:get_string("generatingportal") == nil then
nodemeta:set_string("generatingportal", "true")
for i,v in ipairs(NETHER_PORTAL) do
v.pos.x = v.pos.x + pos.x
v.pos.y = v.pos.y + pos.y
v.pos.z = v.pos.z + pos.z
minetest.env:add_node(v.pos, {name=v.block})
end
if nether:inside_nether(pos) then
NETHER_PORTALS_FROM_NETHER[table.getn(NETHER_PORTALS_FROM_NETHER)+1] = pos
nether:save_portals_from_nether()
nether:read_portals_from_nether()
else
NETHER_PORTALS_TO_NETHER[table.getn(NETHER_PORTALS_TO_NETHER)+1] = pos
nether:save_portals_to_nether()
nether:read_portals_from_nether()
end
end
action = function(pos)
nether:createportal(pos)
end
})
@ -781,6 +943,7 @@ minetest.register_node("nether:nether_portal", {
tile_images = {"nether_portal_stuff.png"},
inventory_image = "nether_portal_stuff.png",
wield_image = "nether_portal_stuff.png",
light_source = LIGHT_MAX - 2,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
@ -808,7 +971,7 @@ minetest.register_abm({
objmeta:set_string("teleportingfromnether", "true")
objmeta:set_string("teleportingtonether", "")
nether:teleport_player(innether, obj)
elseif innether == false and (objmeta:get_string("teleportingfromnether") == "" or objmeta:get_string("teleportingfromnether") == nil) then
elseif innether == false and (objmeta:get_string("teleportingtonether") == "" or objmeta:get_string("teleportingtonether") == nil) then
objmeta:set_string("teleportingtonether", "true")
objmeta:set_string("teleportingfromnether", "")
nether:teleport_player(innether, obj)

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 B

After

Width:  |  Height:  |  Size: 882 B