use of net.minecraftforge.registries.IForgeRegistryModifiable in project Adventurers-Toolbox by the-realest-stu.
the class CommonProxy method processRecipes.
protected void processRecipes() {
if (ForgeRegistries.RECIPES instanceof IForgeRegistryModifiable) {
IForgeRegistryModifiable registry = (IForgeRegistryModifiable) ForgeRegistries.RECIPES;
Entry<ResourceLocation, IRecipe>[] recipeEntries = ForgeRegistries.RECIPES.getEntries().toArray(new Entry[ForgeRegistries.RECIPES.getEntries().size()]);
for (int recipeIndex = 0; recipeIndex < recipeEntries.length; recipeIndex++) {
Entry<ResourceLocation, IRecipe> recipeEntry = recipeEntries[recipeIndex];
IRecipe recipe = recipeEntry.getValue();
NonNullList<Ingredient> ingredients = recipe.getIngredients();
Item output = recipe.getRecipeOutput().getItem();
String rp = output.getRegistryName().getResourcePath();
if ((output instanceof ItemHoe || output instanceof ItemAxe || output instanceof ItemSpade || output instanceof ItemPickaxe || output instanceof ItemSword) || (output instanceof ItemTool && (rp.contains("pick") || rp.contains("axe") || rp.contains("shovel") || rp.contains("spade"))) || (output instanceof ItemTool && (output.getRegistryName().getResourceDomain().equals("thermalfoundation") && rp.contains("hammer")))) {
String materialName = output instanceof ItemHoe ? ((ItemHoe) output).getMaterialName() : output instanceof ItemSword ? ((ItemSword) output).getToolMaterialName() : ((ItemTool) output).getToolMaterialName();
if (Materials.canReplaceMaterial(materialName, recipe.getRecipeOutput())) {
// System.out.println(materialName);
registry.remove(recipeEntry.getKey());
registry.register(new IRecipe() {
private ResourceLocation registryName;
@Override
public IRecipe setRegistryName(ResourceLocation name) {
this.registryName = name;
return this;
}
@Override
public ResourceLocation getRegistryName() {
return this.registryName;
}
@Override
public Class<IRecipe> getRegistryType() {
return IRecipe.class;
}
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
return false;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
return ItemStack.EMPTY;
}
@Override
public boolean canFit(int width, int height) {
return false;
}
@Override
public ItemStack getRecipeOutput() {
return ItemStack.EMPTY;
}
}.setRegistryName(recipeEntry.getKey()));
removed_recipes.add(recipeEntry.getKey());
} else {
System.out.println(output.getRegistryName() + " -> " + materialName);
}
} else {
for (int i = 0; i < ingredients.size(); i++) {
ItemStack[] matchingStacks = ingredients.get(i).getMatchingStacks();
boolean flag = false;
Item ingredientItem = null;
for (int j = 0; j < matchingStacks.length && !flag; j++) {
Item item = matchingStacks[j].getItem();
if (!getToolReplacement(item).isEmpty()) {
ingredientItem = item;
flag = true;
}
}
if (flag && ingredientItem != null && !getToolReplacement(ingredientItem).isEmpty()) {
ingredients.set(i, new IngredientNBT(getToolReplacement(ingredientItem)) {
});
}
}
}
}
}
}
use of net.minecraftforge.registries.IForgeRegistryModifiable in project harvestcraft by MatrexsVigil.
the class RecipeRemoval method registerRecipes.
@SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
ResourceLocation bread = new ResourceLocation("minecraft:bread");
IForgeRegistryModifiable modRegistry = (IForgeRegistryModifiable) event.getRegistry();
modRegistry.remove(bread);
ResourceLocation rabbitstew = new ResourceLocation("minecraft:rabbit_stew");
modRegistry.remove(rabbitstew);
ResourceLocation beetrootsoup = new ResourceLocation("minecraft:beetroot_soup");
modRegistry.remove(beetrootsoup);
ResourceLocation mushroomstew = new ResourceLocation("minecraft:mushroom_stew");
modRegistry.remove(mushroomstew);
ResourceLocation cookie = new ResourceLocation("minecraft:cookie");
modRegistry.remove(cookie);
ResourceLocation pumpkinpie = new ResourceLocation("minecraft:pumpkin_pie");
modRegistry.remove(pumpkinpie);
ResourceLocation bakedpotato = new ResourceLocation("minecraft:baked_potato");
modRegistry.remove(bakedpotato);
}
Aggregations