Skip to content

Instantly share code, notes, and snippets.

@appgurueu
Created Apr 24, 2022
Embed
What would you like to do?
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 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