Put a upper limit for sprite creation

This commit is contained in:
Jean-Patrick Guerrero 2022-06-19 14:43:39 +02:00
parent 56cb236025
commit 563dc719d0
3 changed files with 12 additions and 6 deletions

View File

@ -33,21 +33,24 @@ local function cache_groups(group, groups)
local c = 0
local px = 256
local limit = 10
local sprite = "[combine:WxH"
for _, item in ipairs(items) do
local def = reg_items[item]
local texture = def.inventory_image or def.wield_image
local texture = def.inventory_image
if true_str(texture) then
texture = texture:gsub("%^", "\\^"):gsub(":", "\\:") .. "\\^[resize\\:150x150"
elseif is_cube(def.drawtype) then
texture = get_cube(def.tiles)
local tiles = def.tiles or def.tile_images
texture = get_cube(tiles)
end
if true_str(texture) then
sprite = sprite .. fmt(":0,%u=%s", c * px, texture)
c++
if c == limit then break end
end
end
@ -330,7 +333,8 @@ local function init_cubes()
local id = core.get_content_id(name)
if is_cube(def.drawtype) then
i3.cubes[id] = get_cube(def.tiles)
local tiles = def.tiles or def.tile_images
i3.cubes[id] = get_cube(tiles)
elseif sub(def.drawtype, 1, 9) == "plantlike" or sub(def.drawtype, 1, 8) == "firelike" then
i3.plants[id] = def.inventory_image
end

View File

@ -11,6 +11,7 @@ i3.group_stereotypes = {
stone = "default:stone",
leaves = "default:leaves",
coal = "default:coal_lump",
fence = "default:fence_wood",
vessel = "vessels:glass_bottle",
flower = "flowers:dandelion_yellow",
water_bucket = "bucket:bucket_water",
@ -26,6 +27,7 @@ i3.group_names = {
glass = S"Any glass",
stick = S"Any stick",
stone = S"Any stone",
fence = S"Any fence",
carpet = S"Any carpet",
flower = S"Any flower",
leaves = S"Any leaves",

View File

@ -18,7 +18,7 @@ IMPORT("S", "ES", "translate", "ItemStack", "toupper")
IMPORT("get_sorting_idx", "compression_active", "compressible")
IMPORT("get_bag_description", "get_detached_inv", "get_recipes")
IMPORT("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
IMPORT("get_group_stereotype", "extract_groups", "is_group", "item_has_groups", "get_group")
IMPORT("get_group_stereotype", "extract_groups", "groups_to_items", "is_group", "item_has_groups", "get_group")
local function fmt(elem, ...)
if not fs_elements[elem] then
@ -997,8 +997,8 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
if is_group(name) then
groups = group_cache and group_cache.groups or extract_groups(name)
name = group_cache and group_cache.stereotype or
get_group_stereotype(groups[1]) or group_cache.items[1]
name = group_cache and (group_cache.stereotype or group_cache.items[1]) or
get_group_stereotype(groups[1]) or groups_to_items(groups)[1]
end
local label = groups and "\nG" or ""