Skip to content

Commit 049b482

Browse files
Updated craftle words
Updated to 1.21.10 Fixed words with %s and $1 in them also
1 parent 35ce6d8 commit 049b482

File tree

2 files changed

+76
-48
lines changed

2 files changed

+76
-48
lines changed

craftle.html

Lines changed: 30 additions & 3 deletions
Large diffs are not rendered by default.

tools/craftle.html

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,56 +16,52 @@
1616
$('upload').onchange = function() {
1717
var fr = new FileReader();
1818

19-
fr.onload = function(e) {
19+
fr.onload = async function(e) {
20+
21+
2022
var result = JSON.parse(e.target.result);
2123
console.log(result);
2224
for (let key in result) {
2325
if (
24-
key.startsWith('block.') ||
25-
key.startsWith('death.') ||
26-
key.startsWith('container.') ||
27-
key.startsWith('advancements.') ||
28-
key.startsWith('biome.') ||
29-
key.startsWith('color.') ||
30-
key.startsWith('createWorld.') ||
31-
key.startsWith('deathScreen.') ||
32-
key.startsWith('effect.') ||
33-
key.startsWith('enchantment.') ||
34-
key.startsWith('entity.') ||
35-
key.startsWith('gamerule.') ||
36-
key.startsWith('item.') ||
37-
key.startsWith('itemGroup.') ||
38-
key.startsWith('jukebox_song.') ||
39-
key.startsWith('key.') ||
40-
key.startsWith('menu.') ||
41-
key.startsWith('merchant.') ||
42-
key.startsWith('options.') ||
43-
key.startsWith('painting.') ||
44-
key.startsWith('soundCategory.') ||
45-
key.startsWith('spectatorMenu.') ||
46-
key.startsWith('stat.') ||
47-
key.startsWith('structure.') ||
48-
key.startsWith('subtitles.') ||
49-
key.startsWith('telemetry.') ||
50-
key.startsWith('trim_material.') ||
51-
key.startsWith('tutorial.')
26+
key.startsWith('block.')
27+
|| key.startsWith('death.')
28+
|| key.startsWith('container.')
29+
|| key.startsWith('advancements.')
30+
|| key.startsWith('biome.')
31+
|| key.startsWith('color.')
32+
|| key.startsWith('createWorld.')
33+
|| key.startsWith('deathScreen.')
34+
|| key.startsWith('effect.')
35+
|| key.startsWith('enchantment.')
36+
|| key.startsWith('entity.')
37+
|| key.startsWith('item.')
38+
|| key.startsWith('itemGroup.')
39+
|| key.startsWith('jukebox_song.')
40+
|| key.startsWith('key.')
41+
|| key.startsWith('merchant.')
42+
|| key.startsWith('painting.')
43+
|| key.startsWith('soundCategory.')
44+
|| key.startsWith('spectatorMenu.')
45+
|| key.startsWith('stat.')
46+
|| key.startsWith('structure.')
47+
|| key.startsWith('subtitles.')
48+
|| key.startsWith('trim_material.')
49+
|| key.startsWith('tutorial.')
5250
) {
53-
let value = result[key];
54-
value = value
55-
.replace(/[^a-z ]/gi, '')
56-
.replace(/ +(?= )/g,'')
57-
.toLowerCase();
58-
if (value.replaceAll(" ","").length<3) continue;
59-
let words = value
60-
.split(" ")
61-
.filter(a => a.length > 2);
62-
words.push(value.replaceAll(" ",""));
51+
let fullPhrase = result[key];
52+
let cleanedPhrase = fullPhrase.toLowerCase();
53+
let words = cleanedPhrase.split(" ");
54+
words.push(cleanedPhrase.replaceAll(" ","")); // add entire phrase with spaces removed (eg craftingtable)
55+
let cleanedWords = words.filter(w => !w.includes("%") && !w.includes("$"))
56+
.map(w => w.replace(/[^a-z ]/g, ''));
6357

64-
for (let word of words) {
65-
if (word in output) {
66-
output[word].push(result[key]);
67-
} else {
68-
output[word] = [result[key]];
58+
for (let cleanword of cleanedWords) {
59+
if (cleanword.length > 2) {
60+
if (cleanword in output) {
61+
output[cleanword].push(result[key]);
62+
} else {
63+
output[cleanword] = [result[key]];
64+
}
6965
}
7066
}
7167
}
@@ -75,7 +71,7 @@
7571
(a, b) =>
7672
// pick b if it's shorter, or same length but a has '%' and b doesn't
7773
b.length < a.length ||
78-
(b.length === a.length && a.includes('%') && !b.includes('%'))
74+
(b.length === a.length && a.includes('%') && !b.includes('%') && a.includes('$') && !b.includes('$'))
7975
? b
8076
: a
8177
)
@@ -96,10 +92,15 @@
9692

9793
alert(i+" found");
9894
$('out').value = JSON.stringify(outputSorted);
95+
for (let numLetters in outputSorted) {
96+
console.log(numLetters + ": " + Object.keys(outputSorted[numLetters]).length)
97+
}
9998
}
10099

101100
fr.readAsText($('upload').files[0]);
102101
}
102+
103+
103104

104105
</script>
105106
</body>

0 commit comments

Comments
 (0)