Skip to content

Instantly share code, notes, and snippets.

@appgurueu
Last active September 1, 2022 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save appgurueu/dea1d1d9d8494e9c00114d36d58c5932 to your computer and use it in GitHub Desktop.
Save appgurueu/dea1d1d9d8494e9c00114d36d58c5932 to your computer and use it in GitHub Desktop.
Fix for tile bug on Minetest 5.5
-- 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