28
28
import net .minecraft .core .BlockPos ;
29
29
import net .minecraft .core .Direction ;
30
30
import net .minecraft .core .Holder ;
31
+ import net .minecraft .core .Registry ;
32
+ import net .minecraft .core .registries .BuiltInRegistries ;
31
33
import net .minecraft .core .registries .Registries ;
32
34
import net .minecraft .network .chat .Component ;
33
35
import net .minecraft .resources .ResourceLocation ;
42
44
import net .minecraft .world .level .block .state .BlockState ;
43
45
import net .minecraftforge .common .MinecraftForge ;
44
46
import net .minecraftforge .eventbus .api .IEventBus ;
45
- import net .minecraftforge .registries .ForgeRegistries ;
46
- import net .minecraftforge .registries .IForgeRegistry ;
47
47
import org .jetbrains .annotations .NotNull ;
48
48
import java .util .Arrays ;
49
49
import java .util .HashMap ;
@@ -110,9 +110,9 @@ public Stream<IBlock> getBlock(@NotNull String name){
110
110
var resourceLocation = idExternal (name );
111
111
if (isTag ){
112
112
var tag = TagKey .create (Registries .BLOCK , resourceLocation );
113
- return getRegistryTagContent (ForgeRegistries . BLOCKS , tag ).map (BlockWrapper ::new );
113
+ return getRegistryTagContent (BuiltInRegistries . BLOCK , tag ).map (BlockWrapper ::new );
114
114
}
115
- return getRegistryElement (ForgeRegistries . BLOCKS , resourceLocation ).stream ().map (BlockWrapper ::new );
115
+ return getRegistryElement (BuiltInRegistries . BLOCK , resourceLocation ).stream ().map (BlockWrapper ::new );
116
116
}
117
117
catch (Exception e ){
118
118
return empty ();
@@ -130,9 +130,9 @@ public Stream<IItem> getItem(@NotNull String name){
130
130
var resourceLocation = idExternal (name );
131
131
if (isTag ){
132
132
var tag = TagKey .create (Registries .ITEM , resourceLocation );
133
- return getRegistryTagContent (ForgeRegistries . ITEMS , tag ).map (ItemWrapper ::new );
133
+ return getRegistryTagContent (BuiltInRegistries . ITEM , tag ).map (ItemWrapper ::new );
134
134
}
135
- return getRegistryElement (ForgeRegistries . ITEMS , resourceLocation ).stream ().map (ItemWrapper ::new );
135
+ return getRegistryElement (BuiltInRegistries . ITEM , resourceLocation ).stream ().map (ItemWrapper ::new );
136
136
}
137
137
catch (Exception e ){
138
138
return empty ();
@@ -141,7 +141,7 @@ public Stream<IItem> getItem(@NotNull String name){
141
141
142
142
@ Override
143
143
public boolean isLeafBlock (@ NotNull IBlock block ){
144
- var isAllowedBlock = registryTagContains (ForgeRegistries . BLOCKS , BlockTags .LEAVES , (Block ) block .getRaw ())
144
+ var isAllowedBlock = registryTagContains (BuiltInRegistries . BLOCK , BlockTags .LEAVES , (Block ) block .getRaw ())
145
145
|| getConfiguration ().getTrees ().getAllowedLeaveBlocks (this ).stream ().anyMatch (leaf -> leaf .equals (block ));
146
146
if (isAllowedBlock ){
147
147
var isDeniedBlock = getConfiguration ().getTrees ().getDeniedLeaveBlocks (this ).stream ().anyMatch (leaf -> leaf .equals (block ));
@@ -152,7 +152,7 @@ public boolean isLeafBlock(@NotNull IBlock block){
152
152
153
153
@ Override
154
154
public boolean isLogBlock (@ NotNull IBlock block ){
155
- var isAllowedBlock = getConfiguration ().getTrees ().getDefaultLogsBlocks (this ).stream ().anyMatch (log -> log .equals (block ))
155
+ var isAllowedBlock = getConfiguration ().getTrees ().getDefaultLogsBlocks (this ).stream ().anyMatch (log -> log .equals (block ))
156
156
|| getConfiguration ().getTrees ().getAllowedLogBlocks (this ).stream ().anyMatch (log -> log .equals (block ));
157
157
if (isAllowedBlock ){
158
158
var isDeniedBlock = getConfiguration ().getTrees ().getDeniedLogBlocks (this ).stream ().anyMatch (log -> log .equals (block ));
@@ -164,11 +164,12 @@ public boolean isLogBlock(@NotNull IBlock block){
164
164
@ Override
165
165
@ NotNull
166
166
public Set <IBlock > getAllNonStrippedLogsBlocks (){
167
- return getRegistryTagContent (ForgeRegistries . BLOCKS , BlockTags .LOGS )
168
- .filter (block -> !Optional .ofNullable ( ForgeRegistries . BLOCKS .getKey (block ))
167
+ return getRegistryTagContent (BuiltInRegistries . BLOCK , BlockTags .LOGS )
168
+ .filter (block -> !Optional .of ( BuiltInRegistries . BLOCK .getKey (block ))
169
169
.map (ResourceLocation ::getPath )
170
170
.map (name -> name .startsWith ("stripped" ))
171
- .orElse (false ))
171
+ .orElse (false )
172
+ )
172
173
.map (BlockWrapper ::new )
173
174
.collect (Collectors .toSet ());
174
175
}
@@ -187,7 +188,7 @@ public Direction asDirection(@NotNull DirectionCompat dir){
187
188
188
189
@ Override
189
190
public boolean isNetherWartOrShroomlight (@ NotNull IBlock block ){
190
- return registryTagContains (ForgeRegistries . BLOCKS , BlockTags .WART_BLOCKS , (Block ) block .getRaw ())
191
+ return registryTagContains (BuiltInRegistries . BLOCK , BlockTags .WART_BLOCKS , (Block ) block .getRaw ())
191
192
|| Blocks .SHROOMLIGHT .equals (block .getRaw ());
192
193
}
193
194
@@ -208,16 +209,17 @@ public IItemStack getEmptyItemStack(){
208
209
}
209
210
210
211
@ NotNull
211
- private <T > Optional <T > getRegistryElement (IForgeRegistry <T > registryKey , ResourceLocation identifier ){
212
- return registryKey .getHolder (identifier ).map (Holder ::value );
212
+ private <T > Optional <T > getRegistryElement (Registry <T > registryKey , ResourceLocation identifier ){
213
+ return registryKey .get (identifier ).map (Holder ::value );
213
214
}
214
215
215
216
@ NotNull
216
- private <T > Stream <T > getRegistryTagContent (@ NotNull IForgeRegistry <T > registry , @ NotNull TagKey <T > tag ){
217
- return registry .tags ().getTag (tag ).stream ();
217
+ private <T > Stream <T > getRegistryTagContent (@ NotNull Registry <T > registry , @ NotNull TagKey <T > tag ){
218
+ return registry .get (tag ).stream ()
219
+ .flatMap (a -> a .stream ().map (Holder ::value ));
218
220
}
219
221
220
- private <T > boolean registryTagContains (@ NotNull IForgeRegistry <T > registry , @ NotNull TagKey <T > tag , @ NotNull T element ){
222
+ private <T > boolean registryTagContains (@ NotNull Registry <T > registry , @ NotNull TagKey <T > tag , @ NotNull T element ){
221
223
return getRegistryTagContent (registry , tag ).anyMatch (element ::equals );
222
224
}
223
225
0 commit comments