Compare commits
5 Commits
07551bf142
...
5bcb419734
Author | SHA1 | Date |
---|---|---|
|
5bcb419734 | |
|
71e5397928 | |
|
cd0ccf85da | |
|
cfd74a5abd | |
|
625a2925f5 |
|
@ -2,28 +2,33 @@
|
|||
|
||||
mkdir referenced-mods
|
||||
cd referenced-mods/
|
||||
git clone https://github.com/minetest/minetest_game.git
|
||||
git clone https://github.com/minetest-technic/unified_inventory.git
|
||||
git clone https://github.com/bdjnk/mini_sun.git
|
||||
git clone https://github.com/Ezhh/under_sky.git
|
||||
git clone https://github.com/tenplus1/ethereal.git
|
||||
git clone https://github.com/orwell96/advtrains.git
|
||||
git clone https://github.com/Jeija/minetest-mod-mesecons.git
|
||||
git clone https://github.com/minetest/minetest_game
|
||||
git clone https://github.com/minetest-mods/unified_inventory
|
||||
git clone https://github.com/bdjnk/mini_sun
|
||||
git clone https://github.com/Ezhh/under_sky
|
||||
git clone https://notabug.org/TenPlus1/ethereal
|
||||
git clone https://github.com/orwell96/advtrains
|
||||
git clone https://github.com/Jeija/minetest-mod-mesecons
|
||||
git clone https://github.com/BlockMen/cme
|
||||
git clone https://github.com/duane-r/underworlds
|
||||
git clone https://github.com/saavedra29/archer
|
||||
git clone https://github.com/stujones11/minetest-3d_armor
|
||||
mv minetest-3d_armor/ 3d_armor/
|
||||
|
||||
mkdir octacian
|
||||
cd octacian
|
||||
git clone https://github.com/octacian/digicompute.git
|
||||
git clone https://github.com/octacian/datalib.git
|
||||
git clone https://github.com/octacian/microexpansion.git
|
||||
git clone https://github.com/octacian/digicompute
|
||||
git clone https://github.com/octacian/datalib
|
||||
git clone https://github.com/octacian/microexpansion
|
||||
|
||||
cd ..
|
||||
mkdir yawin
|
||||
cd yawin
|
||||
git clone https://gitlab.com/yawin/Mod_Magic.git
|
||||
git clone https://github.com/yawin123/utilities.git
|
||||
git clone https://gitlab.com/yawin/Mod_Magic
|
||||
git clone https://github.com/yawin123/utilities
|
||||
|
||||
cd ../../mods/
|
||||
rm -f advtrains beds boats bucket carts creative datalib default digicompute doors dye ethereal farming fire flowers give_initial_stuff killme microexpansion mini_sun Mod_Magic minetest-mod-mesecons Minetest-WorldEdit screwdriver sethome sfinv stairs tnt under_sky unified_inventory utilities vessels walls wool xpanes
|
||||
rm -f 3d_armor advtrains archer beds boats bucket carts cme creative datalib default digicompute doors dye ethereal farming fire flowers give_initial_stuff microexpansion mini_sun Mod_Magic minetest-mod-mesecons Minetest-WorldEdit player_api screwdriver sethome sfinv stairs tnt under_sky underworlds unified_inventory utilities vessels walls wool xpanes
|
||||
|
||||
ln -s ../referenced-mods/minetest_game/mods/beds/
|
||||
ln -s ../referenced-mods/minetest_game/mods/boats/
|
||||
|
@ -37,7 +42,7 @@ ln -s ../referenced-mods/minetest_game/mods/farming/
|
|||
ln -s ../referenced-mods/minetest_game/mods/fire/
|
||||
ln -s ../referenced-mods/minetest_game/mods/flowers/
|
||||
ln -s ../referenced-mods/minetest_game/mods/give_initial_stuff/
|
||||
ln -s ../referenced-mods/minetest_game/mods/killme/
|
||||
ln -s ../referenced-mods/minetest_game/mods/player_api/
|
||||
ln -s ../referenced-mods/minetest_game/mods/screwdriver/
|
||||
ln -s ../referenced-mods/minetest_game/mods/sethome/
|
||||
ln -s ../referenced-mods/minetest_game/mods/sfinv/
|
||||
|
@ -49,6 +54,10 @@ ln -s ../referenced-mods/minetest_game/mods/wool/
|
|||
ln -s ../referenced-mods/minetest_game/mods/xpanes/
|
||||
|
||||
ln -s ../referenced-mods/mini_sun/
|
||||
ln -s ../referenced-mods/3d_armor/
|
||||
ln -s ../referenced-mods/cme/
|
||||
ln -s ../referenced-mods/underworlds/
|
||||
ln -s ../referenced-mods/archer/
|
||||
|
||||
ln -s ../referenced-mods/advtrains/
|
||||
ln -s ../referenced-mods/ethereal/
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../referenced-mods/3d_armor/
|
|
@ -1,15 +0,0 @@
|
|||
[mod] Visible Player Armor [3d_armor]
|
||||
=====================================
|
||||
|
||||
depends: default, inventory_plus, unified_skins
|
||||
|
||||
Adds craftable armor that is visible to other players. Each armor item worn contibutes to
|
||||
a player's armor group level making them less vulnerable to weapons.
|
||||
|
||||
Armor takes damage when a player is hurt but also offers a percentage chance of healing.
|
||||
|
||||
default settings: [minetest.conf]
|
||||
|
||||
# Set number of seconds between armor updates.
|
||||
3d_armor_update_time = 1
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
-- Armor Configuration (defaults)
|
||||
|
||||
-- Increase this if you get initialization glitches when a player first joins.
|
||||
ARMOR_INIT_DELAY = 1
|
||||
|
||||
-- Number of initialization attempts.
|
||||
-- Use in conjunction with ARMOR_INIT_DELAY if initialization problems persist.
|
||||
ARMOR_INIT_TIMES = 1
|
||||
|
||||
-- Increase this if armor is not getting into bones due to server lag.
|
||||
ARMOR_BONES_DELAY = 1
|
||||
|
||||
-- How often player armor/wield items are updated.
|
||||
ARMOR_UPDATE_TIME = 1
|
||||
|
||||
-- Drop armor when a player dies.
|
||||
-- Uses bones mod if present, otherwise items are dropped around the player.
|
||||
ARMOR_DROP = true
|
||||
|
||||
-- Pulverise armor when a player dies, overrides ARMOR_DROP.
|
||||
ARMOR_DESTROY = false
|
||||
|
||||
-- You can use this to increase or decrease overall armor effectiveness,
|
||||
-- eg: ARMOR_LEVEL_MULTIPLIER = 0.5 will reduce armor level by half.
|
||||
ARMOR_LEVEL_MULTIPLIER = 1
|
||||
|
||||
-- You can use this to increase or decrease overall armor healing,
|
||||
-- eg: ARMOR_HEAL_MULTIPLIER = 0 will disable healing altogether.
|
||||
ARMOR_HEAL_MULTIPLIER = 1
|
||||
|
||||
-- You can also use this file to execute arbitary lua code
|
||||
-- eg: Dumb the armor down if using Simple Mobs
|
||||
if minetest.get_modpath("mobs") then
|
||||
ARMOR_LEVEL_MULTIPLIER = 0.5
|
||||
ARMOR_HEAL_MULTIPLIER = 0
|
||||
end
|
||||
|
|
@ -1,481 +0,0 @@
|
|||
ARMOR_INIT_DELAY = 1
|
||||
ARMOR_INIT_TIMES = 1
|
||||
ARMOR_BONES_DELAY = 1
|
||||
ARMOR_UPDATE_TIME = 1
|
||||
ARMOR_DROP = minetest.get_modpath("bones") ~= nil
|
||||
ARMOR_DESTROY = false
|
||||
ARMOR_LEVEL_MULTIPLIER = 1
|
||||
ARMOR_HEAL_MULTIPLIER = 1
|
||||
|
||||
local modpath = minetest.get_modpath(ARMOR_MOD_NAME)
|
||||
local worldpath = minetest.get_worldpath()
|
||||
local input = io.open(modpath.."/armor.conf", "r")
|
||||
if input then
|
||||
dofile(modpath.."/armor.conf")
|
||||
input:close()
|
||||
input = nil
|
||||
end
|
||||
input = io.open(worldpath.."/armor.conf", "r")
|
||||
if input then
|
||||
dofile(worldpath.."/armor.conf")
|
||||
input:close()
|
||||
input = nil
|
||||
end
|
||||
|
||||
local time = 0
|
||||
|
||||
armor = {
|
||||
player_hp = {},
|
||||
elements = {"head", "torso", "legs", "feet"},
|
||||
physics = {"jump","speed","gravity"},
|
||||
--[[formspec = "size[8,8.5]list[detached:player_name_armor;armor;0,1;2,3;]"
|
||||
.."image[2,0.75;2,4;armor_preview]"
|
||||
.."list[current_player;main;0,4.5;8,4;]"
|
||||
.."list[current_player;craft;4,1;3,3;]"
|
||||
.."list[current_player;craftpreview;7,2;1,1;]",]]
|
||||
textures = {},
|
||||
default_skin = "character",
|
||||
}
|
||||
|
||||
--[[if inventory_plus then
|
||||
armor.formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
|
||||
.."list[detached:player_name_armor;armor;0,1;2,3;]"
|
||||
.."image[2.5,0.75;2,4;armor_preview]"
|
||||
.."label[5,1;Level: armor_level]"
|
||||
.."label[5,1.5;Heal: armor_heal]"
|
||||
.."list[current_player;main;0,4.5;8,4;]"
|
||||
elseif unified_inventory then
|
||||
unified_inventory.register_button("armor", {
|
||||
type = "image",
|
||||
image = "inventory_plus_armor.png",
|
||||
})
|
||||
unified_inventory.register_page("armor", {
|
||||
get_formspec = function(player)
|
||||
local name = player:get_player_name()
|
||||
local formspec = "background[0.06,0.99;7.92,7.52;3d_armor_ui_form.png]"
|
||||
.."label[0,0;Armor]"
|
||||
.."list[detached:"..name.."_armor;armor;0,1;2,3;]"
|
||||
.."image[2.5,0.75;2,4;"..armor.textures[name].preview.."]"
|
||||
.."label[5,1;Level: "..armor.def[name].level.."]"
|
||||
.."label[5,1.5;Heal: "..armor.def[name].heal.."]"
|
||||
return {formspec=formspec}
|
||||
end,
|
||||
})
|
||||
end]]
|
||||
|
||||
armor.def = {
|
||||
state = 0,
|
||||
count = 0,
|
||||
}
|
||||
|
||||
armor.update_player_visuals = function(self, player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
if self.textures[name] then
|
||||
default.player_set_textures(player, {
|
||||
self.textures[name].skin,
|
||||
self.textures[name].armor,
|
||||
self.textures[name].wielditem,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
armor.set_player_armor = function(self, player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
local player_inv = player:get_inventory()
|
||||
if not name then
|
||||
minetest.log("error", "Failed to read player name")
|
||||
return
|
||||
elseif not player_inv then
|
||||
minetest.log("error", "Failed to read player inventory")
|
||||
return
|
||||
end
|
||||
local armor_texture = "3d_armor_trans.png"
|
||||
local armor_level = 0
|
||||
local armor_heal = 0
|
||||
local state = 0
|
||||
local items = 0
|
||||
local elements = {}
|
||||
local textures = {}
|
||||
local physics_o = {speed=1,gravity=1,jump=1}
|
||||
local material = {type=nil, count=1}
|
||||
--local preview = armor:get_player_skin(name).."_preview.png"
|
||||
for _,v in ipairs(self.elements) do
|
||||
elements[v] = false
|
||||
end
|
||||
for i=1, 4 do
|
||||
local stack = player_inv:get_stack("armor", i)
|
||||
local item = stack:get_name()
|
||||
if stack:get_count() == 1 then
|
||||
local def = stack:get_definition()
|
||||
for k, v in pairs(elements) do
|
||||
if v == false then
|
||||
local level = def.groups["armor_"..k]
|
||||
if level then
|
||||
local texture = item:gsub("%:", "_")
|
||||
table.insert(textures, texture..".png")
|
||||
--preview = preview.."^"..texture.."_preview.png"
|
||||
armor_level = armor_level + level
|
||||
state = state + stack:get_wear()
|
||||
items = items + 1
|
||||
local heal = def.groups["armor_heal"] or 0
|
||||
armor_heal = armor_heal + heal
|
||||
for kk,vv in ipairs(self.physics) do
|
||||
local o_value = def.groups["physics_"..vv]
|
||||
if o_value then
|
||||
physics_o[vv] = physics_o[vv] + o_value
|
||||
end
|
||||
end
|
||||
local mat = string.match(item, "%:.+_(.+)$")
|
||||
if material.type then
|
||||
if material.type == mat then
|
||||
material.count = material.count + 1
|
||||
end
|
||||
else
|
||||
material.type = mat
|
||||
end
|
||||
elements[k] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--[[if minetest.get_modpath("shields") then
|
||||
armor_level = armor_level * 0.9
|
||||
end]]
|
||||
if material.type and material.count == #self.elements then
|
||||
armor_level = armor_level * 1.1
|
||||
end
|
||||
armor_level = armor_level * ARMOR_LEVEL_MULTIPLIER
|
||||
armor_heal = armor_heal * ARMOR_HEAL_MULTIPLIER
|
||||
if #textures > 0 then
|
||||
armor_texture = table.concat(textures, "^")
|
||||
end
|
||||
local armor_groups = {fleshy=100}
|
||||
if armor_level > 0 then
|
||||
armor_groups.level = math.floor(armor_level / 20)
|
||||
armor_groups.fleshy = 100 - armor_level
|
||||
end
|
||||
player:set_armor_groups(armor_groups)
|
||||
player:set_physics_override(physics_o)
|
||||
self.textures[name].armor = armor_texture
|
||||
--self.textures[name].preview = preview
|
||||
self.def[name].state = state
|
||||
self.def[name].count = items
|
||||
self.def[name].level = armor_level
|
||||
self.def[name].heal = armor_heal
|
||||
self.def[name].jump = physics_o.jump
|
||||
self.def[name].speed = physics_o.speed
|
||||
self.def[name].gravity = physics_o.gravity
|
||||
self:update_player_visuals(player)
|
||||
end
|
||||
|
||||
armor.update_armor = function(self, player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
local hp = player:get_hp() or 0
|
||||
if hp == 0 or hp == self.player_hp[name] then
|
||||
return
|
||||
end
|
||||
if self.player_hp[name] > hp then
|
||||
local player_inv = player:get_inventory()
|
||||
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
|
||||
if not player_inv then
|
||||
minetest.log("error", "Failed to read player inventory")
|
||||
return
|
||||
elseif not armor_inv then
|
||||
minetest.log("error", "Failed to read detached inventory")
|
||||
return
|
||||
end
|
||||
local heal_max = 0
|
||||
local state = 0
|
||||
local items = 0
|
||||
for i=1, 6 do
|
||||
local stack = player_inv:get_stack("armor", i)
|
||||
if stack:get_count() > 0 then
|
||||
local use = stack:get_definition().groups["armor_use"] or 0
|
||||
local heal = stack:get_definition().groups["armor_heal"] or 0
|
||||
local item = stack:get_name()
|
||||
stack:add_wear(use)
|
||||
armor_inv:set_stack("armor", i, stack)
|
||||
player_inv:set_stack("armor", i, stack)
|
||||
state = state + stack:get_wear()
|
||||
items = items + 1
|
||||
if stack:get_count() == 0 then
|
||||
local desc = minetest.registered_items[item].description
|
||||
if desc then
|
||||
minetest.chat_send_player(name, "Your "..desc.." got destroyed!")
|
||||
end
|
||||
self:set_player_armor(player)
|
||||
armor:update_inventory(player)
|
||||
end
|
||||
heal_max = heal_max + heal
|
||||
end
|
||||
end
|
||||
self.def[name].state = state
|
||||
self.def[name].count = items
|
||||
heal_max = heal_max * ARMOR_HEAL_MULTIPLIER
|
||||
if heal_max > math.random(100) then
|
||||
player:set_hp(self.player_hp[name])
|
||||
return
|
||||
end
|
||||
end
|
||||
self.player_hp[name] = hp
|
||||
end
|
||||
|
||||
armor.get_player_skin = function(self, name)
|
||||
local skin = nil
|
||||
if skins then
|
||||
skin = skins.skins[name]
|
||||
elseif u_skins then
|
||||
skin = u_skins.u_skins[name]
|
||||
end
|
||||
return skin or armor.default_skin
|
||||
end
|
||||
|
||||
armor.get_armor_formspec = function(self, name)
|
||||
local formspec = armor.formspec:gsub("player_name", name)
|
||||
--formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
|
||||
formspec = formspec:gsub("armor_level", armor.def[name].level)
|
||||
return formspec:gsub("armor_heal", armor.def[name].heal)
|
||||
end
|
||||
|
||||
--[[armor.update_inventory = function(self, player)
|
||||
local name = player:get_player_name()
|
||||
if unified_inventory then
|
||||
if unified_inventory.current_page[name] == "armor" then
|
||||
unified_inventory.set_inventory_formspec(player, "armor")
|
||||
end
|
||||
else
|
||||
local formspec = armor:get_armor_formspec(name)
|
||||
if inventory_plus then
|
||||
local page = player:get_inventory_formspec()
|
||||
if page:find("detached:"..name.."_armor") then
|
||||
inventory_plus.set_inventory_formspec(player, formspec)
|
||||
end
|
||||
else
|
||||
player:set_inventory_formspec(formspec)
|
||||
end
|
||||
end
|
||||
end]]
|
||||
|
||||
-- Register Player Model
|
||||
|
||||
default.player_register_model("3d_armor_character.x", {
|
||||
animation_speed = 30,
|
||||
textures = {
|
||||
armor.default_skin..".png",
|
||||
"3d_armor_trans.png",
|
||||
"3d_armor_trans.png",
|
||||
},
|
||||
animations = {
|
||||
stand = {x=0, y=79},
|
||||
lay = {x=162, y=166},
|
||||
walk = {x=168, y=187},
|
||||
mine = {x=189, y=198},
|
||||
walk_mine = {x=200, y=219},
|
||||
sit = {x=81, y=160},
|
||||
},
|
||||
})
|
||||
|
||||
-- Register Callbacks
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local name = player:get_player_name()
|
||||
if inventory_plus and fields.armor then
|
||||
local formspec = armor:get_armor_formspec(name)
|
||||
inventory_plus.set_inventory_formspec(player, formspec)
|
||||
return
|
||||
end
|
||||
for field, _ in pairs(fields) do
|
||||
if string.find(field, "skins_set_") then
|
||||
minetest.after(0, function(player)
|
||||
local skin = armor:get_player_skin(name)
|
||||
armor.textures[name].skin = skin..".png"
|
||||
armor:set_player_armor(player)
|
||||
end, player)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
default.player_set_model(player, "3d_armor_character.x")
|
||||
local name = player:get_player_name()
|
||||
local player_inv = player:get_inventory()
|
||||
local armor_inv = minetest.create_detached_inventory(name.."_armor",{
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, stack)
|
||||
armor:set_player_armor(player)
|
||||
--armor:update_inventory(player)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, nil)
|
||||
armor:set_player_armor(player)
|
||||
--armor:update_inventory(player)
|
||||
end,
|
||||
on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
local plaver_inv = player:get_inventory()
|
||||
local stack = inv:get_stack(to_list, to_index)
|
||||
player_inv:set_stack(to_list, to_index, stack)
|
||||
player_inv:set_stack(from_list, from_index, nil)
|
||||
armor:set_player_armor(player)
|
||||
--armor:update_inventory(player)
|
||||
end,
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
return 1
|
||||
end,
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
return count
|
||||
end,
|
||||
})
|
||||
--[[if inventory_plus then
|
||||
inventory_plus.register_button(player,"armor", "Armor")
|
||||
end]]
|
||||
armor_inv:set_size("armor", 4)
|
||||
player_inv:set_size("armor", 4)
|
||||
for i=1, 4 do
|
||||
local stack = player_inv:get_stack("armor", i)
|
||||
armor_inv:set_stack("armor", i, stack)
|
||||
end
|
||||
|
||||
-- Legacy support, import player's armor from old inventory format
|
||||
for _,v in pairs(armor.elements) do
|
||||
local list = "armor_"..v
|
||||
armor_inv:add_item("armor", player_inv:get_stack(list, 1))
|
||||
player_inv:set_stack(list, 1, nil)
|
||||
end
|
||||
|
||||
armor.player_hp[name] = 0
|
||||
armor.def[name] = {
|
||||
state = 0,
|
||||
count = 0,
|
||||
level = 0,
|
||||
heal = 0,
|
||||
jump = 1,
|
||||
speed = 1,
|
||||
gravity = 1,
|
||||
}
|
||||
armor.textures[name] = {
|
||||
skin = armor.default_skin..".png",
|
||||
armor = "3d_armor_trans.png",
|
||||
wielditem = "3d_armor_trans.png",
|
||||
preview = armor.default_skin.."_preview.png",
|
||||
}
|
||||
if minetest.get_modpath("skins") then
|
||||
local skin = skins.skins[name]
|
||||
if skin and skins.get_type(skin) == skins.type.MODEL then
|
||||
armor.textures[name].skin = skin..".png"
|
||||
end
|
||||
elseif minetest.get_modpath("simple_skins") then
|
||||
local skin = skins.skins[name]
|
||||
if skin then
|
||||
armor.textures[name].skin = skin..".png"
|
||||
end
|
||||
--[[elseif minetest.get_modpath("u_skins") then
|
||||
local skin = u_skins.u_skins[name]
|
||||
if skin and u_skins.get_type(skin) == u_skins.type.MODEL then
|
||||
armor.textures[name].skin = skin..".png"
|
||||
end]]
|
||||
end
|
||||
if minetest.get_modpath("player_textures") then
|
||||
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
|
||||
local f = io.open(filename..".png")
|
||||
if f then
|
||||
f:close()
|
||||
armor.textures[name].skin = "player_"..name..".png"
|
||||
end
|
||||
end
|
||||
for i=1, ARMOR_INIT_TIMES do
|
||||
minetest.after(ARMOR_INIT_DELAY * i, function(player)
|
||||
armor:set_player_armor(player)
|
||||
if inventory_plus == nil and unified_inventory == nil then
|
||||
--armor:update_inventory(player)
|
||||
end
|
||||
end, player)
|
||||
end
|
||||
end)
|
||||
|
||||
if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local pos = player:getpos()
|
||||
if name and pos then
|
||||
local drop = {}
|
||||
local player_inv = player:get_inventory()
|
||||
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
|
||||
for i=1, player_inv:get_size("armor") do
|
||||
local stack = armor_inv:get_stack("armor", i)
|
||||
if stack:get_count() > 0 then
|
||||
table.insert(drop, stack)
|
||||
armor_inv:set_stack("armor", i, nil)
|
||||
player_inv:set_stack("armor", i, nil)
|
||||
end
|
||||
end
|
||||
armor:set_player_armor(player)
|
||||
--[[if unified_inventory then
|
||||
unified_inventory.set_inventory_formspec(player, "craft")
|
||||
elseif inventory_plus then
|
||||
local formspec = inventory_plus.get_formspec(player,"main")
|
||||
inventory_plus.set_inventory_formspec(player, formspec)
|
||||
else
|
||||
armor:update_inventory(player)
|
||||
end]]
|
||||
if ARMOR_DESTROY == false then
|
||||
if minetest.get_modpath("bones") then
|
||||
minetest.after(ARMOR_BONES_DELAY, function()
|
||||
pos = vector.round(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == "bones:bones" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
local inv = meta:get_inventory()
|
||||
if name == owner then
|
||||
for _,stack in ipairs(drop) do
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
for _,stack in ipairs(drop) do
|
||||
local obj = minetest.add_item(pos, stack)
|
||||
if obj then
|
||||
local x = math.random(1, 5)
|
||||
if math.random(1,2) == 1 then
|
||||
x = -x
|
||||
end
|
||||
local z = math.random(1, 5)
|
||||
if math.random(1,2) == 1 then
|
||||
z = -z
|
||||
end
|
||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
time = time + dtime
|
||||
if time > ARMOR_UPDATE_TIME then
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
armor:update_armor(player)
|
||||
end
|
||||
time = 0
|
||||
end
|
||||
end)
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
3d_armor -- Crafting Guide
|
||||
--------------------------
|
||||
|
||||
Helmets:
|
||||
|
||||
+---+---+---+
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
| | | |
|
||||
+---+---+---+
|
||||
|
||||
[3d_armor:helmet_wood] X = [default:wood]
|
||||
[3d_armor:helmet_steel] X = [default:steel_ingot]
|
||||
[3d_armor:helmet_bronze] X = [default:bronze_ingot]
|
||||
[3d_armor:helmet_diamond] X = [default:diamond]
|
||||
|
||||
Chestplates:
|
||||
|
||||
+---+---+---+
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
|
||||
[3d_armor:chestplate_wood] X = [default:wood]
|
||||
[3d_armor:chestplate_steel] X = [default:steel_ingot]
|
||||
[3d_armor:chestplate_bronze] X = [default:bronze_ingot]
|
||||
[3d_armor:chestplate_diamond] X = [default:diamond]
|
||||
|
||||
Leggings:
|
||||
|
||||
+---+---+---+
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
|
||||
[3d_armor:leggings_wood] X = [default:wood]
|
||||
[3d_armor:leggings_steel] X = [default:steel_ingot]
|
||||
[3d_armor:leggings_bronze] X = [default:bronze_ingot]
|
||||
[3d_armor:leggings_diamond] X = [default:diamond]
|
||||
|
||||
Boots:
|
||||
|
||||
+---+---+---+
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
|
||||
[3d_armor:boots_wood] X = [default:wood]
|
||||
[3d_armor:boots_steel] X = [default:steel_ingot]
|
||||
[3d_armor:boots_bronze] X = [default:bronze_ingot
|
||||
[3d_armor:boots_diamond] X = [default:diamond]
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
default
|
||||
|
|
@ -1,195 +0,0 @@
|
|||
ARMOR_MOD_NAME = minetest.get_current_modname()
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua")
|
||||
|
||||
-- Regisiter Head Armor
|
||||
|
||||
minetest.register_tool("3d_armor:helmet_leather", {
|
||||
description = "Leather Helmet",
|
||||
inventory_image = "3d_armor_inv_helmet_leather.png",
|
||||
groups = {armor_head=5, armor_heal=0, armor_use=100},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:helmet_steel", {
|
||||
description = "Steel Helmet",
|
||||
inventory_image = "3d_armor_inv_helmet_steel.png",
|
||||
groups = {armor_head=10, armor_heal=5, armor_use=250},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:helmet_gold", {
|
||||
description = "Golden Helmet",
|
||||
inventory_image = "3d_armor_inv_helmet_gold.png",
|
||||
groups = {armor_head=15, armor_heal=10, armor_use=500},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:helmet_diamond",{
|
||||
description = "Diamond Helmet",
|
||||
inventory_image = "3d_armor_inv_helmet_diamond.png",
|
||||
groups = {armor_head=20, armor_heal=15, armor_use=750},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:helmet_chain", {
|
||||
description = "Chain Helmet",
|
||||
inventory_image = "3d_armor_inv_helmet_chain.png",
|
||||
groups = {armor_head=15, armor_heal=10, armor_use=500},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
-- Regisiter Torso Armor
|
||||
|
||||
minetest.register_tool("3d_armor:chestplate_leather", {
|
||||
description = "Leather Chestplate",
|
||||
inventory_image = "3d_armor_inv_chestplate_leather.png",
|
||||
groups = {armor_torso=15, armor_heal=0, armor_use=100},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:chestplate_steel", {
|
||||
description = "Steel Chestplate",
|
||||
inventory_image = "3d_armor_inv_chestplate_steel.png",
|
||||
groups = {armor_torso=20, armor_heal=5, armor_use=250},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:chestplate_gold", {
|
||||
description = "Golden Chestplate",
|
||||
inventory_image = "3d_armor_inv_chestplate_gold.png",
|
||||
groups = {armor_torso=25, armor_heal=10, armor_use=500},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:chestplate_diamond",{
|
||||
description = "Diamond Helmet",
|
||||
inventory_image = "3d_armor_inv_chestplate_diamond.png",
|
||||
groups = {armor_torso=30, armor_heal=15, armor_use=750},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:chestplate_chain", {
|
||||
description = "Chain Chestplate",
|
||||
inventory_image = "3d_armor_inv_chestplate_chain.png",
|
||||
groups = {armor_torso=25, armor_heal=10, armor_use=500},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
-- Regisiter Leg Armor
|
||||
|
||||
minetest.register_tool("3d_armor:leggings_leather", {
|
||||
description = "Leather Leggings",
|
||||
inventory_image = "3d_armor_inv_leggings_leather.png",
|
||||
groups = {armor_legs=10, armor_heal=0, armor_use=100},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:leggings_steel", {
|
||||
description = "Steel Leggings",
|
||||
inventory_image = "3d_armor_inv_leggings_steel.png",
|
||||
groups = {armor_legs=15, armor_heal=5, armor_use=250},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:leggings_gold", {
|
||||
description = "Golden Leggings",
|
||||
inventory_image = "3d_armor_inv_leggings_gold.png",
|
||||
groups = {armor_legs=20, armor_heal=10, armor_use=500},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:leggings_diamond",{
|
||||
description = "Diamond Helmet",
|
||||
inventory_image = "3d_armor_inv_leggings_diamond.png",
|
||||
groups = {armor_legs=25, armor_heal=15, armor_use=750},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:leggings_chain", {
|
||||
description = "Chain Leggings",
|
||||
inventory_image = "3d_armor_inv_leggings_chain.png",
|
||||
groups = {armor_legs=20, armor_heal=10, armor_use=500},
|
||||
wear = 0,
|
||||
})
|
||||
-- Regisiter Boots
|
||||
|
||||
minetest.register_tool("3d_armor:boots_leather", {
|
||||
description = "Leather Boots",
|
||||
inventory_image = "3d_armor_inv_boots_leather.png",
|
||||
groups = {armor_feet=5, armor_heal=0, armor_use=100},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:boots_steel", {
|
||||
description = "Steel Boots",
|
||||
inventory_image = "3d_armor_inv_boots_steel.png",
|
||||
groups = {armor_feet=10, armor_heal=5, armor_use=250},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:boots_gold", {
|
||||
description = "Golden Boots",
|
||||
inventory_image = "3d_armor_inv_boots_gold.png",
|
||||
groups = {armor_feet=15, armor_heal=10, armor_use=500},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:boots_diamond",{
|
||||
description = "Diamond Helmet",
|
||||
inventory_image = "3d_armor_inv_boots_diamond.png",
|
||||
groups = {armor_feet=20, armor_heal=15, armor_use=750},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:boots_chain", {
|
||||
description = "Chain Boots",
|
||||
inventory_image = "3d_armor_inv_boots_chain.png",
|
||||
groups = {armor_feet=15, armor_heal=10, armor_use=500},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
-- Register Craft Recipies
|
||||
|
||||
local craft_ingreds = {
|
||||
leather = "default:wood",
|
||||
steel = "default:steel_ingot",
|
||||
gold = "default:gold_ingot",
|
||||
diamond = "default:diamond",
|
||||
chain = "fire:fire",
|
||||
}
|
||||
|
||||
for k, v in pairs(craft_ingreds) do
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:helmet_"..k,
|
||||
recipe = {
|
||||
{v, v, v},
|
||||
{v, "", v},
|
||||
{"", "", ""},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:chestplate_"..k,
|
||||
recipe = {
|
||||
{v, "", v},
|
||||
{v, v, v},
|
||||
{v, v, v},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:leggings_"..k,
|
||||
recipe = {
|
||||
{v, v, v},
|
||||
{v, "", v},
|
||||
{v, "", v},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:boots_"..k,
|
||||
recipe = {
|
||||
{v, "", v},
|
||||
{v, "", v},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
[Dolphin]
|
||||
PreviewsShown=true
|
||||
Timestamp=2016,12,29,21,12,41
|
||||
Version=3
|
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 643 B |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 275 B |
Before Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 433 B |
Before Width: | Height: | Size: 241 B |
Before Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 472 B |
Before Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 341 B |
Before Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 197 B |
Before Width: | Height: | Size: 197 B |
Before Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 191 B |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 146 B |
|
@ -1,7 +0,0 @@
|
|||
3D Armor - Visible Player Armor
|
||||
===============================
|
||||
|
||||
Source Code: Copyright (C) 2013 Stuart Jones - LGPL
|
||||
|
||||
Special credit to Jordach and MirceaKitsune for providing the default 3d character model.
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
Modpack - 3d Armor
|
||||
==================
|
||||
|
||||
[mod] Unified Skins [unified_skins]
|
||||
-----------------------------------
|
||||
|
||||
depends: default
|
||||
|
||||
A 3d character model re-texturing api used as the framework for this modpack.
|
||||
|
||||
Compatible with player skins mod [skins] by Zeg9 and Player Textures [player_textures] by sdzen.
|
||||
|
||||
Note: Currently only supports 64x32px player skins.
|
||||
|
||||
[mod] Visible Wielded Items [wieldview]
|
||||
---------------------------------------
|
||||
|
||||
depends: unified_skins
|
||||
|
||||
Makes hand wielded items visible to other players.
|
||||
|
||||
Note: Currently only supports 16x16px texture packs, sorry!
|
||||
|
||||
[mod] Visible Player Armor [3d_armor]
|
||||
-------------------------------------
|
||||
|
||||
depends: unified_skins, inventory_plus
|
||||
|
||||
Adds craftable armor that is visible to other players. Each armor item worn contributes to
|
||||
a player's armor group level making them less vulnerable to weapons.
|
||||
|
||||
Armor takes damage when a player is hurt, however, many armor items offer a 'stackable'
|
||||
percentage chance of restoring the lost health points.
|
||||
|
||||
[mod] Shields [shields]
|
||||
-------------------------------------
|
||||
|
||||
depends: 3d_armor
|
||||
|
||||
Originally a part of 3d_armor, shields have been re-included as an optional extra.
|
||||
If you do not want shields then simply remove the shields folder from the modpack.
|
|
@ -1,7 +0,0 @@
|
|||
A 3d character model re-texturing api used as the framework for this modpack.
|
||||
|
||||
depends: default
|
||||
|
||||
Compatible with player skins mod [skins] by Zeg9 and Player Textures [player_textures] by sdzen.
|
||||
|
||||
Note: Currently only 64x32px player skins.
|
|
@ -1 +0,0 @@
|
|||
default
|
|
@ -1,47 +0,0 @@
|
|||
--[[
|
||||
uniskins = {
|
||||
skin = {},
|
||||
armor = {},
|
||||
wielditem = {},
|
||||
default_skin = "character.png",
|
||||
default_texture = "uniskins_trans.png",
|
||||
}
|
||||
|
||||
uniskins.update_player_visuals = function(self, player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
player:set_properties({
|
||||
visual = "mesh",
|
||||
mesh = "uniskins_character.x",
|
||||
textures = {
|
||||
self.skin[name],
|
||||
self.armor[name],
|
||||
self.wielditem[name]
|
||||
},
|
||||
visual_size = {x=1, y=1},
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
uniskins.skin[name] = uniskins.default_skin
|
||||
uniskins.armor[name] = uniskins.default_texture
|
||||
uniskins.wielditem[name] = uniskins.default_texture
|
||||
if minetest.get_modpath("player_textures") then
|
||||
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
|
||||
local f = io.open(filename..".png")
|
||||
if f then
|
||||
f:close()
|
||||
uniskins.skin[name] = "player_"..name..".png"
|
||||
end
|
||||
end
|
||||
if minetest.get_modpath("skins") then
|
||||
local skin = skins.skins[name]
|
||||
if skin and skins.get_type(skin) == skins.type.MODEL then
|
||||
uniskins.skin[name] = skin..".png"
|
||||
end
|
||||
end
|
||||
end)
|
||||
]]
|
|
@ -1,4 +0,0 @@
|
|||
[Dolphin]
|
||||
PreviewsShown=true
|
||||
Timestamp=2016,12,29,21,12,52
|
||||
Version=3
|
Before Width: | Height: | Size: 146 B |
|
@ -1,17 +0,0 @@
|
|||
[mod] visible wielded items [wieldview]
|
||||
=======================================
|
||||
|
||||
depends: default, unified_skins
|
||||
|
||||
Makes hand wielded items visible to other players. Compatible with player skins mod [skins].
|
||||
|
||||
Note: Currently only supports 16x16px texture packs, sorry!
|
||||
|
||||
default settings: [minetest.conf]
|
||||
|
||||
# Set number of seconds between visible wielded item updates.
|
||||
wieldview_update_time = 2
|
||||
|
||||
# Show nodes as tiles, disabled by default
|
||||
wieldview_node_tiles = false
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
default
|
||||
3d_armor
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
local time = 0
|
||||
local update_time = tonumber(minetest.setting_get("wieldview_update_time"))
|
||||
if not update_time then
|
||||
update_time = 2
|
||||
minetest.setting_set("wieldview_update_time", tostring(update_time))
|
||||
end
|
||||
local node_tiles = minetest.setting_getbool("wieldview_node_tiles")
|
||||
if not node_tiles then
|
||||
node_tiles = false
|
||||
minetest.setting_set("wieldview_node_tiles", "false")
|
||||
end
|
||||
|
||||
wieldview = {
|
||||
wielded_item = {},
|
||||
transform = {},
|
||||
}
|
||||
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua")
|
||||
|
||||
wieldview.get_item_texture = function(self, item)
|
||||
local texture = "3d_armor_trans.png"
|
||||
if item ~= "" then
|
||||
if minetest.registered_items[item] then
|
||||
local inventory_image = minetest.registered_items[item].inventory_image
|
||||
if inventory_image and inventory_image ~= "" then
|
||||
texture = inventory_image
|
||||
elseif node_tiles == true and minetest.registered_items[item].tiles then
|
||||
texture = minetest.registered_items[item].tiles[1]
|
||||
end
|
||||
end
|
||||
if wieldview.transform[item] then
|
||||
texture = texture.."^[transform"..wieldview.transform[item]
|
||||
end
|
||||
end
|
||||
return texture
|
||||
end
|
||||
|
||||
wieldview.update_wielded_item = function(self, player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
local stack = player:get_wielded_item()
|
||||
local item = stack:get_name()
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
if self.wielded_item[name] then
|
||||
if self.wielded_item[name] == item then
|
||||
return
|
||||
end
|
||||
armor.textures[name].wielditem = self:get_item_texture(item)
|
||||
armor:update_player_visuals(player)
|
||||
end
|
||||
self.wielded_item[name] = item
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
wieldview.wielded_item[name] = ""
|
||||
minetest.after(0, function(player)
|
||||
wieldview:update_wielded_item(player)
|
||||
end, player)
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
time = time + dtime
|
||||
if time > update_time then
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
wieldview:update_wielded_item(player)
|
||||
end
|
||||
time = 0
|
||||
end
|
||||
end)
|
|
@ -1,24 +0,0 @@
|
|||
-- Wielded Item Transformations - http://dev.minetest.net/texture
|
||||
|
||||
wieldview_transform = {
|
||||
["default:torch"]="R270",
|
||||
["default:sapling"]="R270",
|
||||
["flowers:dandelion_white"]="R270",
|
||||
["flowers:dandelion_yellow"]="R270",
|
||||
["flowers:geranium"]="R270",
|
||||
["flowers:rose"]="R270",
|
||||
["flowers:tulip"]="R270",
|
||||
["flowers:viola"]="R270",
|
||||
["bucket:bucket_empty"]="R270",
|
||||
["bucket:bucket_water"]="R270",
|
||||
["bucket:bucket_lava"]="R270",
|
||||
["screwdriver:screwdriver"]="R270",
|
||||
["screwdriver:screwdriver1"]="R270",
|
||||
["screwdriver:screwdriver2"]="R270",
|
||||
["screwdriver:screwdriver3"]="R270",
|
||||
["screwdriver:screwdriver4"]="R270",
|
||||
["vessels:glass_bottle"]="R270",
|
||||
["vessels:drinking_glass"]="R270",
|
||||
["vessels:steel_bottle"]="R270",
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
/home/yawin/.minetest/mods/Minetest-WorldEdit
|
|
@ -0,0 +1 @@
|
|||
../referenced-mods/archer/
|
|
@ -1 +0,0 @@
|
|||
../referenced-mods/minetest_game/mods/killme/
|
|
@ -1,3 +0,0 @@
|
|||
[Dolphin]
|
||||
Timestamp=2016,12,30,19,32,26
|
||||
Version=3
|
|
@ -1,24 +0,0 @@
|
|||
Nether Mod for Minetest
|
||||
|
||||
##License of source code:
|
||||
|
||||
Copyright (C) 2013 PilzAdam
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
##License of media (textures and sounds)
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
##Authors of media files
|
||||
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2013 PilzAdam
|
||||
|
||||
nether_rack.png: Zeg9
|
||||
nether_glowstone.png: BlockMen
|
|
@ -1,6 +0,0 @@
|
|||
stairs
|
||||
default
|
||||
fire
|
||||
quartz
|
||||
default_override
|
||||
moreblocks?
|
|
@ -1 +0,0 @@
|
|||
Adds a deep underground realm with different mapgen that you can reach with obsidian portals.
|
|
@ -1,683 +0,0 @@
|
|||
-- Parameters
|
||||
|
||||
local NETHER_DEPTH = -5000
|
||||
local TCAVE = 0.6
|
||||
local BLEND = 128
|
||||
|
||||
|
||||
-- 3D noise
|
||||
|
||||
local np_cave = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x = 384, y = 128, z = 384}, -- squashed 3:1
|
||||
seed = 59033,
|
||||
octaves = 5,
|
||||
persist = 0.7
|
||||
}
|
||||
|
||||
|
||||
-- Stuff
|
||||
|
||||
local yblmax = NETHER_DEPTH - BLEND * 2
|
||||
|
||||
|
||||
-- Functions
|
||||
|
||||
local function build_portal(pos, target)
|
||||
local p1 = {x = pos.x - 1, y = pos.y - 1, z = pos.z}
|
||||
local p2 = {x = p1.x + 3, y = p1.y + 4, z = p1.z}
|
||||
|
||||
local path = minetest.get_modpath("nether") .. "/schematics/nether_portal.mts"
|
||||
minetest.place_schematic({x = p1.x, y = p1.y, z = p1.z - 2}, path, 0, nil, true)
|
||||
|
||||
for y = p1.y, p2.y do
|
||||
for x = p1.x, p2.x do
|
||||
local meta = minetest.get_meta({x = x, y = y, z = p1.z})
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
local function volume_is_natural(minp, maxp)
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_ignore = minetest.get_content_id("ignore")
|
||||
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local pos1 = {x = minp.x, y = minp.y, z = minp.z}
|
||||
local pos2 = {x = maxp.x, y = maxp.y, z = maxp.z}
|
||||
local emin, emax = vm:read_from_map(pos1, pos2)
|
||||
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
|
||||
local data = vm:get_data()
|
||||
|
||||
for z = pos1.z, pos2.z do
|
||||
for y = pos1.y, pos2.y do
|
||||
local vi = area:index(pos1.x, y, z)
|
||||
for x = pos1.x, pos2.x do
|
||||
local id = data[vi] -- Existing node
|
||||
if id ~= c_air and id ~= c_ignore then -- These are natural
|
||||
local name = minetest.get_name_from_content_id(id)
|
||||
if not minetest.registered_nodes[name].is_ground_content then
|
||||
return false
|
||||
end
|
||||
end
|
||||
vi = vi + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local function find_nether_target_y(target_x, target_z, start_y)
|
||||
local nobj_cave_point = minetest.get_perlin(np_cave)
|
||||
local air = 0 -- Consecutive air nodes found
|
||||
|
||||
for y = start_y, start_y - 4096, -1 do
|
||||
local nval_cave = nobj_cave_point:get3d({x = target_x, y = y, z = target_z})
|
||||
|
||||
if nval_cave > TCAVE then -- Cavern
|
||||
air = air + 1
|
||||
else -- Not cavern, check if 4 nodes of space above
|
||||
if air >= 4 then
|
||||
-- Check volume for non-natural nodes
|
||||
local minp = {x = target_x - 1, y = y - 1, z = target_z - 2}
|
||||
local maxp = {x = target_x + 2, y = y + 3, z = target_z + 2}
|
||||
if volume_is_natural(minp, maxp) then
|
||||
return y + 2
|
||||
else -- Restart search a little lower
|
||||
find_nether_target_y(target_x, target_z, y - 16)
|
||||
end
|
||||
else -- Not enough space, reset air to zero
|
||||
air = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return start_y -- Fallback
|
||||
end
|
||||
|
||||
|
||||
local function find_surface_target_y(target_x, target_z, start_y)
|
||||
for y = start_y, start_y - 256, -16 do
|
||||
-- Check volume for non-natural nodes
|
||||
local minp = {x = target_x - 1, y = y - 1, z = target_z - 2}
|
||||
local maxp = {x = target_x + 2, y = y + 3, z = target_z + 2}
|
||||
if volume_is_natural(minp, maxp) then
|
||||
return y
|
||||
end
|
||||
end
|
||||
|
||||
return y -- Fallback
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
local function make_portal(pos)
|
||||
local p1, p2 = is_portal(pos)
|
||||
if not p1 or not p2 then
|
||||
return false
|
||||
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 target.y < NETHER_DEPTH then
|
||||
target.y = find_surface_target_y(target.x, target.z, -16)
|
||||
else
|
||||
local start_y = NETHER_DEPTH - math.random(500, 1500) -- Search start
|
||||
target.y = find_nether_target_y(target.x, target.z, start_y)
|
||||
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
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
-- ABMs
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"nether:portal"},
|
||||
interval = 1,
|
||||
chance = 2,
|
||||
action = function(pos, node)
|
||||
minetest.add_particlespawner(
|
||||
32, --amount
|
||||
4, --time
|
||||
{x = pos.x - 0.25, y = pos.y - 0.25, z = pos.z - 0.25}, --minpos
|
||||
{x = pos.x + 0.25, y = pos.y + 0.25, z = pos.z + 0.25}, --maxpos
|
||||
{x = -0.8, y = -0.8, z = -0.8}, --minvel
|
||||
{x = 0.8, y = 0.8, z = 0.8}, --maxvel
|
||||
{x = 0, y = 0, z = 0}, --minacc
|
||||
{x = 0, y = 0, z = 0}, --maxacc
|
||||
0.5, --minexptime
|
||||
1, --maxexptime
|
||||
1, --minsize
|
||||
2, --maxsize
|
||||
false, --collisiondetection
|
||||
"nether_particle.png" --texture
|
||||
)
|
||||
for _, obj in ipairs(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
|
||||
-- force emerge of target area
|
||||
minetest.get_voxel_manip():read_from_map(target, target)
|
||||
if not minetest.get_node_or_nil(target) then
|
||||
minetest.emerge_area(
|
||||
vector.subtract(target, 4), vector.add(target, 4))
|
||||
end
|
||||
-- teleport the player
|
||||
minetest.after(3, function(obj, pos, target)
|
||||
local objpos = obj:getpos()
|
||||
objpos.y = objpos.y + 0.1 -- Fix some glitches at -8000
|
||||
if minetest.get_node(objpos).name ~= "nether:portal" then
|
||||
return
|
||||
end
|
||||
|
||||
obj:setpos(target)
|
||||
|
||||
local function check_and_build_portal(pos, target)
|
||||
local n = minetest.get_node_or_nil(target)
|
||||
if n and n.name ~= "nether:portal" then
|
||||
build_portal(target, pos)
|
||||
minetest.after(2, check_and_build_portal, pos, target)
|
||||
minetest.after(4, check_and_build_portal, pos, target)
|
||||
elseif not n then
|
||||
minetest.after(1, check_and_build_portal, pos, target)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(1, check_and_build_portal, pos, target)
|
||||
|
||||
end, obj, pos, target)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- Nodes
|
||||
|
||||
minetest.register_node("nether:portal", {
|
||||
description = "Nether Portal",
|
||||
tiles = {
|
||||
"nether_transparent.png",
|
||||
"nether_transparent.png",
|
||||
"nether_transparent.png",
|
||||
"nether_transparent.png",
|
||||
{
|
||||
name = "nether_portal.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 0.5,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "nether_portal.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 0.5,
|
||||
},
|
||||
},
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
diggable = false,
|
||||
pointable = false,
|
||||
buildable_to = false,
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
light_source = 5,
|
||||
post_effect_color = {a = 180, r = 128, g = 0, b = 128},
|
||||
alpha = 192,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.1, 0.5, 0.5, 0.1},
|
||||
},
|
||||
},
|
||||
groups = {not_in_creative_inventory = 1}
|
||||
})
|
||||
|
||||
minetest.register_node(":default:obsidian", {
|
||||
description = "Obsidian",
|
||||
tiles = {"default_obsidian.png"},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
groups = {cracky = 1, level = 2},
|
||||
|
||||
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,
|
||||
})
|
||||
|
||||
minetest.register_node("nether:rack", {
|
||||
description = "Netherrack",
|
||||
tiles = {"nether_rack.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky = 3, level = 2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("nether:sand", {
|
||||
description = "Nethersand",
|
||||
tiles = {"nether_sand.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly = 3, level = 2, falling_node = 1},
|
||||
sounds = default.node_sound_sand_defaults({
|
||||
footstep = {name = "default_gravel_footstep", gain = 0.45},
|
||||
}),
|
||||
})
|
||||
|
||||
minetest.register_node("nether:brick", {
|
||||
description = "Nether Brick",
|
||||
tiles = {"nether_brick.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 2, level = 2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
local fence_texture =
|
||||
"default_fence_overlay.png^nether_brick.png^default_fence_overlay.png^[makealpha:255,126,126"
|
||||
|
||||
minetest.register_node("nether:fence_nether_brick", {
|
||||
description = "Nether Brick Fence",
|
||||
drawtype = "fencelike",
|
||||
tiles = {"nether_brick.png"},
|
||||
inventory_image = "default_fence.png",
|
||||
wield_image = "default_fence.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
||||
},
|
||||
groups = {cracky = 2, level = 2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
|
||||
-- Register stair and slab
|
||||
|
||||
stairs.register_stair_and_slab(
|
||||
"nether_brick",
|
||||
"nether:brick",
|
||||
{cracky = 2, level = 2},
|
||||
{"nether_brick.png"},
|
||||
"nether stair",
|
||||
"nether slab",
|
||||
default.node_sound_stone_defaults()
|
||||
)
|
||||
|
||||
-- StairsPlus
|
||||
|
||||
if minetest.get_modpath("moreblocks") then
|
||||
stairsplus:register_all(
|
||||
"nether", "brick", "nether:brick", {
|
||||
description = "Nether Brick",
|
||||
groups = {cracky = 2, level = 2},
|
||||
tiles = {"nether_brick.png"},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- Crafting
|
||||
|
||||
minetest.register_craft({
|
||||
output = "nether:brick 4",
|
||||
recipe = {
|
||||
{"nether:rack", "nether:rack"},
|
||||
{"nether:rack", "nether:rack"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "nether:fence_nether_brick 6",
|
||||
recipe = {
|
||||
{"nether:brick", "nether:brick", "nether:brick"},
|
||||
{"nether:brick", "nether:brick", "nether:brick"},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
-- Mapgen
|
||||
|
||||
-- Initialize noise object and localise noise buffer
|
||||
|
||||
local nobj_cave = nil
|
||||
local nbuf_cave
|
||||
|
||||
|
||||
-- Content ids
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
|
||||
local c_stone_with_coal = minetest.get_content_id("default:stone_with_coal")
|
||||
local c_stone_with_iron = minetest.get_content_id("default:stone_with_iron")
|
||||
local c_stone_with_diamond = minetest.get_content_id("default:stone_with_diamond")
|
||||
local c_stone_with_gold = minetest.get_content_id("default:stone_with_gold")
|
||||
local c_stone_with_copper = minetest.get_content_id("default:stone_with_copper")
|
||||
|
||||
local c_gravel = minetest.get_content_id("default:gravel")
|
||||
local c_dirt = minetest.get_content_id("default:dirt")
|
||||
local c_sand = minetest.get_content_id("default:sand")
|
||||
|
||||
local c_cobble = minetest.get_content_id("default:cobble")
|
||||
local c_mossycobble = minetest.get_content_id("default:mossycobble")
|
||||
local c_stair_cobble = minetest.get_content_id("stairs:stair_cobble")
|
||||
|
||||
local c_lava_source = minetest.get_content_id("default:lava_source")
|
||||
local c_lava_flowing = minetest.get_content_id("default:lava_flowing")
|
||||
local c_water_source = minetest.get_content_id("default:water_source")
|
||||
local c_water_flowing = minetest.get_content_id("default:water_flowing")
|
||||
|
||||
local c_glowstone = minetest.get_content_id("default_override:glowstone")
|
||||
local c_nethersand = minetest.get_content_id("nether:sand")
|
||||
local c_netherbrick = minetest.get_content_id("nether:brick")
|
||||
local c_netherrack = minetest.get_content_id("nether:rack")
|
||||
local c_quartz = minetest.get_content_id("default:quartz_ore")
|
||||
|
||||
|
||||
-- On-generated function
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
if minp.y > NETHER_DEPTH then
|
||||
return
|
||||
end
|
||||
|
||||
local t1 = os.clock()
|
||||
|
||||
local x1 = maxp.x
|
||||
local y1 = maxp.y
|
||||
local z1 = maxp.z
|
||||
local x0 = minp.x
|
||||
local y0 = minp.y
|
||||
local z0 = minp.z
|
||||
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
local x11 = emax.x -- Limits of mapchunk plus mapblock shell
|
||||
local y11 = emax.y
|
||||
local z11 = emax.z
|
||||
local x00 = emin.x
|
||||
local y00 = emin.y
|
||||
local z00 = emin.z
|
||||
|
||||
local ystride = x1 - x0 + 1
|
||||
local zstride = ystride * ystride
|
||||
local chulens = {x = ystride, y = ystride, z = ystride}
|
||||
local minposxyz = {x = x0, y = y0, z = z0}
|
||||
|
||||
nobj_cave = nobj_cave or minetest.get_perlin_map(np_cave, chulens)
|
||||
local nvals_cave = nobj_cave:get3dMap_flat(minposxyz, nbuf_cave)
|
||||
|
||||
for y = y00, y11 do -- Y loop first to minimise tcave calculations
|
||||
local tcave
|
||||
local in_chunk_y = false
|
||||
if y >= y0 and y <= y1 then
|
||||
if y > yblmax then
|
||||
tcave = TCAVE + ((y - yblmax) / BLEND) ^ 2
|
||||
else
|
||||
tcave = TCAVE
|
||||
end
|
||||
in_chunk_y = true
|
||||
end
|
||||
|
||||
for z = z00, z11 do
|
||||
local vi = area:index(x00, y, z) -- Initial voxelmanip index
|
||||
local ni
|
||||
local in_chunk_yz = in_chunk_y and z >= z0 and z <= z1
|
||||
|
||||
for x = x00, x11 do
|
||||
if in_chunk_yz and x == x0 then
|
||||
-- Initial noisemap index
|
||||
ni = (z - z0) * zstride + (y - y0) * ystride + 1
|
||||
end
|
||||
local in_chunk_yzx = in_chunk_yz and x >= x0 and x <= x1 -- In mapchunk
|
||||
|
||||
local id = data[vi] -- Existing node
|
||||
-- Cave air, cave liquids and dungeons are overgenerated,
|
||||
-- convert these throughout mapchunk plus shell
|
||||
if id == c_air or -- Air and liquids to air
|
||||
id == c_lava_source or
|
||||
id == c_lava_flowing or
|
||||
--id == c_water_source or
|
||||
id == c_water_flowing then
|
||||
data[vi] = c_air
|
||||
-- Dungeons are preserved so we don't need
|
||||
-- to check for cavern in the shell
|
||||
elseif id == c_cobble or -- Dungeons (preserved) to netherbrick
|
||||
id == c_mossycobble or
|
||||
id == c_stair_cobble then
|
||||
data[vi] = c_netherbrick
|
||||
end
|
||||
|
||||
if in_chunk_yzx then -- In mapchunk
|
||||
if nvals_cave[ni] > tcave then -- Only excavate cavern in mapchunk
|
||||
data[vi] = c_air
|
||||
elseif id == c_water_source then -- Water source to lava
|
||||
data[vi] = c_lava_source
|
||||
elseif id == c_stone_with_gold then -- Precious ores to glowstone
|
||||
data[vi] = c_glowstone
|
||||
elseif id == c_stone_with_copper then
|
||||
data[vi] = c_quartz
|
||||
elseif id == c_stone_with_diamond then
|
||||
data[vi] = c_lava_source
|
||||
elseif id == c_gravel or -- Blob ore to nethersand
|
||||
id == c_dirt or
|
||||
id == c_sand then
|
||||
data[vi] = c_nethersand
|
||||
else -- All else to netherstone
|
||||
data[vi] = c_netherrack
|
||||
end
|
||||
|
||||
ni = ni + 1 -- Only increment noise index in mapchunk
|
||||
end
|
||||
|
||||
vi = vi + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:set_lighting({day = 0, night = 0})
|
||||
vm:calc_lighting()
|
||||
vm:update_liquids()
|
||||
vm:write_to_map()
|
||||
|
||||
local chugent = math.ceil((os.clock() - t1) * 1000)
|
||||
print ("[nether] generate chunk " .. chugent .. " ms")
|
||||
end)
|
||||
|
||||
-- ADD BY YAWIN FROM REDBLOCKERS
|
||||
minetest.register_tool(":fire:flint_and_steel", {
|
||||
description = "Flint and Steel",
|
||||
inventory_image = "default_tool_flint_and_steel.png",
|
||||
liquids_pointable = false,
|
||||
stack_max = 1,
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
flamable = {uses=65, maxlevel=1},
|
||||
}
|
||||
},
|
||||
on_place = function(stack, _, pt)
|
||||
if pt.type == "node" then
|
||||
if pt.under and minetest.get_node(pt.under).name == "default:obsidian" then
|
||||
local done = make_portal(pt.under)
|
||||
end
|
||||
|
||||
set_fire(pt)
|
||||
stack:add_wear(66000/65) -- 65 uses
|
||||
return stack
|
||||
end
|
||||
end,
|
||||
})
|
|
@ -1 +0,0 @@
|
|||
name = nether
|
Before Width: | Height: | Size: 86 KiB |
|
@ -1,4 +0,0 @@
|
|||
[Dolphin]
|
||||
PreviewsShown=true
|
||||
Timestamp=2016,12,30,2,19,38
|
||||
Version=3
|
Before Width: | Height: | Size: 546 B |
Before Width: | Height: | Size: 226 B |
Before Width: | Height: | Size: 382 B |
Before Width: | Height: | Size: 727 B |
Before Width: | Height: | Size: 550 B |
Before Width: | Height: | Size: 128 B |
|
@ -0,0 +1 @@
|
|||
../referenced-mods/minetest_game/mods/player_api/
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 33ee16fa06029444ef6729fed9cf86875e38cfc9
|
|
@ -0,0 +1,5 @@
|
|||
## Generic ignorable patterns and files
|
||||
*~
|
||||
.*.swp
|
||||
debug.txt
|
||||
*.patch
|
|
@ -0,0 +1,3 @@
|
|||
the mod's code's origin is from Jeija's timber mod (GPL)
|
||||
sound from http://www.freesound.org/people/ecfike/sounds/139952/, edited with audacity (WTFPL)
|
||||
rest WTFPL
|
|
@ -0,0 +1,28 @@
|
|||
[Mod] treecapitator [treecapitator]
|
||||
|
||||
I edited Jeja's timber mod to create this mod.
|
||||
[There I got the name.](http://www.minecraftforum.net/topic/1009577-147-daftpvfs-mods-treecapitator-ingameinfo-crystalwing-startinginv-floatingruins/)
|
||||
It works like the timber mod but it destroys the leaves and the fruits, too. Of course, the leaves won't be dropped - only saplings. Hold shift to avoid its function.
|
||||
|
||||
**Depends:** see [depends.txt](https://raw.githubusercontent.com/HybridDog/treecapitator/master/depends.txt)
|
||||
**License:** see [LICENSE.txt](https://raw.githubusercontent.com/HybridDog/treecapitator/master/LICENSE.txt)
|
||||
**Download:** [zip](https://github.com/HybridDog/treecapitator/archive/master.zip), [tar.gz](https://github.com/HybridDog/treecapitator/archive/master.tar.gz)
|
||||
|
||||
![I'm a screenshot!](https://forum.minetest.net/download/file.php?id=571)
|
||||
↑ you can only see the animation if your browser supports apng
|
||||
|
||||
If you got ideas or found bugs, please tell them to me.
|
||||
|
||||
[How to install a mod?](http://wiki.minetest.net/Installing_Mods)
|
||||
|
||||
|
||||
[13.04.2015] Added in trees for moretrees, working out getting proper naming for capitating to work.
|
||||
|
||||
[14.03.2015] Added sound of a falling tree (taken from there http://www.freesound.org/people/ecfike/sounds/139952/). Made "drop_items" and "drop_leaf" both "true" by default. (mintpick)
|
||||
|
||||
TODO:
|
||||
* add more trees
|
||||
* add more types of trees
|
||||
* fix mgv7 default apple tree neighbour tree detection, there sometimes is a sheet removed
|
||||
* mgv7 jungletree
|
||||
* use range_up and range_down for other trees too for greater precision in neighbour detection
|
|
@ -0,0 +1,4 @@
|
|||
default
|
||||
nyanland?
|
||||
farming_plus?
|
||||
moretrees?
|
|
@ -0,0 +1,605 @@
|
|||
local load_time_start = minetest.get_us_time()
|
||||
|
||||
|
||||
--------------------------------------Settings----------------------------------------------
|
||||
|
||||
-- default settings
|
||||
treecapitator = {
|
||||
drop_items = false,
|
||||
drop_leaf = false,
|
||||
play_sound = true,
|
||||
moretrees_support = false,
|
||||
delay = 0,
|
||||
default_tree = { --replaces not defined stuff (see below)
|
||||
trees = {"default:tree"},
|
||||
leaves = {"default:leaves"},
|
||||
range = 2,
|
||||
fruits = {},
|
||||
type = "default",
|
||||
},
|
||||
}
|
||||
|
||||
-- load custom settings
|
||||
for name,v in pairs(treecapitator) do
|
||||
local setting = "treecapitator."..name
|
||||
--local typ = type(v)
|
||||
local neuv
|
||||
if type(v) == "boolean" then
|
||||
neuv = minetest.setting_getbool(setting)
|
||||
else--if typ == "number" then
|
||||
neuv = tonumber(minetest.setting_get(setting))
|
||||
end
|
||||
if neuv ~= nil then
|
||||
treecapitator[name] = neuv
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
--the table where the trees are stored at
|
||||
treecapitator.trees = {}
|
||||
|
||||
--a table of trunks which couldn't be redefined
|
||||
treecapitator.rest_tree_nodes = {}
|
||||
|
||||
|
||||
--------------------------------------------fcts----------------------------------------------
|
||||
|
||||
local poshash = minetest.hash_node_position
|
||||
|
||||
-- don't use minetest.get_node more times for the same position (caching)
|
||||
local known_nodes
|
||||
local function clean_cache()
|
||||
known_nodes = {}
|
||||
setmetatable(known_nodes, {__mode = "kv"})
|
||||
end
|
||||
clean_cache()
|
||||
|
||||
local function remove_node(pos)
|
||||
known_nodes[poshash(pos)] = {name="air", param2=0}
|
||||
minetest.remove_node(pos)
|
||||
minetest.check_for_falling(pos)
|
||||
end
|
||||
|
||||
local function dig_node(pos, node, digger)
|
||||
known_nodes[poshash(pos)] = {name="air", param2=0}
|
||||
minetest.node_dig(pos, node, digger)
|
||||
end
|
||||
|
||||
local function get_node(pos)
|
||||
local vi = poshash(pos)
|
||||
local node = known_nodes[vi]
|
||||
if node then
|
||||
return node
|
||||
end
|
||||
node = minetest.get_node(pos)
|
||||
known_nodes[vi] = node
|
||||
return node
|
||||
end
|
||||
|
||||
--definitions of functions for the destruction of nodes
|
||||
local destroy_node, drop_leaf, remove_leaf
|
||||
if treecapitator.drop_items then
|
||||
function drop_leaf(pos, item)
|
||||
minetest.add_item(pos, item)
|
||||
end
|
||||
|
||||
function destroy_node(pos, node)
|
||||
local drops = minetest.get_node_drops(node.name)
|
||||
for _,item in pairs(drops) do
|
||||
minetest.add_item(pos, item)
|
||||
end
|
||||
remove_node(pos)
|
||||
end
|
||||
else
|
||||
function drop_leaf(pos, item, inv)
|
||||
if inv
|
||||
and inv:room_for_item("main", item) then
|
||||
inv:add_item("main", item)
|
||||
else
|
||||
minetest.add_item(pos, item)
|
||||
end
|
||||
end
|
||||
|
||||
destroy_node = dig_node
|
||||
end
|
||||
|
||||
if not treecapitator.drop_leaf then
|
||||
function remove_leaf(p, leaf, inv)
|
||||
local leaves_drops = minetest.get_node_drops(leaf)
|
||||
for _, itemname in pairs(leaves_drops) do
|
||||
if itemname ~= leaf then
|
||||
drop_leaf(p, itemname, inv)
|
||||
end
|
||||
end
|
||||
remove_node(p) --remove the leaves
|
||||
end
|
||||
else
|
||||
function remove_leaf(p, _, _, node, digger)
|
||||
destroy_node(p, node, digger)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
table.icontains = table.icontains or function(t, v)
|
||||
for i = 1,#t do
|
||||
if t[i] == v then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--tests if the node is a trunk
|
||||
local function findtree(node)
|
||||
if node == 0 then
|
||||
return true
|
||||
end
|
||||
return table.icontains(treecapitator.rest_tree_nodes, node.name)
|
||||
end
|
||||
|
||||
-- tests if the node is a trunk which could belong to the same tree sort
|
||||
local function is_trunk_of_tree(trees, node)
|
||||
return table.icontains(trees, node.name)
|
||||
and node.param2 == 0
|
||||
end
|
||||
|
||||
--returns positions for leaves allowed to be dug
|
||||
local function find_next_trees(pos, r,r_up,r_down, trees, leaves, fruits)
|
||||
-- firstly, detect neighbour trees of the same sort to not hurt them
|
||||
local tab = {}
|
||||
local rx2 = 2 * r
|
||||
local rupdown = r_up + r_down
|
||||
for i = -rx2, rx2 do
|
||||
for j = -rx2, rx2 do
|
||||
if i ~= 0
|
||||
or j ~= 0 then
|
||||
for h = rupdown, -rupdown, -1 do
|
||||
local p = {x=pos.x+j, y=pos.y+h, z=pos.z+i}
|
||||
|
||||
-- tests if a trunk is at the current pos and below it
|
||||
local nd = get_node(p)
|
||||
if is_trunk_of_tree(trees, nd)
|
||||
and is_trunk_of_tree(trees, get_node{x=p.x, y=p.y-1, z=p.z}) then
|
||||
-- search for a leaves or fruit node next to the trunk
|
||||
local leaf = get_node{x=p.x, y=p.y+1, z=p.z}.name
|
||||
local leaf_found = table.icontains(leaves, leaf)
|
||||
or table.icontains(fruits, leaf)
|
||||
if not leaf_found then
|
||||
leaf = get_node{x=p.x, y=p.y, z=p.z+1}.name
|
||||
leaf_found = table.icontains(leaves, leaf)
|
||||
or table.icontains(fruits, leaf)
|
||||
end
|
||||
|
||||
if leaf_found then
|
||||
-- mark places which should not be removed
|
||||
local z1 = math.max(-r+i, -r)
|
||||
local z2 = math.min(r+i, r)
|
||||
local y1 = math.max(-r_down+h, -r_down)
|
||||
local y2 = math.min(r_up+h, r_up)
|
||||
local x1 = math.max(-r+j, -r)
|
||||
local x2 = math.min(r+j, r)
|
||||
for z = z1,z2 do
|
||||
for y = y1,y2 do
|
||||
for x = x1,x2 do
|
||||
tab[poshash{x=x, y=y, z=z}] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- now, get the head positions without the neighbouring trees
|
||||
local tab2,n = {},1
|
||||
for z = -r,r do
|
||||
for y = -r_down,r_up do
|
||||
for x = -r,r do
|
||||
local p = {x=x, y=y, z=z}
|
||||
if not tab[poshash(p)] then
|
||||
tab2[n] = p
|
||||
n = n+1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return tab2, n-1
|
||||
end
|
||||
|
||||
-- table iteration instead of recursion
|
||||
local function get_tab(pos, func, max)
|
||||
local todo = {pos}
|
||||
local n = 1
|
||||
local tab_avoid = {[poshash(pos)] = true}
|
||||
local tab_done,num = {pos},2
|
||||
while n ~= 0 do
|
||||
local p = todo[n]
|
||||
n = n-1
|
||||
--[[
|
||||
for i = -1,1,2 do
|
||||
for _,p2 in pairs{
|
||||
{x=p.x+i, y=p.y, z=p.z},
|
||||
{x=p.x, y=p.y+i, z=p.z},
|
||||
{x=p.x, y=p.y, z=p.z+i},
|
||||
} do]]
|
||||
for i = -1,1 do
|
||||
for j = -1,1 do
|
||||
for k = -1,1 do
|
||||
local p2 = {x=p.x+i, y=p.y+j, z=p.z+k}
|
||||
local vi = poshash(p2)
|
||||
if not tab_avoid[vi]
|
||||
and func(p2) then
|
||||
n = n+1
|
||||
todo[n] = p2
|
||||
|
||||
tab_avoid[vi] = true
|
||||
|
||||
tab_done[num] = p2
|
||||
num = num+1
|
||||
|
||||
if max
|
||||
and num > max then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return tab_done
|
||||
end
|
||||
|
||||
|
||||
-- the functions for the available types
|
||||
local capitate_funcs = {}
|
||||
|
||||
function capitate_funcs.default(pos, tr, node_above, digger)
|
||||
local trees = tr.trees
|
||||
|
||||
-- fill tab with the stem trunks
|
||||
local tab, n = {{{x=pos.x, y=pos.y+1, z=pos.z}, node_above}}, 2
|
||||
local np = {x=pos.x, y=pos.y+2, z=pos.z}
|
||||
local nd = get_node(np)
|
||||
while table.icontains(trees, nd.name) and nd.param2 == 0 do
|
||||
tab[n] = {vector.new(np), nd}
|
||||
n = n+1
|
||||
np.y = np.y+1
|
||||
nd = get_node(np)
|
||||
end
|
||||
np.y = np.y-1
|
||||
|
||||
local leaves = tr.leaves
|
||||
local fruits = tr.fruits
|
||||
|
||||
-- abort if the tree lacks leaves/fruits
|
||||
if not table.icontains(leaves, nd.name)
|
||||
and not table.icontains(fruits, nd.name) then
|
||||
local leaf = get_node{x=np.x, y=np.y, z=np.z+1}.name
|
||||
if not table.icontains(leaves, leaf)
|
||||
and not table.icontains(fruits, leaf) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- play the sound, then dig the stem
|
||||
if treecapitator.play_sound then
|
||||
minetest.sound_play("tree_falling", {pos = pos, max_hear_distance = 32})
|
||||
end
|
||||
for i = 1,n-1 do
|
||||
local pos,node = unpack(tab[i])
|
||||
destroy_node(pos, node, digger)
|
||||
end
|
||||
|
||||
-- remove leaves and fruits
|
||||
local range = tr.range
|
||||
local inv = digger:get_inventory()
|
||||
local head_ps
|
||||
--definition of possible leaves and fruitspositions
|
||||
head_ps,n = find_next_trees(np, range, tr.range_up or range,
|
||||
tr.range_down or range, trees, leaves, fruits)
|
||||
for i = 1,n do
|
||||
local p = vector.add(np, head_ps[i])
|
||||
local node = get_node(p)
|
||||
local nodename = node.name
|
||||
local is_trunk = table.icontains(trees, nodename)
|
||||
if node.param2 ~= 0
|
||||
or not is_trunk then
|
||||
if table.icontains(leaves, nodename) then
|
||||
remove_leaf(p, nodename, inv, node, digger)
|
||||
elseif table.icontains(fruits, nodename) then
|
||||
destroy_node(p, node, digger)
|
||||
end
|
||||
elseif is_trunk
|
||||
and tr.trunk_fruit_vertical
|
||||
and table.icontains(fruits, nodename)
|
||||
and not table.icontains(trees, get_node{x=p.x, y=p.y+1, z=p.z})
|
||||
and not table.icontains(trees, get_node{x=p.x, y=p.y-1, z=p.z}) then
|
||||
destroy_node(p, node, digger)
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function capitate_funcs.acacia(pos, tr, node_above, digger)
|
||||
local trunk = tr.trees[1]
|
||||
|
||||
-- fill tab with the stem trunks
|
||||
local tab, n = {{{x=pos.x, y=pos.y+1, z=pos.z}, node_above}}, 2
|
||||
local np = {x=pos.x, y=pos.y+2, z=pos.z}
|
||||
local nd = get_node(np)
|
||||
while trunk == nd.name
|
||||
and nd.param2 < 4 do
|
||||
tab[n] = {vector.new(np), nd}
|
||||
n = n+1
|
||||
np.y = np.y+1
|
||||
nd = get_node(np)
|
||||
end
|
||||
np.y = np.y-1
|
||||
|
||||
for z = -1,1,2 do
|
||||
for x = -1,1,2 do
|
||||
-- add the other trunks to tab
|
||||
local p = vector.new(np)
|
||||
p.x = p.x+x
|
||||
p.z = p.z+z
|
||||
local nd = get_node(p)
|
||||
if nd.name ~= trunk then
|
||||
p.y = p.y+1
|
||||
nd = get_node(p)
|
||||
if nd.name ~= trunk then
|
||||
return
|
||||
end
|
||||
end
|
||||
tab[n] = {vector.new(p), nd}
|
||||
|
||||
p.x = p.x+x
|
||||
p.z = p.z+z
|
||||
p.y = p.y+1
|
||||
|
||||
if get_node(p).name ~= trunk then
|
||||
return
|
||||
end
|
||||
tab[n+1] = {vector.new(p), nd}
|
||||
n = n+2
|
||||
|
||||
-- get neighbouring acacia trunks for delimiting
|
||||
local no_rms = {}
|
||||
for z = -4,4 do
|
||||
for x = -4,4 do
|
||||
if math.abs(x+z) ~= 8
|
||||
and (x ~= 0 or z ~= 0) then
|
||||
if get_node{x=p.x+x, y=p.y, z=p.z+z}.name == trunk
|
||||
and get_node{x=p.x+x, y=p.y+1, z=p.z+z}.name == tr.leaf then
|
||||
for z = math.max(-4, z-2), math.min(4, z+2) do
|
||||
for x = math.max(-4, x-2), math.min(4, x+2) do
|
||||
no_rms[(z+4)*9 + x+4] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- remove leaves
|
||||
local inv = digger:get_inventory()
|
||||
p.y = p.y+1
|
||||
local i = 0
|
||||
for z = -4,4 do
|
||||
for x = -4,4 do
|
||||
if not no_rms[i] then
|
||||
local p = {x=p.x+x, y=p.y, z=p.z+z}
|
||||
local node = get_node(p)
|
||||
if node.name == tr.leaf then
|
||||
remove_leaf(p, tr.leaf, inv, node, digger)
|
||||
end
|
||||
end
|
||||
i = i+1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- play the sound, then dig the stem
|
||||
if treecapitator.play_sound then
|
||||
minetest.sound_play("tree_falling", {pos = pos, max_hear_distance = 32})
|
||||
end
|
||||
for i = 1,n-1 do
|
||||
local pos,node = unpack(tab[i])
|
||||
destroy_node(pos, node, digger)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function capitate_funcs.moretrees(pos, tr, _, digger)
|
||||
local trees = tr.trees
|
||||
local leaves = tr.leaves
|
||||
local fruits = tr.fruits
|
||||
local minx = pos.x-tr.range
|
||||
local maxx = pos.x+tr.range
|
||||
local minz = pos.z-tr.range
|
||||
local maxz = pos.z+tr.range
|
||||
local maxy = pos.y+tr.height
|
||||
local num_trunks = 0
|
||||
local num_leaves = 0
|
||||
local ps = get_tab({x=pos.x, y=pos.y+1, z=pos.z}, function(pos)
|
||||
if pos.x < minx
|
||||
or pos.x > maxx
|
||||
or pos.z < minz
|
||||
or pos.z > maxz
|
||||
or pos.y > maxy then
|
||||
return false
|
||||
end
|
||||
local nam = get_node(pos).name
|
||||
if table.icontains(trees, nam) then
|
||||
num_trunks = num_trunks+1
|
||||
elseif table.icontains(leaves, nam) then
|
||||
num_leaves = num_leaves+1
|
||||
elseif not table.icontains(fruits, nam) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end, tr.max_nodes)
|
||||
if not ps then
|
||||
print"no ps found"
|
||||
return
|
||||
end
|
||||
if num_trunks < tr.num_trunks_min
|
||||
or num_trunks > tr.num_trunks_max then
|
||||
print("wrong trunks num: "..num_trunks)
|
||||
return
|
||||
end
|
||||
if num_leaves < tr.num_leaves_min
|
||||
or num_leaves > tr.num_leaves_max then
|
||||
print("wrong leaves num: "..num_leaves)
|
||||
return
|
||||
end
|
||||
if treecapitator.play_sound then
|
||||
minetest.sound_play("tree_falling", {pos = pos, max_hear_distance = 32})
|
||||
end
|
||||
local inv = digger:get_inventory()
|
||||
for _,p in pairs(ps) do
|
||||
local node = get_node(p)
|
||||
local nodename = node.name
|
||||
if table.icontains(leaves, nodename) then
|
||||
remove_leaf(p, nodename, inv, node, digger)
|
||||
else
|
||||
destroy_node(p, node, digger)
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
--the function which is used for capitating
|
||||
local capitating = false --necessary if minetest.node_dig is used
|
||||
local function capitate_tree(pos, node, digger)
|
||||
if capitating
|
||||
or not digger
|
||||
or digger:get_player_control().sneak
|
||||
or not findtree(node) then
|
||||
return
|
||||
end
|
||||
local t1 = minetest.get_us_time()
|
||||
capitating = true
|
||||
local node_above = get_node{x=pos.x, y=pos.y+1, z=pos.z}
|
||||
for i = 1,#treecapitator.trees do
|
||||
local tr = treecapitator.trees[i]
|
||||
if table.icontains(tr.trees, node_above.name)
|
||||
and node_above.param2 < 4
|
||||
and capitate_funcs[tr.type](pos, tr, node_above, digger) then
|
||||
break
|
||||
end
|
||||
end
|
||||
clean_cache()
|
||||
capitating = false
|
||||
minetest.log("info", "[treecapitator] tree capitated at ("
|
||||
.. pos.x .. "|" .. pos.y .. "|" .. pos.z .. ") after ca. "
|
||||
.. (minetest.get_us_time() - t1) / 1000000 .. " s")
|
||||
end
|
||||
|
||||
local delay = treecapitator.delay
|
||||
if delay > 0 then
|
||||
local oldfunc = capitate_tree
|
||||
function capitate_tree(...)
|
||||
minetest.after(delay, function(...)
|
||||
oldfunc(...)
|
||||
end, ...)
|
||||
end
|
||||
end
|
||||
|
||||
--adds trunks to rest_tree_nodes if they were overwritten by other mods
|
||||
local tmp_trees = {}
|
||||
local function test_overwritten(tree)
|
||||
tmp_trees[#tmp_trees+1] = tree
|
||||
end
|
||||
|
||||
minetest.after(0, function()
|
||||
for _,tree in pairs(tmp_trees) do
|
||||
if not minetest.registered_nodes[tree].after_dig_node then
|
||||
minetest.log("error", "[treecapitator] Error: Overwriting "
|
||||
.. tree .. " went wrong.")
|
||||
treecapitator.rest_tree_nodes[#treecapitator.rest_tree_nodes+1] = tree
|
||||
end
|
||||
end
|
||||
tmp_trees = nil
|
||||
end)
|
||||
|
||||
-- the function to overide trunks
|
||||
local override
|
||||
if minetest.override_item then
|
||||
function override(name)
|
||||
minetest.override_item(name, {
|
||||
after_dig_node = function(pos, _, _, digger)
|
||||
capitate_tree(pos, 0, digger)
|
||||
end
|
||||
})
|
||||
end
|
||||
else
|
||||
minetest.log("deprecated", "minetest.override_item isn't supported")
|
||||
table.copy = table.copy or function(tab)
|
||||
local tab2 = {}
|
||||
for n,i in pairs(tab) do
|
||||
tab2[n] = i
|
||||
end
|
||||
return tab2
|
||||
end
|
||||
function override(name, data)
|
||||
data = table.copy(data)
|
||||
data.after_dig_node = function(pos, _, _, digger)
|
||||
capitate_tree(pos, 0, digger)
|
||||
end
|
||||
minetest.register_node(":"..name, data)
|
||||
end
|
||||
end
|
||||
|
||||
--the function to register trees to become capitated
|
||||
local num = 1
|
||||
function treecapitator.register_tree(tab)
|
||||
for name,value in pairs(treecapitator.default_tree) do
|
||||
tab[name] = tab[name] or value --replaces not defined stuff
|
||||
end
|
||||
treecapitator.trees[num] = tab
|
||||
num = num+1
|
||||
|
||||
for _,tree in pairs(tab.trees) do
|
||||
local data = minetest.registered_nodes[tree]
|
||||
if not data then
|
||||
minetest.log("info", "[treecapitator] Info: "
|
||||
.. tree .. " isn't registered yet.")
|
||||
treecapitator.rest_tree_nodes[#treecapitator.rest_tree_nodes+1] = tree
|
||||
else
|
||||
if data.after_dig_node then
|
||||
minetest.log("info", "[treecapitator] Info: " .. tree
|
||||
.. " already has an after_dig_node.")
|
||||
treecapitator.rest_tree_nodes[#treecapitator.rest_tree_nodes+1] = tree
|
||||
else
|
||||
override(tree, data)
|
||||
test_overwritten(tree)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath"treecapitator".."/trees.lua")
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
--use register_on_dignode if trunks are left
|
||||
if treecapitator.rest_tree_nodes[1] then
|
||||
minetest.register_on_dignode(capitate_tree)
|
||||
end
|
||||
|
||||
|
||||
local time = (minetest.get_us_time() - load_time_start) / 1000000
|
||||
local msg = "[treecapitator] loaded after ca. " .. time .. " seconds."
|
||||
if time > 0.01 then
|
||||
print(msg)
|
||||
else
|
||||
minetest.log("info", msg)
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
# drop items, else get them in the inventory
|
||||
treecapitator.drop_items (drop items) bool false
|
||||
|
||||
# if set to false, do not drop leaves, just saplings (leafdecay behaviour)
|
||||
treecapitator.drop_leaf (give leaves) bool false
|
||||
|
||||
# play a sound after digging a tree
|
||||
treecapitator.play_sound (play sound) bool true
|
||||
|
||||
# capitate moretrees' trees, experimental, use with caution
|
||||
treecapitator.moretrees_support (support moretrees) bool false
|
||||
|
||||
# lets trees become capitated <delay> seconds later, only works if it's > 0
|
||||
treecapitator.delay (delay) float 0 0
|
|
@ -0,0 +1,321 @@
|
|||
--[[
|
||||
treecapitator.register_tree({
|
||||
trees = {<node1>, <node2>, ...},
|
||||
leaves = {<node1>, <node2>, ...},
|
||||
range = <range>,
|
||||
range_up = <range>,
|
||||
range_down = <range>,
|
||||
fruits = {<node1>, <node2>, ...},
|
||||
trunk_fruit_vertical = <some_boolean>,
|
||||
type = "default",
|
||||
})
|
||||
|
||||
trees: the straight stem nodes with param2=0
|
||||
leaves: nodes of the tree head which only drop their main item if drop_leaf is enabled
|
||||
range: the size of the tree head cuboid
|
||||
range_up: range upwards beginning from the highest trunk node to head top
|
||||
if omitted it's set to range
|
||||
range_down: like range_up but downwards
|
||||
fruits: similar to leaves but without the drop_leaf setting condition
|
||||
trunk_fruit_vertical: set this to true to make a trunk node, if it's in trees
|
||||
and fruits, get removed even if it isn't rotated (param2 = 0)
|
||||
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {<node1>, <node2>, ...},
|
||||
leaves = {<node1>, <node2>, ...},
|
||||
range = <range>,
|
||||
fruits = {<node1>, <node2>, ...},
|
||||
height = <height>,
|
||||
max_nodes = <max_nodes>,
|
||||
num_trunks_min = <some_number>,
|
||||
num_trunks_max = <some_number>,
|
||||
num_leaves_min = <some_number>,
|
||||
num_leaves_max = <some_number>,
|
||||
type = "moretrees",
|
||||
})
|
||||
|
||||
height: maximum tree height
|
||||
max_nodes: maximum amount of nodes the tree is allowed to consist of
|
||||
num_trunks_min…
|
||||
]]
|
||||
|
||||
local mgname = minetest.get_mapgen_setting"mg_name"
|
||||
if mgname == "v7" then
|
||||
treecapitator.register_tree{
|
||||
trees = {"default:tree"},
|
||||
leaves = {"default:leaves"},
|
||||
range = 2,
|
||||
range_up = 4,
|
||||
range_down = 0,
|
||||
fruits = {"default:apple", "default:tree"},
|
||||
trunk_fruit_vertical = true
|
||||
}
|
||||
else
|
||||
treecapitator.register_tree{
|
||||
trees = {"default:tree"},
|
||||
leaves = {"default:leaves"},
|
||||
range = 2,
|
||||
fruits = {"default:apple"}
|
||||
}
|
||||
end
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"default:pine_tree"},
|
||||
leaves = {"default:pine_needles"},
|
||||
range_up = 2,
|
||||
range_down = 6,
|
||||
range = 3,
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"default:jungletree"},
|
||||
leaves = {"default:jungleleaves"},
|
||||
range = 3
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"default:acacia_tree"},
|
||||
leaf = "default:acacia_leaves",
|
||||
no_param2test = true,
|
||||
--leavesrange = 4,
|
||||
type = "acacia"
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"default:aspen_tree"},
|
||||
leaves = {"default:aspen_leaves"},
|
||||
range = 4,
|
||||
})
|
||||
|
||||
if minetest.get_modpath("nyanland") then
|
||||
treecapitator.register_tree({
|
||||
trees = {"nyanland:mesetree", "nyanland:healstone"},
|
||||
leaves = {"nyanland:meseleaves"},
|
||||
range = 2,
|
||||
fruits = {"default:apple"}
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("farming_plus") then
|
||||
treecapitator.register_tree({
|
||||
trees = {"default:tree"},
|
||||
leaves = {"farming_plus:banana_leaves"},
|
||||
range = 2,
|
||||
fruits = {"farming_plus:banana"}
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"default:tree"},
|
||||
leaves = {"farming_plus:cocoa_leaves"},
|
||||
range = 2,
|
||||
fruits = {"farming_plus:cocoa"}
|
||||
})
|
||||
end
|
||||
|
||||
if treecapitator.moretrees_support
|
||||
and minetest.get_modpath("moretrees") then
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:acacia_trunk"},
|
||||
leaves = {"moretrees:acacia_leaves"},
|
||||
range = 10,
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:apple_tree_trunk"},
|
||||
leaves = {"moretrees:apple_tree_leaves"},
|
||||
range = 20,
|
||||
fruits = {"default:apple"}
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:beech_trunk"},
|
||||
leaves = {"moretrees:beech_leaves"},
|
||||
range = 8,
|
||||
})
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:birch_trunk"},
|
||||
leaves = {"moretrees:birch_leaves"},
|
||||
range = 8,
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:fir_trunk"},
|
||||
leaves = {"moretrees:fir_leaves","fir_leaves_bright"},
|
||||
range = 12,
|
||||
fruits = {"moretrees:fir_cone"}
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:jungletree_trunk"},
|
||||
leaves = {"moretrees:jungletree_leaves_green","jungletree_leaves_yellow","jungletree_leaves_red"},
|
||||
range = 8,
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:oak_trunk"},
|
||||
leaves = {"moretrees:oak_leaves"},
|
||||
range = 8,
|
||||
fruits = {"moretrees:acorn"}
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:palm_trunk"},
|
||||
leaves = {"moretrees:palm_leaves"},
|
||||
range = 8,
|
||||
fruits = {"moretrees:coconut"}
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:cedar_trunk"},
|
||||
leaves = {"moretrees:cedar_leaves"},
|
||||
range = 8,
|
||||
fruits = {"moretrees:cedar_cone"}
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:rubber_tree_trunk","rubber_tree_trunk_empty"},
|
||||
leaves = {"moretrees:rubber_tree_leaves"},
|
||||
range = 8,
|
||||
})
|
||||
--[[
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:sequoia_trunk"},
|
||||
leaves = {"moretrees:sequoia_leaves"},
|
||||
range = 12,
|
||||
})--]]
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:spruce_trunk"},
|
||||
leaves = {"moretrees:spruce_leaves"},
|
||||
range = 10,
|
||||
fruits = {"moretrees:spruce_cone"}
|
||||
})
|
||||
|
||||
--[[
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:willow_trunk"},
|
||||
leaves = {"moretrees:willow_leaves"},
|
||||
range = 10,
|
||||
})
|
||||
--]]
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:sequoia_trunk"},
|
||||
leaves = {"moretrees:sequoia_leaves"},
|
||||
range = 8,
|
||||
|
||||
|
||||
height = 17,
|
||||
max_nodes = 8000,
|
||||
num_trunks_min = 5,
|
||||
num_trunks_max = 400,
|
||||
num_leaves_min = 10,
|
||||
num_leaves_max = 4000,
|
||||
type = "moretrees",
|
||||
})
|
||||
|
||||
treecapitator.register_tree({
|
||||
trees = {"moretrees:willow_trunk"},
|
||||
leaves = {"moretrees:willow_leaves"},
|
||||
range = 11,
|
||||
height = 17,
|
||||
max_nodes = 8000,
|
||||
num_trunks_min = 5,
|
||||
num_trunks_max = 400,
|
||||
num_leaves_min = 10,
|
||||
num_leaves_max = 4000,
|
||||
type = "moretrees",
|
||||
})
|
||||
end
|
||||
|
||||
-- code from amadin and narrnika
|
||||
if minetest.get_modpath("ethereal") then
|
||||
treecapitator.register_tree({--jungle [эвкалипт]
|
||||
trees = {"default:jungletree"},
|
||||
leaves = {"default:jungleleaves"},
|
||||
range = 3,
|
||||
height = 20,
|
||||
max_nodes = 145,
|
||||
num_trunks_min = 0,
|
||||
num_trunks_max = 35,
|
||||
num_leaves_min = 0,
|
||||
num_leaves_max = 110,
|
||||
type = "moretrees",
|
||||
})
|
||||
treecapitator.register_tree({--pine [кедр]
|
||||
trees = {"default:pinetree"}, -- this may need to be changed to pine_tree
|
||||
leaves = {"ethereal:pineleaves"},
|
||||
range = 6,
|
||||
type = "default",
|
||||
})
|
||||
treecapitator.register_tree({--orange [апельсиновое дерево]
|
||||
trees = {"default:tree"},
|
||||
leaves = {"default:leaves", "ethereal:orange_leaves"},
|
||||
fruits = {"default:apple", "ethereal:orange"},
|
||||
range = 2,
|
||||
type = "default",
|
||||
})
|
||||
treecapitator.register_tree({--acacia [акация]
|
||||
trees = {"ethereal:acacia_trunk"},
|
||||
leaves = {"ethereal:acacia_leaves"},
|
||||
range = 10,
|
||||
height = 10,
|
||||
max_nodes = 122,
|
||||
num_trunks_min = 0,
|
||||
num_trunks_max = 22,
|
||||
num_leaves_min = 0,
|
||||
num_leaves_max = 100,
|
||||
type = "moretrees",
|
||||
})
|
||||
treecapitator.register_tree({--banana [банановое дерево]
|
||||
trees = {"ethereal:banana_trunk"},
|
||||
leaves = {"ethereal:bananaleaves"},
|
||||
fruits = {"ethereal:banana"},
|
||||
range = 3,
|
||||
height = 7,
|
||||
max_nodes = 28,
|
||||
num_trunks_min = 0,
|
||||
num_trunks_max = 4,
|
||||
num_leaves_min = 0,
|
||||
num_leaves_max = 20,
|
||||
type = "moretrees",
|
||||
})
|
||||
treecapitator.register_tree({--coconut [кокосовое дерево]
|
||||
trees = {"ethereal:palm_trunk"},
|
||||
leaves = {"ethereal:palmleaves"},
|
||||
fruits = {"ethereal:coconut"},
|
||||
range = 3,
|
||||
height = 9,
|
||||
max_nodes = 37,
|
||||
num_trunks_min = 0,
|
||||
num_trunks_max = 8,
|
||||
num_leaves_min = 0,
|
||||
num_leaves_max = 25,
|
||||
type = "moretrees",
|
||||
})
|
||||
treecapitator.register_tree({--willow [ива]
|
||||
trees = {"ethereal:willow_trunk"},
|
||||
leaves = {"ethereal:willow_twig"},
|
||||
range = 10,
|
||||
height = 13,
|
||||
max_nodes = 540,
|
||||
num_trunks_min = 0,
|
||||
num_trunks_max = 90,
|
||||
num_leaves_min = 0,
|
||||
num_leaves_max = 450,
|
||||
type = "moretrees",
|
||||
})
|
||||
treecapitator.register_tree({--moshroom [гриб]
|
||||
trees = {"ethereal:mushroom_trunk"},
|
||||
leaves = {"ethereal:mushroom", "ethereal:mushroom_porew"},
|
||||
range = 4,
|
||||
height = 10,
|
||||
max_nodes = 100,
|
||||
num_trunks_min = 0,
|
||||
num_trunks_max = 32,
|
||||
num_leaves_min = 0,
|
||||
num_leaves_max = 80,
|
||||
type = "moretrees",
|
||||
})
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
../referenced-mods/underworlds/
|