Compare commits

..

8 Commits

6 changed files with 87 additions and 142 deletions

View File

@ -24,6 +24,11 @@ local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= fa
local mobs_debug = minetest.settings:get_bool("mobs_debug", false) -- Shows helpful debug info above each mob
local spawn_logging = minetest.settings:get_bool("mcl_logging_mobs_spawn",true)
local MAPGEN_LIMIT = mcl_vars.mapgen_limit
local MAPGEN_MOB_LIMIT = MAPGEN_LIMIT - 90
-- 30927 seems to be the edge of the world, so could be closer, but this is safer
-- Peaceful mode message so players will know there are no monsters
if minetest.settings:get_bool("only_peaceful_mobs", false) then
minetest.register_on_joinplayer(function(player)
@ -328,12 +333,37 @@ local function update_timers (self, dtime)
end
end
function mob_class:outside_limits()
local pos = self.object:get_pos()
if pos then
local posx = math.abs(pos.x)
local posy = math.abs(pos.y)
local posz = math.abs(pos.z)
if posx > MAPGEN_MOB_LIMIT or posy > MAPGEN_MOB_LIMIT or posz > MAPGEN_MOB_LIMIT then
--minetest.log("action", "Getting close to limits of worldgen: " .. minetest.pos_to_string(pos))
if posx > MAPGEN_LIMIT or posy > MAPGEN_LIMIT or posz > MAPGEN_LIMIT then
minetest.log("action", "Warning mob past limits of worldgen: " .. minetest.pos_to_string(pos))
else
if self.state ~= "stand" then
minetest.log("action", "Warning mob close to limits of worldgen: " .. minetest.pos_to_string(pos))
self.state = "stand"
self:set_animation("stand")
self.object:set_acceleration(vector.zero())
self.object:set_velocity(vector.zero())
end
end
return true
end
end
end
-- main mob function
function mob_class:on_step(dtime)
local pos = self.object:get_pos()
if not pos then return end
if self:check_despawn(pos, dtime) then return true end
if self:outside_limits() then return end
if self:check_death_and_slow_mob() then
--minetest.log("action", "Mob is dying: ".. tostring(self.name))

View File

@ -172,6 +172,7 @@ local professions = {
{ { "mcl_mobitems:string", 15, 20 }, E1 },
{ E1, { "mcl_bows:arrow", 8, 12 } },
{ { "mcl_core:gravel", 10, 10, "mcl_core:emerald", 1, 1 }, { "mcl_core:flint", 6, 10 } },
{ { "mcl_core:stick", 32, 32 }, E1 },
},
{
{ { "mcl_core:flint", 26, 26 }, E1 },

View File

@ -1,84 +1,33 @@
--local deepslate_mod = minetest.get_modpath("mcl_deepslate")
-- a basic on_place()
function mcl_copper.on_place (itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local node = minetest.get_node(pointed_thing.under)
local pos = pointed_thing.under
local node_name = node.name
if mcl_util.check_position_protection(pos, placer) then
return itemstack
end
-- Use pointed node's on_rightclick function first, if present
local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
if new_stack then
return new_stack
end
local placed = ItemStack(itemstack:get_name())
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
minetest.item_place(placed, placer, pointed_thing, minetest.dir_to_facedir(vector.direction(pointed_thing.above, pointed_thing.under)))
return itemstack
end
local function register_oxidation_abm(abm_name, node_name, oxidized_variant)
minetest.register_abm({
label = abm_name,
nodenames = { node_name },
nodenames = {node_name},
interval = 500,
chance = 3,
action = function(pos, node)
minetest.swap_node(pos, { name = oxidized_variant, param2 = node.param2 })
minetest.swap_node(pos, {name = oxidized_variant, param2 = node.param2})
end,
})
end
function waxing_copper_block(pos, node, player, itemstack, convert_to)
if itemstack:get_name() == "mcl_honey:honeycomb" then
-- prevent modification of protected nodes.
if mcl_util.check_position_protection(pos, player) then
return
end
local def = minetest.registered_nodes[node.name]
if def and def._mcl_copper_waxed_variant then
node.name = def._mcl_copper_waxed_variant
end
node.name = convert_to
minetest.set_node(pos, node)
awards.unlock(player:get_player_name(), "mcl:wax_on")
if not minetest.is_creative_enabled(player:get_player_name()) then
itemstack:take_item()
end
return itemstack
else
return -- changed to work with mcl_util.call_on_rightclick()
return true
end
end
function scraping_copper_block(pos, node, player, itemstack, convert_to)
if itemstack:get_name():find("axe") then
-- prevent modification of protected nodes.
if mcl_util.check_position_protection(pos, player) then
return
end
local def = minetest.registered_nodes[node.name]
if def and def._mcl_copper_unwaxed_variant then
node.name = def._mcl_copper_unwaxed_variant
end
node.name = convert_to
minetest.set_node(pos, node)
awards.unlock(player:get_player_name(), "mcl:wax_off")
if not minetest.is_creative_enabled(player:get_player_name()) then
@ -87,7 +36,7 @@ function scraping_copper_block(pos, node, player, itemstack, convert_to)
itemstack:add_wear(wear)
end
else
return
return true
end
end
@ -215,41 +164,41 @@ if not deepslate_mod then
end
--]]
local block_oxidation = {
{ "", "_exposed" },
{ "_cut", "_exposed_cut" },
{ "_exposed", "_weathered" },
{ "_exposed_cut", "_weathered_cut" },
{ "_weathered", "_oxidized" },
{ "_weathered_cut", "_oxidized_cut" }
{"", "_exposed"},
{"_cut", "_exposed_cut"},
{"_exposed", "_weathered"},
{"_exposed_cut", "_weathered_cut"},
{"_weathered", "_oxidized"},
{"_weathered_cut", "_oxidized_cut"}
}
local stair_oxidation = {
{ "slab", "cut", "exposed_cut" },
{ "slab", "exposed_cut", "weathered_cut" },
{ "slab", "weathered_cut", "oxidized_cut" },
{ "slab", "cut_top", "exposed_cut_top" },
{ "slab", "exposed_cut_top", "weathered_cut_top" },
{ "slab", "weathered_cut_top", "oxidized_cut_double" },
{ "slab", "cut_double", "exposed_cut_double" },
{ "slab", "exposed_cut_double", "weathered_cut_double" },
{ "slab", "weathered_cut_double", "oxidized_cut_double" },
{ "stair", "cut", "exposed_cut" },
{ "stair", "exposed_cut", "weathered_cut" },
{ "stair", "weathered_cut", "oxidized_cut" },
{ "stair", "cut_inner", "exposed_cut_inner" },
{ "stair", "exposed_cut_inner", "weathered_cut_inner" },
{ "stair", "weathered_cut_inner", "oxidized_cut_inner" },
{ "stair", "cut_outer", "exposed_cut_outer" },
{ "stair", "exposed_cut_outer", "weathered_cut_outer" },
{ "stair", "weathered_cut_outer", "oxidized_cut_outer" }
{"slab", "cut", "exposed_cut"},
{"slab", "exposed_cut", "weathered_cut"},
{"slab", "weathered_cut", "oxidized_cut"},
{"slab", "cut_top", "exposed_cut_top"},
{"slab", "exposed_cut_top", "weathered_cut_top"},
{"slab", "weathered_cut_top", "oxidized_cut_double"},
{"slab", "cut_double", "exposed_cut_double"},
{"slab", "exposed_cut_double", "weathered_cut_double"},
{"slab", "weathered_cut_double", "oxidized_cut_double"},
{"stair", "cut", "exposed_cut"},
{"stair", "exposed_cut", "weathered_cut"},
{"stair", "weathered_cut", "oxidized_cut"},
{"stair", "cut_inner", "exposed_cut_inner"},
{"stair", "exposed_cut_inner", "weathered_cut_inner"},
{"stair", "weathered_cut_inner", "oxidized_cut_inner"},
{"stair", "cut_outer", "exposed_cut_outer"},
{"stair", "exposed_cut_outer", "weathered_cut_outer"},
{"stair", "weathered_cut_outer", "oxidized_cut_outer"}
}
for _, b in pairs(block_oxidation) do
register_oxidation_abm("Copper oxidation", "mcl_copper:block" .. b[1], "mcl_copper:block" .. b[2])
register_oxidation_abm("Copper oxidation", "mcl_copper:block"..b[1], "mcl_copper:block"..b[2])
end
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
--local axes = {"wood", "stone", "iron", "gold", "diamond"}

View File

@ -1,7 +1,5 @@
local path = minetest.get_modpath("mcl_copper")
mcl_copper = {} -- initialize global variable.
dofile(path .. "/functions.lua")
dofile(path .. "/nodes.lua")
dofile(path .. "/items.lua")

View File

@ -1,4 +1,4 @@
name = mcl_copper
author = NO11
depends = mcl_core, mcl_sounds, mcl_stairs, mcl_util
depends = mcl_core, mcl_sounds, mcl_stairs
description = Adds Copper Ore, blocks and items.

View File

@ -12,6 +12,7 @@ minetest.register_node("mcl_copper:stone_with_copper", {
_mcl_hardness = 3,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = mcl_core.fortune_drop_ore,
})
minetest.register_node("mcl_copper:block_raw", {
@ -34,11 +35,7 @@ minetest.register_node("mcl_copper:block", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 3,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack)
return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block")
end,
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block") end,
})
minetest.register_node("mcl_copper:waxed_block", {
@ -50,9 +47,7 @@ minetest.register_node("mcl_copper:waxed_block", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 3,
_mcl_copper_unwaxed_variant = "mcl_copper:block",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end,
})
minetest.register_node("mcl_copper:block_exposed", {
@ -64,10 +59,8 @@ minetest.register_node("mcl_copper:block_exposed", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_anti_oxidation_variant = "mcl_copper:block",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed") end,
_mcl_anti_oxidation_varient = "mcl_copper:block",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed") end,
})
minetest.register_node("mcl_copper:waxed_block_exposed", {
@ -79,9 +72,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_copper_unwaxed_variant = "mcl_copper:block",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end,
})
minetest.register_node("mcl_copper:block_weathered", {
@ -93,10 +84,8 @@ minetest.register_node("mcl_copper:block_weathered", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_anti_oxidation_variant = "mcl_copper:block_exposed",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered") end,
_mcl_anti_oxidation_varient = "mcl_copper:block_exposed",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered") end,
})
minetest.register_node("mcl_copper:waxed_block_weathered", {
@ -108,9 +97,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_copper_unwaxed_variant = "mcl_copper:block_exposed",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed") end,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed") end,
})
minetest.register_node("mcl_copper:block_oxidized", {
@ -122,10 +109,8 @@ minetest.register_node("mcl_copper:block_oxidized", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_anti_oxidation_variant = "mcl_copper:block_weathered",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized") end,
_mcl_anti_oxidation_varient = "mcl_copper:block_weathered",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized") end,
})
minetest.register_node("mcl_copper:waxed_block_oxidized", {
@ -137,9 +122,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_copper_unwaxed_variant = "mcl_copper:block_weathered",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered") end,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered") end,
})
minetest.register_node("mcl_copper:block_cut", {
@ -151,9 +134,7 @@ minetest.register_node("mcl_copper:block_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_cut",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_cut") end,
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_cut") end,
})
minetest.register_node("mcl_copper:waxed_block_cut", {
@ -165,9 +146,7 @@ minetest.register_node("mcl_copper:waxed_block_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_copper_unwaxed_variant = "mcl_copper:block_cut",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end,
})
minetest.register_node("mcl_copper:block_exposed_cut", {
@ -179,10 +158,8 @@ minetest.register_node("mcl_copper:block_exposed_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_anti_oxidation_variant = "mcl_copper:block_cut",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed_cut") end,
_mcl_anti_oxidation_varient = "mcl_copper:block_cut",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed_cut") end,
})
minetest.register_node("mcl_copper:waxed_block_exposed_cut", {
@ -194,9 +171,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_copper_unwaxed_variant = "mcl_copper:block_cut",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end,
})
minetest.register_node("mcl_copper:block_weathered_cut", {
@ -208,10 +183,8 @@ minetest.register_node("mcl_copper:block_weathered_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_anti_oxidation_variant = "mcl_copper:block_exposed_cut",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered_cut") end,
_mcl_anti_oxidation_varient = "mcl_copper:block_exposed_cut",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered_cut") end,
})
minetest.register_node("mcl_copper:waxed_block_weathered_cut", {
@ -223,9 +196,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_copper_unwaxed_variant = "mcl_copper:block_exposed_cut",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed_cut") end,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed_cut") end,
})
minetest.register_node("mcl_copper:block_oxidized_cut", {
@ -237,10 +208,8 @@ minetest.register_node("mcl_copper:block_oxidized_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_anti_oxidation_variant = "mcl_copper:block_weathered_cut",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized_cut",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized_cut") end,
_mcl_anti_oxidation_varient = "mcl_copper:block_weathered_cut",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized_cut") end,
})
minetest.register_node("mcl_copper:waxed_block_oxidized_cut", {
@ -252,9 +221,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
_mcl_copper_unwaxed_variant = "mcl_copper:block_weathered_cut",
on_place = mcl_copper.on_place,
on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered_cut") end,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered_cut") end,
})
mcl_stairs.register_slab("copper_cut", "mcl_copper:block_cut",