From 00e54944fad9efb0e13cd2aeee3b71945c0e6404 Mon Sep 17 00:00:00 2001 From: Johannes Fritz Date: Tue, 3 May 2022 09:48:50 -0500 Subject: [PATCH] Fix mcl_maps on Windows --- mods/ITEMS/mcl_maps/init.lua | 10 +++++++--- mods/PLAYER/mcl_wieldview/README.txt | 4 +++- mods/PLAYER/mcl_wieldview/init.lua | 7 ++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_maps/init.lua b/mods/ITEMS/mcl_maps/init.lua index 413e7382a..640147bc5 100644 --- a/mods/ITEMS/mcl_maps/init.lua +++ b/mods/ITEMS/mcl_maps/init.lua @@ -55,7 +55,7 @@ function mcl_maps.create_map(pos) local map_y_start = 64 * dx local map_y_limit = 127 * dx - local pixels = {} + local pixels = "" local last_heightmap for x = 1, 128 do local map_x = x + offset @@ -125,13 +125,15 @@ function mcl_maps.create_map(pos) height = map_y - map_z heightmap[z] = height or minp.y - pixels[#pixels + 1] = color and {r = color[1], g = color[2], b = color[3]} or {r = 0, g = 0, b = 0} + + if not color then color = {0, 0, 0} end + pixels = pixels .. minetest.colorspec_to_bytes({r = color[1], g = color[2], b = color[3]}) end last_heightmap = heightmap end local png = minetest.encode_png(128, 128, pixels) - local f = io.open(map_textures_path .. "mcl_maps_map_texture_" .. id .. ".png", "w") + local f = io.open(map_textures_path .. "mcl_maps_map_texture_" .. id .. ".png", "wb") if not f then return end f:write(png) f:close() @@ -219,6 +221,8 @@ 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.groups.no_wieldview = 1 +filled_wield_def._wieldview_item = "mcl_maps:empty_map" for _, texture in pairs(mcl_skins.list) do local def = table.copy(filled_wield_def) diff --git a/mods/PLAYER/mcl_wieldview/README.txt b/mods/PLAYER/mcl_wieldview/README.txt index b118d9ba6..660974f9b 100644 --- a/mods/PLAYER/mcl_wieldview/README.txt +++ b/mods/PLAYER/mcl_wieldview/README.txt @@ -7,4 +7,6 @@ Makes hand wielded items visible to other players. Info for modders ################ -Add items to the "no_wieldview" group with a raiting of 1 and it will not be shown by the wieldview. +Add an item to the "no_wieldview" group with a rating of 1 and it will not be shown by the wieldview. +If an item has the "no_wieldview" group rating of 1, the item definition can specify the property "_wieldview_item". +"_wieldview_item" should be set to an item name that will be shown by the wieldview instead of the item. diff --git a/mods/PLAYER/mcl_wieldview/init.lua b/mods/PLAYER/mcl_wieldview/init.lua index 660f5edb3..878d60b23 100644 --- a/mods/PLAYER/mcl_wieldview/init.lua +++ b/mods/PLAYER/mcl_wieldview/init.lua @@ -34,7 +34,12 @@ minetest.register_entity("mcl_wieldview:wieldnode", { self._item = item if get_item_group(item, "no_wieldview") ~= 0 then - item = "" + local def = player:get_wielded_item():get_definition() + if def and def._wieldview_item then + item = def._wieldview_item + else + item = "" + end end local item_def = minetest.registered_items[item]