mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-09-02 02:27:56 +00:00
Update and rename all resources
- Languages are converted to JSON - Rename most *(_advanced) blocks to *_{advanced,normal}. It's more verbose, but means they're sorted together. - A couple of changes to the ROM to work with some Java changes. - Update recipes and advancements to not use damage values.
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
"type": "computercraft:impostor_shapeless",
|
||||
"group": "computercraft:disk",
|
||||
"ingredients": [
|
||||
{ "type": "forge:ore_dict", "ore": "dustRedstone" },
|
||||
{ "type": "forge:ore_dict", "ore": "paper" },
|
||||
{ "item": "minecraft:dye", "data": ${dye} }
|
||||
{ "tag": "forge:dusts/redstone" },
|
||||
{ "item": "minecraft:paper" },
|
||||
{ "item": "${dye}" }
|
||||
],
|
||||
"result": { "item": "computercraft:disk_expanded", "data": 0, "nbt": { "color": ${colour} } }
|
||||
"result": { "item": "computercraft:disk", "nbt": { "color": ${colour} } }
|
||||
}
|
||||
|
@@ -29,25 +29,26 @@ local secondary = {
|
||||
|
||||
local verbose = false
|
||||
|
||||
local path = "src/main/resources/assets/computercraft/lang/%s.lang"
|
||||
local path = "src/main/resources/assets/computercraft/lang/%s.json"
|
||||
|
||||
|
||||
local args = {...}
|
||||
local args = { ... }
|
||||
for i = #args, 1, -1 do
|
||||
if args[i] == "-v" or args[i] == "--verbose" then
|
||||
table.remove(args, i)
|
||||
verbose = true
|
||||
end
|
||||
end
|
||||
if #args > 0 then secondary = args end
|
||||
if #args > 0 then
|
||||
secondary = args
|
||||
end
|
||||
|
||||
-- Read the contents of the primary language file
|
||||
local primary_contents, n = {}, 1
|
||||
for line in io.lines(path:format(primary)) do
|
||||
local key = line:match("^([^=]+)=.*$")
|
||||
local key = line:match('^%s*"([^"]+)":.*$')
|
||||
if key then
|
||||
primary_contents[n], n = key, n + 1
|
||||
elseif line == "" or line:sub(1, 1) == "#" then
|
||||
elseif line == "" or line == "{" or line == "}" then
|
||||
primary_contents[n], n = line, n + 1
|
||||
else
|
||||
io.stderr:write(("Unknown line %q in %s\n"):format(line, primary))
|
||||
@@ -59,7 +60,7 @@ for _, language in ipairs(secondary) do
|
||||
local keys = {}
|
||||
|
||||
for line in io.lines(path:format(language)) do
|
||||
local key, value = line:match("^([^=]+)=(.*)$")
|
||||
local key, value = line:match('^%s*"([^"]+)":%s*(.-),?$')
|
||||
if key then
|
||||
if keys[key] then
|
||||
io.stderr:write(("Duplicate keys for %q in %q\n"):format(key, language))
|
||||
@@ -67,29 +68,28 @@ for _, language in ipairs(secondary) do
|
||||
end
|
||||
|
||||
keys[key] = value
|
||||
elseif line ~= "" and line:sub(1, 1) ~= "#" then
|
||||
elseif line ~= "" and line ~= "{" and line ~= "}" then
|
||||
io.stderr:write(("Unknown line %q in %s\n"):format(line, language))
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
local h = io.open(path:format(language), "wb")
|
||||
local previous_blank = true
|
||||
h:write("{")
|
||||
local has_blank, has_any = false, false
|
||||
for _, line in ipairs(primary_contents) do
|
||||
if line == "" then
|
||||
if not previous_blank then
|
||||
previous_blank = true
|
||||
h:write("\n")
|
||||
end
|
||||
elseif line:sub(1, 1) == "#" then
|
||||
h:write(line .. "\n")
|
||||
previous_blank = false
|
||||
if line == "{" or line == "}" then
|
||||
-- Skip
|
||||
elseif line == "" then
|
||||
has_blank = true
|
||||
else
|
||||
local translated = keys[line]
|
||||
if translated then
|
||||
h:write(("%s=%s\n"):format(line, translated))
|
||||
if has_any then h:write(",") else has_any = true end
|
||||
if has_blank then h:write("\n") has_blank = false end
|
||||
|
||||
h:write(("\n %q: %s"):format(line, translated))
|
||||
keys[line] = nil
|
||||
previous_blank = false
|
||||
elseif verbose then
|
||||
io.stderr:write(("Missing translation %q for %q\n"):format(line, language))
|
||||
end
|
||||
@@ -98,15 +98,22 @@ for _, language in ipairs(secondary) do
|
||||
|
||||
if next(keys) ~= nil then
|
||||
local extra = {}
|
||||
for k, v in pairs(keys) do extra[#extra + 1] = ("%s=%s\n"):format(k, v) end
|
||||
for k, v in pairs(keys) do
|
||||
extra[#extra + 1] = ("\n %q: %s"):format(k, v)
|
||||
end
|
||||
table.sort(extra)
|
||||
|
||||
io.stderr:write(("%d additional unknown translation keys in %q\n"):format(#extra, language))
|
||||
|
||||
if not previous_blank then h:write("\n") end
|
||||
h:write("#Unknown translations\n")
|
||||
for _, line in ipairs(extra) do h:write(line) end
|
||||
has_blank = true
|
||||
|
||||
for _, line in ipairs(extra) do
|
||||
if has_any then h:write(",") else has_any = true end
|
||||
if has_blank then h:write("\n") has_blank = false end
|
||||
h:write(line)
|
||||
end
|
||||
end
|
||||
|
||||
h:write("\n}\n")
|
||||
h:close()
|
||||
end
|
||||
|
@@ -8,8 +8,8 @@
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{ "item": "computercraft:pocket_computer", "data": ${pocket_data} },
|
||||
{ "item": ${upgrade_item} }
|
||||
{ "item": "computercraft:pocket_computer_${pocket_family}" },
|
||||
{ "item": "${upgrade_item}" }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@@ -6,8 +6,8 @@
|
||||
"T"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": ${upgrade_item} },
|
||||
"T": { "item": "computercraft:pocket_computer", "data": ${pocket_data} }
|
||||
"#": { "item": "${upgrade_item}" },
|
||||
"T": { "item": "computercraft:pocket_computer_${pocket_family}" }
|
||||
},
|
||||
"result": { "item": "computercraft:pocket_computer", "data": ${pocket_data}, "nbt": { "upgrade": "${upgrade_id}" } }
|
||||
"result": { "item": "computercraft:pocket_computer_${pocket_family}", "nbt": { "Upgrade": "${upgrade_id}" } }
|
||||
}
|
||||
|
@@ -10,9 +10,9 @@
|
||||
|
||||
--- All turtle upgrades, and an optional item for this upgrade.
|
||||
local turtle_upgrades = {
|
||||
{ "computercraft:wireless_modem", '"computercraft:peripheral", "data": 1' },
|
||||
{ "computercraft:advanced_modem" },
|
||||
{ "computercraft:speaker", '"computercraft:peripheral", "data": 5' },
|
||||
{ "computercraft:wireless_modem_normal" },
|
||||
{ "computercraft:wireless_modem_advanced" },
|
||||
{ "computercraft:speaker" },
|
||||
{ "minecraft:crafting_table" },
|
||||
{ "minecraft:diamond_sword" },
|
||||
{ "minecraft:diamond_shovel" },
|
||||
@@ -23,29 +23,29 @@ local turtle_upgrades = {
|
||||
|
||||
--- All pocket upgrades, and an optional item for this upgrade.
|
||||
local pocket_upgrades = {
|
||||
{ "computercraft:wireless_modem", '"computercraft:peripheral", "data": 1' },
|
||||
{ "computercraft:advanced_modem" },
|
||||
{ "computercraft:speaker", '"computercraft:peripheral", "data": 5' },
|
||||
{ "computercraft:wireless_modem_normal" },
|
||||
{ "computercraft:wireless_modem_advanced" },
|
||||
{ "computercraft:speaker" },
|
||||
}
|
||||
|
||||
--- All dye/disk colours
|
||||
local colours = {
|
||||
0x111111,
|
||||
0xcc4c4c,
|
||||
0x57A64E,
|
||||
0x7f664c,
|
||||
0x3366cc,
|
||||
0xb266e5,
|
||||
0x4c99b2,
|
||||
0x999999,
|
||||
0x4c4c4c,
|
||||
0xf2b2cc,
|
||||
0x7fcc19,
|
||||
0xdede6c,
|
||||
0x99b2f2,
|
||||
0xe57fd8,
|
||||
0xf2b233,
|
||||
0xf0f0f0;
|
||||
{ 0x111111, "minecraft:ink_sac" },
|
||||
{ 0xcc4c4c, "minecraft:rose_red" },
|
||||
{ 0x57A64E, "minecraft:cactus_green" },
|
||||
{ 0x7f664c, "minecraft:cocoa_beans" },
|
||||
{ 0x3366cc, "minecraft:lapis_lazuli" },
|
||||
{ 0xb266e5, "minecraft:purple_dye" },
|
||||
{ 0x4c99b2, "minecraft:cyan_dye" },
|
||||
{ 0x999999, "minecraft:light_gray_dye" },
|
||||
{ 0x4c4c4c, "minecraft:gray_dye" },
|
||||
{ 0xf2b2cc, "minecraft:pink_dye" },
|
||||
{ 0x7fcc19, "minecraft:lime_dye" },
|
||||
{ 0xdede6c, "minecraft:dandelion_yellow" },
|
||||
{ 0x99b2f2, "minecraft:light_blue_dye" },
|
||||
{ 0xe57fd8, "minecraft:magenta_dye" },
|
||||
{ 0xf2b233, "minecraft:orange_dye" },
|
||||
{ 0xf0f0f0, "minecraft:bone_meal" },
|
||||
}
|
||||
|
||||
--- Read the provided file into a string, exiting the program if not found.
|
||||
@@ -82,44 +82,44 @@ end
|
||||
--- Format template strings of the form `${key}` using the given substituion
|
||||
-- table.
|
||||
local function template(str, subs)
|
||||
return str:gsub("%$%{([^}]+)%}", function(k) return subs[k] or error("Unknown key " .. k) end)
|
||||
return str:gsub("%$%{([^}]+)%}", function(k)
|
||||
return subs[k] or error("Unknown key " .. k)
|
||||
end)
|
||||
end
|
||||
|
||||
-- Write turtle upgrades
|
||||
local turtle_recipe = read_all "tools/turtle_upgrade_recipe.json"
|
||||
local turtle_advance = read_all "tools/turtle_upgrade_advancement.json"
|
||||
for _, turtle in ipairs { { "normal", "computercraft:turtle_expanded" }, { "advanced", "computercraft:turtle_advanced" } } do
|
||||
local turtle_family, turtle_item = turtle[1], turtle[2]
|
||||
for _, turtle_family in ipairs { "normal", "advanced" } do
|
||||
for _, upgrade in ipairs(turtle_upgrades) do
|
||||
local upgrade_id, upgrade_item = upgrade[1], upgrade[2] or ('"%s"'):format(upgrade[1])
|
||||
local upgrade_id, upgrade_item = upgrade[1], upgrade[2] or upgrade[1]
|
||||
local path = ("generated/turtle_%s/%s"):format(turtle_family, (upgrade_id:gsub(":", "_")))
|
||||
local keys = {
|
||||
upgrade_id = upgrade_id, upgrade_item = upgrade_item,
|
||||
turtle_family = turtle_family, turtle_item = turtle_item,
|
||||
turtle_family = turtle_family,
|
||||
path = path,
|
||||
}
|
||||
|
||||
write_all("src/main/resources/assets/computercraft/recipes/" .. path .. ".json", template(turtle_recipe, keys))
|
||||
write_all("src/main/resources/assets/computercraft/advancements/recipes/" .. path .. ".json", template(turtle_advance, keys))
|
||||
write_all("src/main/resources/data/computercraft/recipes/" .. path .. ".json", template(turtle_recipe, keys))
|
||||
write_all("src/main/resources/data/computercraft/advancements/recipes/" .. path .. ".json", template(turtle_advance, keys))
|
||||
end
|
||||
end
|
||||
|
||||
-- Write pocket upgrades
|
||||
local pocket_recipe = read_all "tools/pocket_upgrade_recipe.json"
|
||||
local pocket_advance = read_all "tools/pocket_upgrade_advancement.json"
|
||||
for _, pocket in ipairs { { "normal", "0" }, { "advanced", "1" } } do
|
||||
local pocket_family, pocket_data = pocket[1], pocket[2]
|
||||
for _, pocket_family in ipairs { "normal", "advanced" } do
|
||||
for _, upgrade in ipairs(pocket_upgrades) do
|
||||
local upgrade_id, upgrade_item = upgrade[1], upgrade[2] or ('"%s"'):format(upgrade[1])
|
||||
local upgrade_id, upgrade_item = upgrade[1], upgrade[2] or upgrade[1]
|
||||
local path = ("generated/pocket_%s/%s"):format(pocket_family, (upgrade_id:gsub(":", "_")))
|
||||
local keys = {
|
||||
upgrade_id = upgrade_id, upgrade_item = upgrade_item,
|
||||
pocket_family = pocket_family, pocket_data = pocket_data,
|
||||
pocket_family = pocket_family,
|
||||
path = path,
|
||||
}
|
||||
|
||||
write_all("src/main/resources/assets/computercraft/recipes/" .. path .. ".json", template(pocket_recipe, keys))
|
||||
write_all("src/main/resources/assets/computercraft/advancements/recipes/" .. path .. ".json", template(pocket_advance, keys))
|
||||
write_all("src/main/resources/data/computercraft/recipes/" .. path .. ".json", template(pocket_recipe, keys))
|
||||
write_all("src/main/resources/data/computercraft/advancements/recipes/" .. path .. ".json", template(pocket_advance, keys))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -128,9 +128,9 @@ local disk_recipe = read_all "tools/disk_recipe.json"
|
||||
for i, colour in ipairs(colours) do
|
||||
local path = ("generated/disk/disk_%s"):format(i)
|
||||
local keys = {
|
||||
dye = i - 1, colour = colour,
|
||||
path = path,
|
||||
}
|
||||
dye = colour[2], colour = colour[1],
|
||||
path = path,
|
||||
}
|
||||
|
||||
write_all("src/main/resources/assets/computercraft/recipes/" .. path .. ".json", template(disk_recipe, keys))
|
||||
write_all("src/main/resources/data/computercraft/recipes/" .. path .. ".json", template(disk_recipe, keys))
|
||||
end
|
||||
|
@@ -8,8 +8,8 @@
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{ "item": "${turtle_item}", "data": 0 },
|
||||
{ "item": ${upgrade_item} }
|
||||
{ "item": "computercraft:turtle_${turtle_family}" },
|
||||
{ "item": "${upgrade_item}" }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@@ -5,8 +5,8 @@
|
||||
"#T"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": ${upgrade_item} },
|
||||
"T": { "item": "${turtle_item}", "data": 0 }
|
||||
"#": { "item": "${upgrade_item}" },
|
||||
"T": { "item": "computercraft:turtle_${turtle_family}" }
|
||||
},
|
||||
"result": { "item": "${turtle_item}", "data": 0, "nbt": { "rightUpgrade": "${upgrade_id}" } }
|
||||
"result": { "item": "computercraft:turtle_${turtle_family}", "nbt": { "RightUpgrade": "${upgrade_id}" } }
|
||||
}
|
||||
|
Reference in New Issue
Block a user