diff --git a/mods/mcl_core/init.lua b/mods/mcl_core/init.lua index 9bb436ddc1..a1834c4cd6 100644 --- a/mods/mcl_core/init.lua +++ b/mods/mcl_core/init.lua @@ -20,7 +20,6 @@ dofile(minetest.get_modpath("mcl_core").."/tools.lua") dofile(minetest.get_modpath("mcl_core").."/craftitems.lua") dofile(minetest.get_modpath("mcl_core").."/crafting.lua") dofile(minetest.get_modpath("mcl_core").."/mapgen.lua") -dofile(minetest.get_modpath("mcl_core").."/player.lua") -- Aliases minetest.register_alias("default:desert_sand", "mcl_core:sand") diff --git a/mods/mcl_minecarts/depends.txt b/mods/mcl_minecarts/depends.txt index 5d9803d534..485278d763 100644 --- a/mods/mcl_minecarts/depends.txt +++ b/mods/mcl_minecarts/depends.txt @@ -1,2 +1,3 @@ mcl_core +mcl_player mesecons? diff --git a/mods/mcl_minecarts/init.lua b/mods/mcl_minecarts/init.lua index bdd2331b0d..1f4cea4d8e 100644 --- a/mods/mcl_minecarts/init.lua +++ b/mods/mcl_minecarts/init.lua @@ -40,7 +40,7 @@ function mcl_minecarts.cart:on_rightclick(clicker) clicker:set_detach() elseif not self._driver then self._driver = player_name - mcl_core.player_attached[player_name] = true + mcl_player.player_attached[player_name] = true clicker:set_attach(self.object, "", {x=0, y=3, z=0}, {x=0, y=0, z=0}) end end @@ -72,7 +72,7 @@ function mcl_minecarts.cart:on_punch(puncher, time_from_last_punch, tool_capabil if self._old_pos then self.object:setpos(self._old_pos) end - mcl_core.player_attached[self._driver] = nil + mcl_player.player_attached[self._driver] = nil local player = minetest.get_player_by_name(self._driver) if player then player:set_detach() diff --git a/mods/mcl_player/README.txt b/mods/mcl_player/README.txt new file mode 100644 index 0000000000..4da003a0d3 --- /dev/null +++ b/mods/mcl_player/README.txt @@ -0,0 +1,20 @@ +MineClone 2 mod: mcl_player +========================== + +License of source code: +----------------------- +Copyright (C) 2011-2012 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +http://www.gnu.org/licenses/lgpl-2.1.html + +Authors of media files +----------------------- +MirceaKitsune (WTFPL): + character.x + +Textures from Faithful 1.11 resource pack (see main readme file) diff --git a/mods/mcl_core/player.lua b/mods/mcl_player/init.lua similarity index 82% rename from mods/mcl_core/player.lua rename to mods/mcl_player/init.lua index 7d069ebe4c..da083bcdee 100644 --- a/mods/mcl_core/player.lua +++ b/mods/mcl_player/init.lua @@ -1,4 +1,4 @@ --- Minetest 0.4 mod: player +-- MineClone 2 mod: mcl_player -- See README.txt for licensing and other information. --[[ @@ -6,29 +6,29 @@ API --- -mcl_core.player_register_model(name, def) +mcl_player.player_register_model(name, def) ^ Register a new model to be used by players. ^ is the model filename such as "character.x", "foo.b3d", etc. ^ See Model Definition below for format of . -mcl_core.registered_player_models[name] +mcl_player.registered_player_models[name] ^ See Model Definition below for format. -mcl_core.player_set_model(player, model_name) +mcl_player.player_set_model(player, model_name) ^ is a PlayerRef. ^ is a model registered with player_register_model. -mcl_core.player_set_animation(player, anim_name [, speed]) +mcl_player.player_set_animation(player, anim_name [, speed]) ^ is a PlayerRef. ^ is the name of the animation. ^ is in frames per second. If nil, default from the model is used -mcl_core.player_set_textures(player, textures) +mcl_player.player_set_textures(player, textures) ^ is a PlayerRef. ^ is an array of textures ^ If is nil, the default textures from the model def are used -mcl_core.player_get_animation(player) +mcl_player.player_get_animation(player) ^ is a PlayerRef. ^ Returns a table containing fields "model", "textures" and "animation". ^ Any of the fields of the returned table may be nil. @@ -50,21 +50,23 @@ model_def = { ]] +mcl_player = {} + -- Player animation blending -- Note: This is currently broken due to a bug in Irrlicht, leave at 0 local animation_blend = 0 -mcl_core.registered_player_models = { } +mcl_player.registered_player_models = { } -- Local for speed. -local models = mcl_core.registered_player_models +local models = mcl_player.registered_player_models -function mcl_core.player_register_model(name, def) +function mcl_player.player_register_model(name, def) models[name] = def end -- Default player appearance -mcl_core.player_register_model("character.x", { +mcl_player.player_register_model("character.x", { animation_speed = 30, textures = {"character.png", }, animations = { @@ -84,9 +86,9 @@ local player_model = {} local player_textures = {} local player_anim = {} local player_sneak = {} -mcl_core.player_attached = {} +mcl_player.player_attached = {} -function mcl_core.player_get_animation(player) +function mcl_player.player_get_animation(player) local name = player:get_player_name() return { model = player_model[name], @@ -96,7 +98,7 @@ function mcl_core.player_get_animation(player) end -- Called when a player's appearance needs to be updated -function mcl_core.player_set_model(player, model_name) +function mcl_player.player_set_model(player, model_name) local name = player:get_player_name() local model = models[model_name] if model then @@ -109,7 +111,7 @@ function mcl_core.player_set_model(player, model_name) visual = "mesh", visual_size = model.visual_size or {x=1, y=1}, }) - mcl_core.player_set_animation(player, "stand") + mcl_player.player_set_animation(player, "stand") else player:set_properties({ textures = { "player.png", "player_back.png", }, @@ -119,13 +121,13 @@ function mcl_core.player_set_model(player, model_name) player_model[name] = model_name end -function mcl_core.player_set_textures(player, textures) +function mcl_player.player_set_textures(player, textures) local name = player:get_player_name() player_textures[name] = textures player:set_properties({textures = textures,}) end -function mcl_core.player_set_animation(player, anim_name, speed) +function mcl_player.player_set_animation(player, anim_name, speed) local name = player:get_player_name() if player_anim[name] == anim_name then return @@ -141,8 +143,8 @@ end -- Update appearance when the player joins minetest.register_on_joinplayer(function(player) - mcl_core.player_attached[player:get_player_name()] = false - mcl_core.player_set_model(player, "character.x") + mcl_player.player_attached[player:get_player_name()] = false + mcl_player.player_set_model(player, "character.x") -- Minecraft has no sneak glitch -- sneak is also disabled because it is buggy in Minetest (can be used to negate fall damage) player:set_physics_override({sneak_glitch=false}) @@ -159,7 +161,7 @@ minetest.register_on_leaveplayer(function(player) end) -- Localize for better performance. -local player_set_animation = mcl_core.player_set_animation +local player_set_animation = mcl_player.player_set_animation -- Check each player and apply animations minetest.register_globalstep(function(dtime) @@ -167,7 +169,7 @@ minetest.register_globalstep(function(dtime) local name = player:get_player_name() local model_name = player_model[name] local model = model_name and models[model_name] - if model and not mcl_core.player_attached[name] then + if model and not mcl_player.player_attached[name] then local controls = player:get_player_control() local walking = false local animation_speed_mod = model.animation_speed or 30 diff --git a/mods/mcl_core/models/character.blend b/mods/mcl_player/models/character.blend similarity index 100% rename from mods/mcl_core/models/character.blend rename to mods/mcl_player/models/character.blend diff --git a/mods/mcl_core/models/character.png b/mods/mcl_player/models/character.png similarity index 100% rename from mods/mcl_core/models/character.png rename to mods/mcl_player/models/character.png diff --git a/mods/mcl_core/models/character.x b/mods/mcl_player/models/character.x similarity index 100% rename from mods/mcl_core/models/character.x rename to mods/mcl_player/models/character.x diff --git a/mods/mcl_core/textures/player.png b/mods/mcl_player/textures/player.png similarity index 100% rename from mods/mcl_core/textures/player.png rename to mods/mcl_player/textures/player.png diff --git a/mods/mcl_core/textures/player_back.png b/mods/mcl_player/textures/player_back.png similarity index 100% rename from mods/mcl_core/textures/player_back.png rename to mods/mcl_player/textures/player_back.png diff --git a/mods/minetest-3d_armor/3d_armor/armor.lua b/mods/minetest-3d_armor/3d_armor/armor.lua index 4254ca19c5..0eaf297a69 100644 --- a/mods/minetest-3d_armor/3d_armor/armor.lua +++ b/mods/minetest-3d_armor/3d_armor/armor.lua @@ -128,7 +128,7 @@ armor.update_player_visuals = function(self, player) end local name = player:get_player_name() if self.textures[name] then - mcl_core.player_set_textures(player, { + mcl_player.player_set_textures(player, { self.textures[name].skin, self.textures[name].armor, self.textures[name].wielditem, @@ -325,7 +325,7 @@ end -- Register Player Model -mcl_core.player_register_model("3d_armor_character.b3d", { +mcl_player.player_register_model("3d_armor_character.b3d", { animation_speed = 30, textures = { armor.default_skin..".png", @@ -366,7 +366,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) minetest.register_on_joinplayer(function(player) - mcl_core.player_set_model(player, "3d_armor_character.b3d") + mcl_player.player_set_model(player, "3d_armor_character.b3d") local name = player:get_player_name() local player_inv = player:get_inventory() local armor_inv = minetest.create_detached_inventory(name.."_armor", { diff --git a/mods/minetest-3d_armor/3d_armor/depends.txt b/mods/minetest-3d_armor/3d_armor/depends.txt index 8e577a9e6b..53a7eca2ef 100644 --- a/mods/minetest-3d_armor/3d_armor/depends.txt +++ b/mods/minetest-3d_armor/3d_armor/depends.txt @@ -1,4 +1,5 @@ mcl_core +mcl_player inventory_plus? unified_inventory? fire? diff --git a/mods/mobs_mc/pig.lua b/mods/mobs_mc/pig.lua index 46ed5ecb2f..f44dbacc5c 100644 --- a/mods/mobs_mc/pig.lua +++ b/mods/mobs_mc/pig.lua @@ -89,14 +89,14 @@ mobs:register_mob("mobs_mc:pig", { if self.driver and clicker == self.driver then self.driver = nil clicker:set_detach() - mcl_core.player_attached[name] = false - mcl_core.player_set_animation(clicker, "stand" , 30) + mcl_player.player_attached[name] = false + mcl_player.player_set_animation(clicker, "stand" , 30) elseif not self.driver and self.saddle == "yes" then self.driver = clicker clicker:set_attach(self.object, "", {x = 0, y = 19, z = 0}, {x = 0, y = 0, z = 0}) - mcl_core.player_attached[name] = true + mcl_player.player_attached[name] = true minetest.after(0.2, function() - mcl_core.player_set_animation(clicker, "sit" , 30) + mcl_player.player_set_animation(clicker, "sit" , 30) end) ----[[ -- ridable pigs