Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] Help with custom crafting table & chests (using wood OreDict)
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 2
Kitteh6660

[1.12.2] Help with custom crafting table & chests (using wood OreDict)

By Kitteh6660, August 24, 2018 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Kitteh6660    0

Kitteh6660

Kitteh6660    0

  • Tree Puncher
  • Kitteh6660
  • Members
  • 0
  • 5 posts
Posted August 24, 2018 (edited)

I've got nearly every thing up and running with my MoreCraft mod after days of painstakingly converting every recipe and integrating advancement functionality to my mod.

It's almost ready but I've came across obstacles. I couldn't seem to be able to have the JSONs take priority over vanilla recipes when it comes to using ore dictionary.

 

While the mod NoMoreRecipeConflict works, that's only a band-aid solution. I could remove the ore dict but then the Netherwood planks can no longer be used in every wooden crafting recipe universally, and that would cripple cross-mod crafting functionality. I want to make sure the ore dict remains but properly fix the recipes. Back in 1.11.2, I had no problems as the coded recipes easily takes priority over the vanilla recipes.

The expected behaviour. Clicking the Netherwood chest without the required planks produces the expected chest on output. The recipe is registered.

PFIdsth.png -

The results. It creates an ordinary chest. For some reasons the mod recipe doesn't take priority over the vanilla recipe. This is the same case for Netherwood Crafting Table (which uses vanilla crafting functionality)

QOLgB9n.png

 

Spoiler

netherwood_chest.json


{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "###",
    "# #",
    "###"
  ],
  "key": {
    "#": {
      "item": "morecraft:netherwood_planks"
    }
  },
  "result": {
    "item": "morecraft:netherwood_chest"
  }
}

netherwood_crafting_table.json


{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "##",
    "##"
  ],
  "key": {
    "#": {
      "item": "morecraft:netherwood_planks"
    }
  },
  "result": {
    "item": "morecraft:netherwood_crafting_table"
  }
}

Snippet from MoreCraft.java


    public static void oreRegistration()
    {
    	//|--| Register blocks to Ore Dictionary |--|\\
		OreDictionary.registerOre("blockGlass", MoreCraftBlocks.SOUL_GLASS);
		OreDictionary.registerOre("blockGlassColorless", MoreCraftBlocks.SOUL_GLASS);
		OreDictionary.registerOre("paneGlass", MoreCraftBlocks.SOUL_GLASS_PANE);
		OreDictionary.registerOre("paneGlassColorless", MoreCraftBlocks.SOUL_GLASS_PANE);
    	
		//Ruby ores and blocks
		OreDictionary.registerOre("oreRuby", MoreCraftBlocks.RUBY_ORE);
		OreDictionary.registerOre("blockRuby", MoreCraftBlocks.RUBY_BLOCK);
		
		//Netherwood
		OreDictionary.registerOre("treeWood", MoreCraftBlocks.NETHERWOOD_LOG);
		OreDictionary.registerOre("plankWood", MoreCraftBlocks.NETHERWOOD_PLANKS);
		OreDictionary.registerOre("stairWood", MoreCraftBlocks.NETHERWOOD_STAIRS);
		OreDictionary.registerOre("slabWood", MoreCraftBlocks.NETHERWOOD_SLAB);
		OreDictionary.registerOre("treeLeaves", MoreCraftBlocks.NETHERWOOD_LEAVES);
		OreDictionary.registerOre("treeSapling", MoreCraftBlocks.NETHERWOOD_SAPLING);
		
		//Blocks made from vanilla resources.
		OreDictionary.registerOre("blockFlesh", MoreCraftBlocks.FLESH_BLOCK);
		OreDictionary.registerOre("blockGunpowder", MoreCraftBlocks.GUNPOWDER_BLOCK);
		OreDictionary.registerOre("blockBlaze", MoreCraftBlocks.BLAZE_BLOCK);
		OreDictionary.registerOre("blockEnder", MoreCraftBlocks.ENDER_BLOCK);
		
		//|--| Register items to Ore Dictionary |--|\\
		OreDictionary.registerOre("gemRuby", MoreCraftItems.RUBY);
		OreDictionary.registerOre("boneWither", MoreCraftItems.WITHER_BONE);
		OreDictionary.registerOre("scaleEnder", MoreCraftItems.ENDERDRAGON_SCALES);
    }

 

Is there a solution to ensure that OreDict'ed ingredients are exempt from certain recipes? I've been trying to make everything done as simple as possible.

Edited August 24, 2018 by Kitteh6660
Correction of text placement
  • Quote

Share this post


Link to post
Share on other sites

Cadiboo    365

Cadiboo

Cadiboo    365

  • Reality Controller
  • Cadiboo
  • Members
  • 365
  • 3624 posts
Posted August 24, 2018
4 hours ago, Kitteh6660 said:

I've got nearly every thing up and running with my MoreCraft mod after days of painstakingly converting every recipe and integrating advancement functionality to my mod.

It's almost ready but I've came across obstacles. I couldn't seem to be able to have the JSONs take priority over vanilla recipes when it comes to using ore dictionary.

 

While the mod NoMoreRecipeConflict works, that's only a band-aid solution. I could remove the ore dict but then the Netherwood planks can no longer be used in every wooden crafting recipe universally, and that would cripple cross-mod crafting functionality. I want to make sure the ore dict remains but properly fix the recipes. Back in 1.11.2, I had no problems as the coded recipes easily takes priority over the vanilla recipes.

The expected behaviour. Clicking the Netherwood chest without the required planks produces the expected chest on output. The recipe is registered.

PFIdsth.png -

The results. It creates an ordinary chest. For some reasons the mod recipe doesn't take priority over the vanilla recipe. This is the same case for Netherwood Crafting Table (which uses vanilla crafting functionality)

QOLgB9n.png

 

  Reveal hidden contents

netherwood_chest.json



{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "###",
    "# #",
    "###"
  ],
  "key": {
    "#": {
      "item": "morecraft:netherwood_planks"
    }
  },
  "result": {
    "item": "morecraft:netherwood_chest"
  }
}

netherwood_crafting_table.json



{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "##",
    "##"
  ],
  "key": {
    "#": {
      "item": "morecraft:netherwood_planks"
    }
  },
  "result": {
    "item": "morecraft:netherwood_crafting_table"
  }
}

Snippet from MoreCraft.java



    public static void oreRegistration()
    {
    	//|--| Register blocks to Ore Dictionary |--|\\
		OreDictionary.registerOre("blockGlass", MoreCraftBlocks.SOUL_GLASS);
		OreDictionary.registerOre("blockGlassColorless", MoreCraftBlocks.SOUL_GLASS);
		OreDictionary.registerOre("paneGlass", MoreCraftBlocks.SOUL_GLASS_PANE);
		OreDictionary.registerOre("paneGlassColorless", MoreCraftBlocks.SOUL_GLASS_PANE);
    	
		//Ruby ores and blocks
		OreDictionary.registerOre("oreRuby", MoreCraftBlocks.RUBY_ORE);
		OreDictionary.registerOre("blockRuby", MoreCraftBlocks.RUBY_BLOCK);
		
		//Netherwood
		OreDictionary.registerOre("treeWood", MoreCraftBlocks.NETHERWOOD_LOG);
		OreDictionary.registerOre("plankWood", MoreCraftBlocks.NETHERWOOD_PLANKS);
		OreDictionary.registerOre("stairWood", MoreCraftBlocks.NETHERWOOD_STAIRS);
		OreDictionary.registerOre("slabWood", MoreCraftBlocks.NETHERWOOD_SLAB);
		OreDictionary.registerOre("treeLeaves", MoreCraftBlocks.NETHERWOOD_LEAVES);
		OreDictionary.registerOre("treeSapling", MoreCraftBlocks.NETHERWOOD_SAPLING);
		
		//Blocks made from vanilla resources.
		OreDictionary.registerOre("blockFlesh", MoreCraftBlocks.FLESH_BLOCK);
		OreDictionary.registerOre("blockGunpowder", MoreCraftBlocks.GUNPOWDER_BLOCK);
		OreDictionary.registerOre("blockBlaze", MoreCraftBlocks.BLAZE_BLOCK);
		OreDictionary.registerOre("blockEnder", MoreCraftBlocks.ENDER_BLOCK);
		
		//|--| Register items to Ore Dictionary |--|\\
		OreDictionary.registerOre("gemRuby", MoreCraftItems.RUBY);
		OreDictionary.registerOre("boneWither", MoreCraftItems.WITHER_BONE);
		OreDictionary.registerOre("scaleEnder", MoreCraftItems.ENDERDRAGON_SCALES);
    }

 

Is there a solution to ensure that OreDict'ed ingredients are exempt from certain recipes? I've been trying to make everything done as simple as possible.

I think this may be solved in 1.13 with the vanilla tag system, which (I believe) will be used instead of OreDictionary

  • Quote

About Me

Spoiler

My Discord - Cadiboo#8887

My Website - Cadiboo.github.io

My Mods - Cadiboo.github.io/projects

My Tutorials - Cadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Share this post


Link to post
Share on other sites

Animefan8888    741

Animefan8888

Animefan8888    741

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 741
  • 6157 posts
Posted August 24, 2018
8 hours ago, Kitteh6660 said:

Is there a solution to ensure that OreDict'ed ingredients are exempt from certain recipes? I've been trying to make everything done as simple as possible.

What you are going to have to do, is after all your recipes have been added, you will need to remove and re-add the recipes to the registry.

  • Quote

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Share this post


Link to post
Share on other sites

Kitteh6660    0

Kitteh6660

Kitteh6660    0

  • Tree Puncher
  • Kitteh6660
  • Members
  • 0
  • 5 posts
Posted August 25, 2018 (edited)

It took me a long while of searching and eventually giving up on that but I ended up having made a solution of my own. The only downside is the output graphic looks unaltered but you will receive the items.

I tried the removing and re-adding to no avail.

Spoiler

My workaround solution. Not perfect however. You can still mix Netherwood planks + vanilla planks and get vanilla chests and crafting table, but if you use all Netherwood planks, you get the Netherwood version. It also checks if you use Shift keys, and thus prevents the infinite items exploit.

I've registered and now everything works, other than the minor graphical issue on crafting.


package kittehmod.morecraft.crafting;

import org.lwjgl.input.Keyboard;

import kittehmod.morecraft.MoreCraftBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;

public class RecipeHelper {
	
	//It's ugly but it'll do for now.
	public static int countItemInGrid(InventoryCrafting matrix, Item item) {
		int amt = 0;
		for (int i = 0; i < 9; i++) {
			if (matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getItem() == item) { amt++; }
		}
		System.out.println(amt);
		return amt;
	}
	public static int decreaseItemsInGrid(InventoryCrafting matrix, int amount) {
		int amt = 0;
		for (int i = 0; i < 9; i++) {
			if (matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getCount() > 0) {
				matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).shrink(amount);
			}
		}
		System.out.println(amt);
		return amt;
	}
	public static int countMultiplesLowest(InventoryCrafting matrix, Item item) {
		int amt = 99;
		for (int i = 0; i < 9; i++) {
			if (matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getCount() > 0 && amt > matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getCount() && matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getItem() == item) {
				amt = matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getCount();
			}
		}
		return amt;
	}
	private static void deductItemsFromPlayer(EntityPlayer player, Item item, int amount) {
		InventoryPlayer inventory = player.inventory;
		for (int i = 0; i < 36; i++) {
			if (inventory.getStackInSlot(i).getItem() == item) {
				inventory.decrStackSize(i, amount);
				break;
			}
		}
	}
	
	public static void processCrafting(ItemCraftedEvent event, EntityPlayer player, InventoryCrafting matrix, Item origCraft, Item targetCraft, Item materialDeducted) {
		World world = player.getEntityWorld();
		int amt = 1;
		if (!world.isRemote) { //Server handler
			event.crafting.shrink(1);
			decreaseItemsInGrid(matrix, 1);
			event.player.addItemStackToInventory(new ItemStack(targetCraft, 1));
		}
		else { //Singleplayer handler
			if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
				event.crafting.shrink(1);
				amt = countMultiplesLowest(matrix, materialDeducted);
				decreaseItemsInGrid(matrix, amt);
				deductItemsFromPlayer(event.player, origCraft, 1);
				event.player.addItemStackToInventory(new ItemStack(targetCraft, amt));
			}
			else {
				event.crafting.shrink(1);
				decreaseItemsInGrid(matrix, 1);
				event.player.addItemStackToInventory(new ItemStack(targetCraft, 1));
			}
		}
	}
	
	//Hacky workaround for Netherwood chests and crafting tables.		
	@SubscribeEvent
	public void CraftEvent(ItemCraftedEvent event)
	{
		InventoryCrafting matrix = (InventoryCrafting)event.craftMatrix;
		RecipeHelper.countItemInGrid(matrix, Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS));
		if (event.crafting.getItem() == Item.getItemFromBlock(Blocks.CHEST) && countItemInGrid(matrix, Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS)) == 8) {
			processCrafting(event, event.player, matrix, Item.getItemFromBlock(Blocks.CHEST), Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_CHEST), Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS));
		}
		else if (event.crafting.getItem() == Item.getItemFromBlock(Blocks.CRAFTING_TABLE) && countItemInGrid(matrix, Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS)) == 4) {
			processCrafting(event, event.player, matrix, Item.getItemFromBlock(Blocks.CRAFTING_TABLE), Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_CRAFTING_TABLE), Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS));
		}
	}
}

 

While it works in Single Player, I'll have to figure out a way to process multiples at a time on the server.

Edited August 25, 2018 by Kitteh6660
  • Quote

Share this post


Link to post
Share on other sites

Cadiboo    365

Cadiboo

Cadiboo    365

  • Reality Controller
  • Cadiboo
  • Members
  • 365
  • 3624 posts
Posted August 26, 2018 (edited)
7 hours ago, Kitteh6660 said:

It took me a long while of searching and eventually giving up on that but I ended up having made a solution of my own. The only downside is the output graphic looks unaltered but you will receive the items.

I tried the removing and re-adding to no avail.

  Reveal hidden contents

My workaround solution. Not perfect however. You can still mix Netherwood planks + vanilla planks and get vanilla chests and crafting table, but if you use all Netherwood planks, you get the Netherwood version. It also checks if you use Shift keys, and thus prevents the infinite items exploit.

I've registered and now everything works, other than the minor graphical issue on crafting.



package kittehmod.morecraft.crafting;

import org.lwjgl.input.Keyboard;

import kittehmod.morecraft.MoreCraftBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;

public class RecipeHelper {
	
	//It's ugly but it'll do for now.
	public static int countItemInGrid(InventoryCrafting matrix, Item item) {
		int amt = 0;
		for (int i = 0; i < 9; i++) {
			if (matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getItem() == item) { amt++; }
		}
		System.out.println(amt);
		return amt;
	}
	public static int decreaseItemsInGrid(InventoryCrafting matrix, int amount) {
		int amt = 0;
		for (int i = 0; i < 9; i++) {
			if (matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getCount() > 0) {
				matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).shrink(amount);
			}
		}
		System.out.println(amt);
		return amt;
	}
	public static int countMultiplesLowest(InventoryCrafting matrix, Item item) {
		int amt = 99;
		for (int i = 0; i < 9; i++) {
			if (matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getCount() > 0 && amt > matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getCount() && matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getItem() == item) {
				amt = matrix.getStackInRowAndColumn(i % 3, (int)(i/3)).getCount();
			}
		}
		return amt;
	}
	private static void deductItemsFromPlayer(EntityPlayer player, Item item, int amount) {
		InventoryPlayer inventory = player.inventory;
		for (int i = 0; i < 36; i++) {
			if (inventory.getStackInSlot(i).getItem() == item) {
				inventory.decrStackSize(i, amount);
				break;
			}
		}
	}
	
	public static void processCrafting(ItemCraftedEvent event, EntityPlayer player, InventoryCrafting matrix, Item origCraft, Item targetCraft, Item materialDeducted) {
		World world = player.getEntityWorld();
		int amt = 1;
		if (!world.isRemote) { //Server handler
			event.crafting.shrink(1);
			decreaseItemsInGrid(matrix, 1);
			event.player.addItemStackToInventory(new ItemStack(targetCraft, 1));
		}
		else { //Singleplayer handler
			if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
				event.crafting.shrink(1);
				amt = countMultiplesLowest(matrix, materialDeducted);
				decreaseItemsInGrid(matrix, amt);
				deductItemsFromPlayer(event.player, origCraft, 1);
				event.player.addItemStackToInventory(new ItemStack(targetCraft, amt));
			}
			else {
				event.crafting.shrink(1);
				decreaseItemsInGrid(matrix, 1);
				event.player.addItemStackToInventory(new ItemStack(targetCraft, 1));
			}
		}
	}
	
	//Hacky workaround for Netherwood chests and crafting tables.		
	@SubscribeEvent
	public void CraftEvent(ItemCraftedEvent event)
	{
		InventoryCrafting matrix = (InventoryCrafting)event.craftMatrix;
		RecipeHelper.countItemInGrid(matrix, Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS));
		if (event.crafting.getItem() == Item.getItemFromBlock(Blocks.CHEST) && countItemInGrid(matrix, Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS)) == 8) {
			processCrafting(event, event.player, matrix, Item.getItemFromBlock(Blocks.CHEST), Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_CHEST), Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS));
		}
		else if (event.crafting.getItem() == Item.getItemFromBlock(Blocks.CRAFTING_TABLE) && countItemInGrid(matrix, Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS)) == 4) {
			processCrafting(event, event.player, matrix, Item.getItemFromBlock(Blocks.CRAFTING_TABLE), Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_CRAFTING_TABLE), Item.getItemFromBlock(MoreCraftBlocks.NETHERWOOD_PLANKS));
		}
	}
}

 

While it works in Single Player, I'll have to figure out a way to process multiples at a time on the server.

If I remember correctly I never implemented this, but found a way to do it very easily.

I think that you can just modify your onCraftMatrixChanged method and use code from  net.minecraft.inventory#Container.slotChangedCraftingGrid and net.minecraft.item.crafting.CraftingManager.findMatchingRecipe.

 

Never mind, I forgot that you're using the vanilla crafting table. You just have to reshuffle the recipe registry so that your recipes are before the vanilla ones so that the for loop in net.minecraft.item.crafting.CraftingManager.findMatchingRecipe chooses your recipe and not the vanilla ones. 

Edited August 26, 2018 by Cadiboo
  • Quote

About Me

Spoiler

My Discord - Cadiboo#8887

My Website - Cadiboo.github.io

My Mods - Cadiboo.github.io/projects

My Tutorials - Cadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Share this post


Link to post
Share on other sites

Kitteh6660    0

Kitteh6660

Kitteh6660    0

  • Tree Puncher
  • Kitteh6660
  • Members
  • 0
  • 5 posts
Posted August 29, 2018

How can I re-add? If I try to re-register the vanilla recipe, it crashes Minecraft with "already registered"

Here's the code. I looked through the dropdown and couldn't seem to find a reliable way to re-add the recipes.

Spoiler

	public static void fixCraftingRecipes() {
		IForgeRegistryModifiable<IRecipe> registry = (IForgeRegistryModifiable<IRecipe>) ForgeRegistries.RECIPES;
		if (!fixedNetherChest) {
			fixedNetherChest = true;
			IRecipe recipe = CraftingManager.getRecipe(new ResourceLocation("minecraft:chest"));
			registry.remove(recipe.getRegistryName());
			//Now how do I re-add the recipe? Register doesn't work as it crashes with "already registered"
		}
		if (!fixedNetherTable) {
			//This will be filled out
		}
	}

 

I could try the for loop, but I still feel a bit confused, and a bit of poking around to find it doesn't seem easy to have it skip over the vanilla recipes.

  • Quote

Share this post


Link to post
Share on other sites

Animefan8888    741

Animefan8888

Animefan8888    741

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 741
  • 6157 posts
Posted August 29, 2018
1 hour ago, Kitteh6660 said:

I could try the for loop, but I still feel a bit confused, and a bit of poking around to find it doesn't seem easy to have it skip over the vanilla recipes.

Iterate over the registry for recipes. Then remove the recipes while storing them in a variable. Then add your recipes, then add the copies of the recipes you removed.

  • Quote

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Share this post


Link to post
Share on other sites

Kitteh6660    0

Kitteh6660

Kitteh6660    0

  • Tree Puncher
  • Kitteh6660
  • Members
  • 0
  • 5 posts
Posted August 30, 2018

I tried the following code like you asked, but it doesn't work.

Spoiler

	//A wonky workaround to fixing Netherwood chest and crafting table recipes
	public static void fixCraftingRecipes() {
		IForgeRegistryModifiable<IRecipe> registry = (IForgeRegistryModifiable<IRecipe>) ForgeRegistries.RECIPES;
		ArrayList<IRecipe> recipes = Lists.newArrayList(registry.getValues());
		IRecipe recipeNether = CraftingManager.getRecipe(new ResourceLocation("morecraft:netherwood_chest"));
		IRecipe recipeCopy;
		for (IRecipe recipe : recipes) {
			if (recipe.getRecipeOutput().getItem() == Item.getItemFromBlock(Blocks.CHEST)) {
				recipeCopy = recipe;
				registry.remove(recipe.getRegistryName());
				registry.register(recipeNether);
				registry.register(recipeCopy);
				break;
			}
		}
	}

 

It then crashes with the following error output:

Spoiler

// Ouch. That hurt :(

Time: 8/30/18 8:16 AM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from MoreCraft (morecraft)
Caused by: java.lang.IllegalArgumentException: value already present: net.minecraft.item.crafting.ShapedRecipes@73a1a1b4
	at com.google.common.collect.HashBiMap.put(HashBiMap.java:287)
	at com.google.common.collect.HashBiMap.put(HashBiMap.java:262)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:338)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:285)
	at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:118)
	at kittehmod.morecraft.crafting.RecipeHelper.fixCraftingRecipes(RecipeHelper.java:121)
	at kittehmod.morecraft.MoreCraft.load(MoreCraft.java:123)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:629)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:744)
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:329)
	at net.minecraft.client.Minecraft.init(Minecraft.java:581)
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)

 

I'm close to giving up on that.

  • Quote

Share this post


Link to post
Share on other sites

Cadiboo    365

Cadiboo

Cadiboo    365

  • Reality Controller
  • Cadiboo
  • Members
  • 365
  • 3624 posts
Posted August 30, 2018

Have you tried something like (pseudo code)

 

ArrayList<> myRecipes = new ArrayList<>();

ArrayList otherRecipes = new ArrayList<>();

 

for(Recipe recipe : forgeRegistries.Recipes.allRecipesAsList()) {

if(recipeIsMine(recipe)) {

myRecipes.add(recipe);

}

else {

otherRecipes.add(recipe);

}

}

 

forgeRegistries.Recipes.allRecipesAsList().clear();

 

forgeRegistries.Recipes.allRecipesAsList().addAll(myRecipes);

 

forgeRegistries.Recipes.allRecipesAsList().addAll(otherRecipes);

 

 

sorry for the bad formatting, I wrote it on my phone

  • Quote

About Me

Spoiler

My Discord - Cadiboo#8887

My Website - Cadiboo.github.io

My Mods - Cadiboo.github.io/projects

My Tutorials - Cadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Share this post


Link to post
Share on other sites

Animefan8888    741

Animefan8888

Animefan8888    741

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 741
  • 6157 posts
Posted August 30, 2018
8 hours ago, Kitteh6660 said:

I'm close to giving up on that.

You never remove your recipe registry so why do you try to add it again?

  • Quote

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • ThisIsNotOriginal
      When I try to run my mod after I just added Deferred Registries it crashes

      By ThisIsNotOriginal · Posted 1 minute ago

      so do i change the name in my ItemsList?
    • diesieben07
      [1.16.5] Help with custom Backpack (slot background and mouse wheel move)

      By diesieben07 · Posted 11 minutes ago

      I do not understand. How is the offhand slot relevant regarding the background color of your slot?   Assuming you want a keyboard key to open the GUI: Make a KeyBinding. Use ClientTickEvent to check if its pressed. If it is, send a packet to the server, which then calls NetworkHooks#openGui. You can preemptively also open it on the client to hide the latency of the two network roundtrips.
    • diesieben07
      When I try to run my mod after I just added Deferred Registries it crashes

      By diesieben07 · Posted 13 minutes ago

      That is not how you make a Git repo. At all.   This creates a BlockItem for all of your blocks. One of your blocks has the registry name "copper_ore", hence this will create a BlockItem with registry name "copper_ore". This then creates another Item with registry name "copper_ore". This is not allowed, registry names must be unique.
    • Extrupt
      Forge won't fully download

      By Extrupt · Posted 15 minutes ago

      thanks for the help! it worked!
    • Luis_ST
      [1.16.5] Help with custom Backpack (slot background and mouse wheel move)

      By Luis_ST · Posted 16 minutes ago

      I've already tried that and it's not how it's supposed to work. For example, if I put an item in the offand slot, the background texture is set to default. that's how it should work   I'll try the event   Another question which event should I use to open my BackpackContainer. I know that there is the KeyInputEvent when I use this I don't get a ServerPlayerEntity which I need to open the GUI with NetworkHooks#openGui. I currently use TickEvent#PlayerTickEvent which is not the best solution. Is there another / better way to do this?
  • Topics

    • ThisIsNotOriginal
      18
      When I try to run my mod after I just added Deferred Registries it crashes

      By ThisIsNotOriginal
      Started 16 hours ago

    • Luis_ST
      3
      [1.16.5] Help with custom Backpack (slot background and mouse wheel move)

      By Luis_ST
      Started Yesterday at 07:47 AM

    • Extrupt
      5
      Forge won't fully download

      By Extrupt
      Started 47 minutes ago

    • HDMI_Steckdose
      1
      Forge error Forge won't open

      By HDMI_Steckdose
      Started 22 minutes ago

    • Retsal
      7
      [1.16.x] Custom block as a shop

      By Retsal
      Started Yesterday at 01:04 PM

  • Who's Online (See full list)

    • reu_24
    • troublemaker_47
    • CAS_ual_TY
    • diesieben07
    • Extrupt
    • ThisIsNotOriginal
    • Coloringgamer
    • Katie328
    • Luis_ST
    • Tavi007
    • Draco18s
    • dresacraft
    • hugo.talento@gmail.com
    • HDMI_Steckdose
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] Help with custom crafting table & chests (using wood OreDict)
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community