Fix beds & wieldview armor dependency

This commit is contained in:
stujones11 2019-05-31 21:12:31 +01:00 committed by MoNTE48
parent 67795ccf0c
commit 359601fc42
3 changed files with 34 additions and 9 deletions

View File

@ -47,13 +47,24 @@ function beds.register_bed(name, def)
return itemstack return itemstack
end end
local node_def = minetest.registered_nodes[minetest.get_node(pos).name] local pos_front = vector.new(pos)
if not node_def or not node_def.buildable_to then
return itemstack
end
local dir = placer and placer:get_look_dir() and local dir = placer and placer:get_look_dir() and
minetest.dir_to_facedir(placer:get_look_dir()) or 0 minetest.dir_to_facedir(placer:get_look_dir()) % 4 or 0
if dir == 1 then
pos_front.x = pos_front.x + 1
elseif dir == 2 then
pos_front.z = pos_front.z - 1
elseif dir == 3 then
pos_front.x = pos_front.x - 1
else
pos_front.z = pos_front.z + 1
end
for _, p in pairs({pos_front, pos}) do
local node_def = minetest.registered_nodes[minetest.get_node(p).name]
if not node_def or not node_def.buildable_to then
return itemstack
end
end
minetest.set_node(pos, {name = name, param2 = dir}) minetest.set_node(pos, {name = name, param2 = dir})

View File

@ -1 +1,2 @@
3d_armor player_api
3d_armor?

View File

@ -1,3 +1,4 @@
local has_armor = minetest.get_modpath("3d_armor")
local time = 0 local time = 0
local update_time = tonumber(minetest.settings:get("wieldview_update_time")) local update_time = tonumber(minetest.settings:get("wieldview_update_time"))
if not update_time then if not update_time then
@ -17,6 +18,19 @@ wieldview = {
dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua") dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua")
local function update_player_visuals(player, wield_image)
local name = player:get_player_name()
if has_armor then
armor.textures[name].wielditem = wield_image
armor:update_player_visuals(player)
return
end
local animation = player_api.get_animation(player) or {}
local textures = animation.textures or {}
local skin = textures[1] and textures[1] or "character.png"
player_api.set_textures(player, {skin, "blank.png", wield_image})
end
wieldview.get_item_texture = function(self, item) wieldview.get_item_texture = function(self, item)
local texture = "blank.png" local texture = "blank.png"
if item ~= "" then if item ~= "" then
@ -57,8 +71,7 @@ wieldview.update_wielded_item = function(self, player)
if self.wielded_item[name] == item then if self.wielded_item[name] == item then
return return
end end
armor.textures[name].wielditem = self:get_item_texture(item) update_player_visuals(player, self:get_item_texture(item))
armor:update_player_visuals(player)
end end
self.wielded_item[name] = item self.wielded_item[name] = item
end end