4
4
import com .github .franckyi .ibeeditor .client .screen .model .selection .element .*;
5
5
import com .github .franckyi .ibeeditor .common .ColoredItemHelper ;
6
6
import net .minecraft .client .Minecraft ;
7
+ import net .minecraft .core .HolderLookup ;
7
8
import net .minecraft .core .Registry ;
9
+ import net .minecraft .core .registries .BuiltInRegistries ;
10
+ import net .minecraft .core .registries .Registries ;
11
+ import net .minecraft .resources .ResourceKey ;
8
12
import net .minecraft .world .item .Item ;
9
13
import net .minecraft .world .item .ItemStack ;
10
14
import net .minecraft .world .item .Items ;
11
15
import net .minecraft .world .item .enchantment .Enchantment ;
12
16
import net .minecraft .world .item .enchantment .EnchantmentCategory ;
13
17
14
18
import java .util .ArrayList ;
19
+ import java .util .Comparator ;
15
20
import java .util .List ;
16
21
17
22
public final class ClientCache {
@@ -29,23 +34,23 @@ public final class ClientCache {
29
34
private static List <SpriteListSelectionElementModel > effectSelectionItems ;
30
35
31
36
public static List <String > getItemSuggestions () {
32
- return itemSuggestions == null ? itemSuggestions = buildSuggestions (Registry .ITEM ) : itemSuggestions ;
37
+ return itemSuggestions == null ? itemSuggestions = buildSuggestions (BuiltInRegistries .ITEM ) : itemSuggestions ;
33
38
}
34
39
35
40
public static List <ItemListSelectionElementModel > getItemSelectionItems () {
36
41
return itemSelectionItems == null ? itemSelectionItems = buildItemSelectionItems () : itemSelectionItems ;
37
42
}
38
43
39
44
public static List <String > getBlockSuggestions () {
40
- return blockSuggestions == null ? blockSuggestions = buildSuggestions (Registry .BLOCK ) : blockSuggestions ;
45
+ return blockSuggestions == null ? blockSuggestions = buildSuggestions (BuiltInRegistries .BLOCK ) : blockSuggestions ;
41
46
}
42
47
43
48
public static List <ItemListSelectionElementModel > getBlockSelectionItems () {
44
49
return blockSelectionItems == null ? blockSelectionItems = buildBlockSelectionItems () : blockSelectionItems ;
45
50
}
46
51
47
52
public static List <String > getEnchantmentSuggestions () {
48
- return enchantmentSuggestions == null ? enchantmentSuggestions = buildSuggestions (Registry .ENCHANTMENT ) : enchantmentSuggestions ;
53
+ return enchantmentSuggestions == null ? enchantmentSuggestions = buildSuggestions (BuiltInRegistries .ENCHANTMENT ) : enchantmentSuggestions ;
49
54
}
50
55
51
56
public static List <SortedEnchantmentListSelectionElementModel > getSortedEnchantmentSelectionItems (ItemStack target ) {
@@ -84,23 +89,23 @@ public static List<SortedEnchantmentListSelectionElementModel> getSortedEnchantm
84
89
}
85
90
86
91
public static List <String > getAttributeSuggestions () {
87
- return attributeSuggestions == null ? attributeSuggestions = buildSuggestions (Registry .ATTRIBUTE ) : attributeSuggestions ;
92
+ return attributeSuggestions == null ? attributeSuggestions = buildSuggestions (BuiltInRegistries .ATTRIBUTE ) : attributeSuggestions ;
88
93
}
89
94
90
95
public static List <ListSelectionElementModel > getAttributeSelectionItems () {
91
96
return attributeSelectionItems == null ? attributeSelectionItems = buildAttributeSelectionItems () : attributeSelectionItems ;
92
97
}
93
98
94
99
public static List <String > getPotionSuggestions () {
95
- return potionSuggestions == null ? potionSuggestions = buildSuggestions (Registry .POTION ) : potionSuggestions ;
100
+ return potionSuggestions == null ? potionSuggestions = buildSuggestions (BuiltInRegistries .POTION ) : potionSuggestions ;
96
101
}
97
102
98
103
public static List <ItemListSelectionElementModel > getPotionSelectionItems () {
99
104
return potionSelectionItems == null ? potionSelectionItems = buildPotionSelectionItems () : potionSelectionItems ;
100
105
}
101
106
102
107
public static List <String > getEffectSuggestions () {
103
- return effectSuggestions == null ? effectSuggestions = buildSuggestions (Registry .MOB_EFFECT ) : effectSuggestions ;
108
+ return effectSuggestions == null ? effectSuggestions = buildSuggestions (BuiltInRegistries .MOB_EFFECT ) : effectSuggestions ;
104
109
}
105
110
106
111
public static List <SpriteListSelectionElementModel > getEffectSelectionItems () {
@@ -122,21 +127,21 @@ private static List<String> buildSuggestions(Registry<?> registry) {
122
127
}
123
128
124
129
private static List <ItemListSelectionElementModel > buildItemSelectionItems () {
125
- return Registry .ITEM .entrySet ().stream ()
130
+ return BuiltInRegistries .ITEM .entrySet ().stream ()
126
131
.map (e -> new ItemListSelectionElementModel (e .getValue ().getDescriptionId (), e .getKey ().location (), new ItemStack (e .getValue ())))
127
- .toList ();
132
+ .sorted (). toList ();
128
133
}
129
134
130
135
private static List <ItemListSelectionElementModel > buildBlockSelectionItems () {
131
- return Registry .BLOCK .entrySet ().stream ()
136
+ return BuiltInRegistries .BLOCK .entrySet ().stream ()
132
137
.map (e -> new ItemListSelectionElementModel (e .getValue ().getDescriptionId (), e .getKey ().location (), new ItemStack (e .getValue ())))
133
- .toList ();
138
+ .sorted (). toList ();
134
139
}
135
140
136
141
private static List <EnchantmentListSelectionElementModel > buildEnchantmentSelectionItems () {
137
- return Registry .ENCHANTMENT .entrySet ().stream ()
142
+ return BuiltInRegistries .ENCHANTMENT .entrySet ().stream ()
138
143
.map (e -> new EnchantmentListSelectionElementModel (e .getValue ().getDescriptionId (), e .getKey ().location (), e .getValue (), new ItemStack (getEnchantmentTypeItem (e .getValue ()))))
139
- .toList ();
144
+ .sorted (). toList ();
140
145
}
141
146
142
147
private static Item getEnchantmentTypeItem (Enchantment e ) {
@@ -171,21 +176,21 @@ private static Item getEnchantmentTypeItem(Enchantment e) {
171
176
}
172
177
173
178
private static List <ListSelectionElementModel > buildAttributeSelectionItems () {
174
- return Registry .ATTRIBUTE .entrySet ().stream ()
179
+ return BuiltInRegistries .ATTRIBUTE .entrySet ().stream ()
175
180
.map (e -> new ListSelectionElementModel (e .getValue ().getDescriptionId (), e .getKey ().location ()))
176
- .toList ();
181
+ .sorted (). toList ();
177
182
}
178
183
179
184
private static List <ItemListSelectionElementModel > buildPotionSelectionItems () {
180
- return Registry .POTION .entrySet ().stream ()
185
+ return BuiltInRegistries .POTION .entrySet ().stream ()
181
186
.map (e -> new ItemListSelectionElementModel (e .getValue ().getName (Items .POTION .getDescriptionId () + ".effect." ), e .getKey ().location (), ColoredItemHelper .createColoredPotionItem (e .getKey ().location (), Color .NONE )))
182
- .toList ();
187
+ .sorted (). toList ();
183
188
}
184
189
185
190
private static List <SpriteListSelectionElementModel > buildEffectSelectionItems () {
186
- return Registry .MOB_EFFECT .entrySet ().stream ()
191
+ return BuiltInRegistries .MOB_EFFECT .entrySet ().stream ()
187
192
.map (e -> new SpriteListSelectionElementModel (e .getValue ().getDescriptionId (), e .getKey ().location (), () -> Minecraft .getInstance ().getMobEffectTextures ().get (e .getValue ())))
188
- .toList ();
193
+ .sorted (). toList ();
189
194
}
190
195
191
196
}
0 commit comments