Last active
September 1, 2022 07:02
-
-
Save appgurueu/dea1d1d9d8494e9c00114d36d58c5932 to your computer and use it in GitHub Desktop.
Fix for tile bug on Minetest 5.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Written by appgurueu, licensed under the MIT license | |
local function patch_tile_texture(tex) | |
if not (tex:match"^%[combine:" or tex:match"^%[inventorycube{") then | |
return | |
end | |
-- Prevent Minetest 5.5 from prepending "blank.png^" for 5.4 and older clients which don't support [png | |
-- See https://github.com/minetest/minetest/pull/12210 | |
return "(" .. tex .. ")" | |
end | |
minetest.register_on_mods_loaded(function() | |
for name, node in pairs(minetest.registered_nodes) do | |
local redef = {} | |
for _, tile_field in pairs{"tiles", "overlay_tiles", "special_tiles"} do | |
local tiles = node[tile_field] | |
if tiles then | |
for index, tile in ipairs(tiles) do | |
if type(tile) == "string" then | |
local patched = patch_tile_texture(tile) | |
if patched then | |
tiles[index] = patched | |
redef[tile_field] = tiles | |
end | |
else | |
local patched = patch_tile_texture(tile.name) | |
if patched then | |
tile.name = patched | |
redef[tile_field] = tiles | |
end | |
end | |
end | |
end | |
end | |
if next(redef) ~= nil then | |
minetest.override_item(name, redef) | |
end | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment