Merge pull request 'Remove image stack wieldview' (#2333) from MrRar/MineClone2:wieldview into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2333 Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
commit
26a4b3d895
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -390,7 +390,7 @@ minetest.register_tool("mcl_fishing:fishing_rod", {
|
|||
_doc_items_usagehelp = S("Rightclick to launch the bobber. When it sinks right-click again to reel in an item. Who knows what you're going to catch?"),
|
||||
groups = { tool=1, fishing_rod=1, enchantability=1 },
|
||||
inventory_image = "mcl_fishing_fishing_rod.png",
|
||||
wield_image = "mcl_fishing_fishing_rod.png^[transformR270",
|
||||
wield_image = "mcl_fishing_fishing_rod.png^[transformFY^[transformR90",
|
||||
wield_scale = { x = 1.5, y = 1.5, z = 1 },
|
||||
stack_max = 1,
|
||||
on_place = fish,
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 359 B |
|
@ -227,6 +227,7 @@ filled_wield_def.drawtype = "mesh"
|
|||
filled_wield_def.node_placement_prediction = ""
|
||||
filled_wield_def.range = minetest.registered_items[""].range
|
||||
filled_wield_def.on_place = mcl_util.call_on_rightclick
|
||||
filled_wield_def._mcl_wieldview_item = "mcl_maps:filled_map"
|
||||
|
||||
for _, texture in pairs(mcl_skins.list) do
|
||||
local def = table.copy(filled_wield_def)
|
||||
|
|
|
@ -321,7 +321,7 @@ minetest.register_tool("mcl_mobitems:carrot_on_a_stick", {
|
|||
_tt_help = S("Lets you ride a saddled pig"),
|
||||
_doc_items_longdesc = S("A carrot on a stick can be used on saddled pigs to ride them."),
|
||||
_doc_items_usagehelp = S("Place it on a saddled pig to mount it. You can now ride the pig like a horse. Pigs will also walk towards you when you just wield the carrot on a stick."),
|
||||
wield_image = "mcl_mobitems_carrot_on_a_stick.png",
|
||||
wield_image = "mcl_mobitems_carrot_on_a_stick.png^[transformFY^[transformR90",
|
||||
inventory_image = "mcl_mobitems_carrot_on_a_stick.png",
|
||||
groups = { transport = 1 },
|
||||
_mcl_toollike_wield = true,
|
||||
|
|
|
@ -31,12 +31,12 @@ minetest.register_tool("mcl_shields:shield", {
|
|||
shield = 1,
|
||||
weapon = 1,
|
||||
enchantability = -1,
|
||||
no_wieldview = 1,
|
||||
offhand_item = 1,
|
||||
},
|
||||
sound = {breaks = "default_tool_breaks"},
|
||||
_repair_material = "group:wood",
|
||||
wield_scale = vector.new(2, 2, 2),
|
||||
_mcl_wieldview_item = "",
|
||||
})
|
||||
|
||||
local function wielded_item(obj, i)
|
||||
|
@ -438,7 +438,6 @@ for _, colortab in pairs(mcl_banners.colors) do
|
|||
shield = 1,
|
||||
weapon = 1,
|
||||
enchantability = -1,
|
||||
no_wieldview = 1,
|
||||
not_in_creative_inventory = 1,
|
||||
offhand_item = 1,
|
||||
},
|
||||
|
@ -446,6 +445,7 @@ for _, colortab in pairs(mcl_banners.colors) do
|
|||
_repair_material = "group:wood",
|
||||
wield_scale = vector.new(2, 2, 2),
|
||||
_shield_color = colortab[4],
|
||||
_mcl_wieldview_item = "",
|
||||
})
|
||||
|
||||
local banner = "mcl_banners:banner_item_" .. color
|
||||
|
|
|
@ -103,10 +103,6 @@ function mcl_player.player_set_armor(player, texture)
|
|||
set_texture(player, 2, texture)
|
||||
end
|
||||
|
||||
function mcl_player.player_set_wielditem(player, texture)
|
||||
set_texture(player, 3, texture)
|
||||
end
|
||||
|
||||
function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname)
|
||||
local name = player:get_player_name()
|
||||
local model = player_model[name]
|
||||
|
|
|
@ -359,15 +359,17 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
|
||||
if wielded_def and wielded_def._mcl_toollike_wield then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,3.9,1.3), vector.new(90,0,0))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,4.7,3.1), vector.new(-90,225,90))
|
||||
elseif string.find(wielded:get_name(), "mcl_bows:bow") then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(.5,4.5,-1.6), vector.new(90,0,20))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(1,4,0), vector.new(90,130,115))
|
||||
elseif string.find(wielded:get_name(), "mcl_bows:crossbow_loaded") then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(-1.5,5.7,1.8), vector.new(64,90,0))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,5.2,1.2), vector.new(0,180,73))
|
||||
elseif string.find(wielded:get_name(), "mcl_bows:crossbow") then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(-1.5,5.7,1.8), vector.new(90,90,0))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,5.2,1.2), vector.new(0,180,45))
|
||||
elseif wielded_def.inventory_image == "" then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,6,2), vector.new(180,-45,0))
|
||||
else
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(-1.5,4.9,1.8), vector.new(135,0,90))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,5.3,2), vector.new(90,0,0))
|
||||
end
|
||||
|
||||
-- controls right and left arms pitch when shooting a bow or blocking
|
||||
|
|
|
@ -1,21 +1,13 @@
|
|||
[mod] visible wielded items [wieldview]
|
||||
[mod] visible wielded items [mcl_wieldview]
|
||||
=======================================
|
||||
|
||||
Makes hand wielded items visible to other players.
|
||||
|
||||
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
|
||||
|
||||
|
||||
Info for modders
|
||||
################
|
||||
|
||||
Wield image transformation: To apply a simple transformation to the item in
|
||||
hand, add the group “wieldview_transform” to the item definition. The group
|
||||
rating equals one of the numbers used for the [transform texture modifier
|
||||
of the Lua API.
|
||||
Register an item with the property "_mcl_wieldview_item" to change the third person wield view appearance of the item.
|
||||
"_mcl_wieldview_item" should be set to an item name that will be shown by the wield view instead of the item.
|
||||
If you use an empty string, nothing will be shown.
|
||||
|
||||
|
|
|
@ -1,126 +1,64 @@
|
|||
local get_connected_players = minetest.get_connected_players
|
||||
local get_item_group = minetest.get_item_group
|
||||
|
||||
mcl_wieldview = {
|
||||
players = {}
|
||||
}
|
||||
|
||||
function mcl_wieldview.get_item_texture(itemname)
|
||||
if itemname == "" or minetest.get_item_group(itemname, "no_wieldview") ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local def = minetest.registered_items[itemname]
|
||||
if not def then
|
||||
return
|
||||
end
|
||||
|
||||
local inv_image = def.inventory_image
|
||||
if inv_image == "" then
|
||||
return
|
||||
end
|
||||
|
||||
local texture = inv_image
|
||||
|
||||
local transform = get_item_group(itemname, "wieldview_transform")
|
||||
if transform then
|
||||
-- This actually works with groups ratings because transform1, transform2, etc.
|
||||
-- have meaning and transform0 is used for identidy, so it can be ignored
|
||||
texture = texture .. "^[transform" .. transform
|
||||
end
|
||||
|
||||
return texture
|
||||
end
|
||||
|
||||
function mcl_wieldview.update_wielded_item(player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local itemstack = player:get_wielded_item()
|
||||
local itemname = itemstack:get_name()
|
||||
|
||||
local def = mcl_wieldview.players[player]
|
||||
|
||||
if def.item == itemname then
|
||||
return
|
||||
end
|
||||
|
||||
def.item = itemname
|
||||
def.texture = mcl_wieldview.get_item_texture(itemname) or "blank.png"
|
||||
|
||||
mcl_player.player_set_wielditem(player, def.texture)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
mcl_wieldview.players[player] = {item = "", texture = "blank.png"}
|
||||
|
||||
minetest.after(0, function()
|
||||
if not player:is_player() then
|
||||
return
|
||||
end
|
||||
|
||||
mcl_wieldview.update_wielded_item(player)
|
||||
|
||||
local itementity = minetest.add_entity(player:get_pos(), "mcl_wieldview:wieldnode")
|
||||
itementity:set_attach(player, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 0, 45))
|
||||
itementity:get_luaentity().wielder = player
|
||||
end)
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
mcl_wieldview.players[player] = nil
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function()
|
||||
local players = get_connected_players()
|
||||
for i = 1, #players do
|
||||
mcl_wieldview.update_wielded_item(players[i])
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_entity("mcl_wieldview:wieldnode", {
|
||||
minetest.register_entity("mcl_wieldview:wieldview", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
visual = "wielditem",
|
||||
physical = false,
|
||||
textures = {""},
|
||||
automatic_rotate = 1.5,
|
||||
is_visible = true,
|
||||
is_visible = false,
|
||||
pointable = false,
|
||||
collide_with_objects = false,
|
||||
static_save = false,
|
||||
collisionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21},
|
||||
selectionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21},
|
||||
visual_size = {x = 0.21, y = 0.21},
|
||||
},
|
||||
|
||||
itemstring = "",
|
||||
|
||||
on_step = function(self)
|
||||
if self.wielder:is_player() then
|
||||
local def = mcl_wieldview.players[self.wielder]
|
||||
local itemstring = def.item
|
||||
|
||||
if self.itemstring ~= itemstring then
|
||||
local itemdef = minetest.registered_items[itemstring]
|
||||
self.object:set_properties({glow = itemdef and itemdef.light_source or 0})
|
||||
|
||||
-- wield item as cubic
|
||||
if def.texture == "blank.png" then
|
||||
self.object:set_properties({textures = {itemstring}})
|
||||
-- wield item as flat
|
||||
else
|
||||
self.object:set_properties({textures = {""}})
|
||||
end
|
||||
|
||||
if minetest.get_item_group(itemstring, "no_wieldview") ~= 0 then
|
||||
self.object:set_properties({textures = {""}})
|
||||
end
|
||||
|
||||
self.itemstring = itemstring
|
||||
end
|
||||
else
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
}
|
||||
})
|
||||
|
||||
local wieldview_luaentites = {}
|
||||
|
||||
local function update_wieldview_entity(player)
|
||||
local luaentity = wieldview_luaentites[player]
|
||||
if luaentity and luaentity.object:get_yaw() then
|
||||
local item = player:get_wielded_item():get_name()
|
||||
|
||||
if item == luaentity._item then return end
|
||||
|
||||
luaentity._item = item
|
||||
|
||||
local def = player:get_wielded_item():get_definition()
|
||||
if def and def._mcl_wieldview_item then
|
||||
item = def._mcl_wieldview_item
|
||||
end
|
||||
|
||||
local item_def = minetest.registered_items[item]
|
||||
luaentity.object:set_properties({
|
||||
glow = item_def and item_def.light_source or 0,
|
||||
wield_item = item,
|
||||
is_visible = item ~= ""
|
||||
})
|
||||
else
|
||||
-- If the player is running through an unloaded area,
|
||||
-- the wieldview entity will sometimes get unloaded.
|
||||
-- This code path is also used to initalize the wieldview.
|
||||
-- Creating entites from minetest.register_on_joinplayer
|
||||
-- is unreliable as of Minetest 5.6
|
||||
local obj_ref = minetest.add_entity(player:get_pos(), "mcl_wieldview:wieldview")
|
||||
if not obj_ref then return end
|
||||
obj_ref:set_attach(player, "Wield_Item")
|
||||
--obj_ref:set_attach(player, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 45, 90))
|
||||
wieldview_luaentites[player] = obj_ref:get_luaentity()
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
if wieldview_luaentites[player] then
|
||||
wieldview_luaentites[player].object:remove()
|
||||
end
|
||||
wieldview_luaentites[player] = nil
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local players = minetest.get_connected_players()
|
||||
for i, player in pairs(players) do
|
||||
update_wieldview_entity(player)
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name = mcl_wieldview
|
||||
author = stujones11
|
||||
description = Makes hand wielded items visible to other players.
|
||||
depends = mcl_player
|
||||
depends = mcl_armor, mcl_playerplus
|
||||
|
|
Loading…
Reference in New Issue
Block a user