Skip to content

Commit

Permalink
Fix crash when retextured blocks have invalid NBT (#207)
Browse files Browse the repository at this point in the history
Only really happens when people misuse commands, but better to not crash

(cherry picked from commit 7701195)
  • Loading branch information
KnightMiner committed Dec 10, 2024
1 parent 73c8e84 commit 0e428a2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/slimeknights/mantle/util/RetexturedHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ public final class RetexturedHelper {
*/
public static Block getBlock(String name) {
if (!name.isEmpty()) {
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(name));
if (block != null) {
return block;
ResourceLocation location = ResourceLocation.tryParse(name);
if (location != null) {
Block block = ForgeRegistries.BLOCKS.getValue(location);
if (block != null) {
return block;
}
}
}
return Blocks.AIR;
Expand Down

0 comments on commit 0e428a2

Please sign in to comment.