Migrated some API calls

This commit is contained in:
Frank 2022-11-12 12:10:59 +01:00
parent c11fca74a5
commit daa4a2b4af
56 changed files with 172 additions and 167 deletions

View file

@ -3,7 +3,6 @@ package org.betterx.bclib.recipes;
import org.betterx.bclib.api.v2.advancement.AdvancementManager;
import net.minecraft.advancements.RequirementsStrategy;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.ArmorItem;
@ -105,8 +104,8 @@ public class AbstractAdvancementRecipe {
String name = "has_" + (nameCounter++) + "_" +
Arrays.stream(items)
.map(block -> (block instanceof Block)
? Registry.BLOCK.getKey((Block) block)
: Registry.ITEM.getKey((Item) block))
? BuiltInRegistries.BLOCK.getKey((Block) block)
: BuiltInRegistries.ITEM.getKey((Item) block))
.filter(id -> id != null)
.map(id -> id.getPath())
.collect(Collectors.joining("_"));

View file

@ -209,10 +209,10 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
@Override
public NonNullList<Ingredient> getIngredients() {
NonNullList<Ingredient> defaultedList = NonNullList.create();
defaultedList.add(Ingredient.of(Registry.ITEM.stream()
.filter(AnvilRecipe::isHammer)
.filter(this::canUse)
.map(ItemStack::new))
defaultedList.add(Ingredient.of(BuiltInRegistries.ITEM.stream()
.filter(AnvilRecipe::isHammer)
.filter(this::canUse)
.map(ItemStack::new))
);
defaultedList.add(input);
return defaultedList;

View file

@ -117,9 +117,9 @@ public class BCLRecipeManager {
public static boolean exists(ItemLike item) {
if (item instanceof Block) {
return Registry.BLOCK.getKey((Block) item) != Registry.BLOCK.getDefaultKey();
return BuiltInRegistries.BLOCK.getKey((Block) item) != BuiltInRegistries.BLOCK.getDefaultKey();
} else {
return item != Items.AIR && Registry.ITEM.getKey(item.asItem()) != Registry.ITEM.getDefaultKey();
return item != Items.AIR && BuiltInRegistries.ITEM.getKey(item.asItem()) != BuiltInRegistries.ITEM.getDefaultKey();
}
}