-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaterial_To_GiveName.php
125 lines (111 loc) · 4.66 KB
/
Material_To_GiveName.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
$items = file_get_contents("https://minecraft-ids.grahamedgecombe.com/items.json");
$items = json_decode($items, true);
$itemList = array();
$itemNameList = array();
foreach($items as $item){
$id = $item["type"];
$durability = $item["meta"];
$name = $item["text_type"];
$itemList[$id . ":" . $durability] = ["name" => $name, "id" => $id, "durability" => $durability];
$itemNameList[$name] = ["name" => $name, "id" => $id, "durability" => $durability];
}
$material = file_get_contents(__DIR__ . "/Materials_1.12.2.txt");
$materials = array();
$materialNameList = array();
preg_match_all("/(.+)\(([0-9]+)\)\,/", $material, $m); // Material(int id)
foreach($m[2] as $key => $id){
$text = $m[0][$key];
$name = $m[1][$key];
$name = strtolower($name);
$materials[$id . ":" . "0"] = ["name" => $name, "id" => $id];
$materialNameList[$name] = ["name" => $name, "id" => $id];
$material = str_replace($text, "", $material);
}
preg_match_all("/(.+)\(([0-9]+)\, [0-9]+\)\,/", $material, $m); // Material(int id, int stack)
foreach($m[2] as $key => $id){
$text = $m[0][$key];
$name = $m[1][$key];
$name = strtolower($name);
$materials[$id . ":" . "0"] = ["name" => $name, "id" => $id];
$materialNameList[$name] = ["name" => $name, "id" => $id];
$material = str_replace($text, "", $material);
}
preg_match_all("/(.+)\(([0-9]+)\, [0-9]+\, ([0-9]+)\)\,/", $material, $m); // Material(int id, int stack, int durability)
foreach($m[2] as $key => $id){
$text = $m[0][$key];
$name = $m[1][$key];
$name = strtolower($name);
$durability = $m[3][$key];
$materials[$id . ":" . $durability] = ["name" => $name, "id" => $id, "durability" => $durability];
$materialNameList[$name] = ["name" => $name, "id" => $id, "durability" => $durability];
$material = str_replace($text, "", $material);
}
preg_match_all("/(.+)\(([0-9]+)\, [0-9]+\, [0-9]+\, .+\.class\)\,/", $material, $m); // Material(int id, int stack, int durability, Class<? extends MaterialData> data)
foreach($m[2] as $key => $id){
$text = $m[0][$key];
$name = $m[1][$key];
$name = strtolower($name);
$durability = $m[3][$key];
$materials[$id . ":" . $durability] = ["name" => $name, "id" => $id, "durability" => $durability];
$materialNameList[$name] = ["name" => $name, "id" => $id, "durability" => $durability];
$material = str_replace($text, "", $material);
}
preg_match_all("/(.+)\(([0-9]+)\, [0-9]+\, .+\.class\)\,/", $material, $m); // Material(int id, int stack, Class<? extends MaterialData> data)
foreach($m[2] as $key => $id){
$text = $m[0][$key];
$name = $m[1][$key];
$name = strtolower($name);
$materials[$id . ":" . "0"] = ["name" => $name, "id" => $id];
$materialNameList[$name] = ["name" => $name, "id" => $id];
$material = str_replace($text, "", $material);
}
preg_match_all("/(.+)\(([0-9]+)\, .+\.class\)\,/", $material, $m); // Material(int id, Class<? extends MaterialData> data)
foreach($m[2] as $key => $id){
$text = $m[0][$key];
$name = $m[1][$key];
$name = strtolower($name);
$materials[$id . ":" . "0"] = ["name" => $name, "id" => $id];
$materialNameList[$name] = ["name" => $name, "id" => $id];
$material = str_replace($text, "", $material);
}
foreach($materials as $key => $arr){
$name = $arr["name"];
if(isset($itemList[$key])){
//echo $name . "(" . $key . ") : FOUND\n";
}else{
//echo $name . "(" . $key . ") : NOTFOUND\n";
}
}
//echo "--------------------------------------------------------------\n";
$b = array();
foreach($materialNameList as $key => $arr){
$name = $arr["name"];
$id = $arr["id"];
if(isset($arr["durability"])){
$durability = $arr["durability"];
}else{
$durability = 0;
}
if(isset($itemNameList[$key])){
//echo $name . "(" . $key . ") : FOUND\n";
}else{
if(isset($itemList[$id . ":" . $durability])){
$a = $itemList[$id . ":" . $durability];
echo $name . "(" . $key . " | " . $id . ":" . $durability . ") : NOTFOUND";
echo " -> " . $a["name"] . "\n";
$b[] = "if(MaterialName.equalsIgnoreCase(\"" . $name . "\")) MaterialName = \"" . $a["name"] . "\";";
}else if(isset($itemList[$id . ":0"])){
$a = $itemList[$id . ":0"];
echo " -> " . $a["name"] . "\n";
$b[] = "if(MaterialName.equalsIgnoreCase(\"" . $name . "\")) MaterialName = \"" . $a["name"] . "\";";
}else{
echo $name . "(" . $key . " | " . $id . ":" . $durability . ") : NOTFOUND";
echo "\n";
}
}
}
echo "--------------------------------------------------------------\n";
foreach($b as $one){
echo $one . "\n";
}