Add itemframe offset
This commit is contained in:
parent
fa7d042169
commit
b490e31075
@ -1,3 +1,10 @@
|
|||||||
|
-- Item frames.
|
||||||
|
|
||||||
|
-- Hint:
|
||||||
|
-- If your item appears behind or too far in front of the item frame, add
|
||||||
|
-- _xdecor_itemframe_offset = <number>
|
||||||
|
-- to your item definition to fix it.
|
||||||
|
|
||||||
local itemframe, tmp = {}, {}
|
local itemframe, tmp = {}, {}
|
||||||
local S = minetest.get_translator("xdecor")
|
local S = minetest.get_translator("xdecor")
|
||||||
screwdriver = screwdriver or {}
|
screwdriver = screwdriver or {}
|
||||||
@ -28,7 +35,15 @@ local function update_item(pos, node)
|
|||||||
local posad = facedir[node.param2]
|
local posad = facedir[node.param2]
|
||||||
if not posad or itemstring == "" then return end
|
if not posad or itemstring == "" then return end
|
||||||
|
|
||||||
pos = vector.add(pos, vector.multiply(posad, 6.5/16))
|
local itemdef = ItemStack(itemstring):get_definition()
|
||||||
|
local offset_plus = 0
|
||||||
|
if itemdef and itemdef._xdecor_itemframe_offset then
|
||||||
|
offset_plus = itemdef._xdecor_itemframe_offset
|
||||||
|
offset_plus = math.min(6, math.max(-6, offset_plus))
|
||||||
|
end
|
||||||
|
local offset = (6.5+offset_plus)/16
|
||||||
|
|
||||||
|
pos = vector.add(pos, vector.multiply(posad, offset))
|
||||||
tmp.nodename = node.name
|
tmp.nodename = node.name
|
||||||
tmp.texture = ItemStack(itemstring):get_name()
|
tmp.texture = ItemStack(itemstring):get_name()
|
||||||
|
|
||||||
@ -154,7 +169,8 @@ xdecor.register("itemframe", {
|
|||||||
on_rightclick = itemframe.rightclick,
|
on_rightclick = itemframe.rightclick,
|
||||||
on_punch = itemframe.punch,
|
on_punch = itemframe.punch,
|
||||||
can_dig = itemframe.dig,
|
can_dig = itemframe.dig,
|
||||||
after_destruct = remove_item
|
after_destruct = remove_item,
|
||||||
|
_xdecor_itemframe_offset = -3.5,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_entity("xdecor:f_item", {
|
minetest.register_entity("xdecor:f_item", {
|
||||||
|
@ -115,7 +115,8 @@ xdecor.register("lever_off", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end,
|
||||||
|
_xdecor_itemframe_offset = -3.5,
|
||||||
})
|
})
|
||||||
|
|
||||||
xdecor.register("lever_on", {
|
xdecor.register("lever_on", {
|
||||||
|
@ -197,7 +197,8 @@ xdecor.register("chair", {
|
|||||||
pos.y = pos.y + 0 -- Sitting position
|
pos.y = pos.y + 0 -- Sitting position
|
||||||
xdecor.sit(pos, node, clicker, pointed_thing)
|
xdecor.sit(pos, node, clicker, pointed_thing)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end,
|
||||||
|
_xdecor_itemframe_offset = -1.5,
|
||||||
})
|
})
|
||||||
|
|
||||||
xdecor.register("cobweb", {
|
xdecor.register("cobweb", {
|
||||||
|
Loading…
Reference in New Issue
Block a user