Jump to content

MC 1.12.2 Registering things correctly


winnetrie

Recommended Posts

Because i have been told not to use static initializers, i have come up with an other approach to register my stuff.

I'm wondering if this is a good 1?

 

So i have a ModBlocks class that has 2 methods: 1 for adding my blocks to a list and the other to iniatilize that

It looks like this:

public class ModBlocks {
	
	public static final List<Block> BLOCKS = new ArrayList<Block>();
	public static final List<ItemBlock> ITEMBLOCKS = new ArrayList<ItemBlock>();
	
	
	
	public static void addBlockToRegistryList(Block block) {
		
		BLOCKS.add(block);
		ITEMBLOCKS.add((ItemBlock) new ItemBlock(block).setRegistryName(block.getRegistryName()));
		
	}
	public static void init() {
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.WHITE_STAINED_HARDENED_CLAY, "white_terracotta_bricks"));
	    
}

Then i have a RegistryHandler class:

@EventBusSubscriber
public class RegistryHandler {
	
	@SubscribeEvent
	public static void onItemRegister(RegistryEvent.Register<Item> event) {
		
		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
	}
	
	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event) {
		
		event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
	}
	
	@SubscribeEvent

	public static void registerItemBlocks(RegistryEvent.Register<Item> event) {

		event.getRegistry().registerAll(ModBlocks.ITEMBLOCKS.toArray(new ItemBlock[0]));

	}

}

And my ClientProxy:

@EventBusSubscriber
public class ClientProxy implements IProxy{
	
	private static final String DEFAULT_VARIANT = "inventory";

	

	@SubscribeEvent
	public static void onModelRegister(ModelRegistryEvent event) {
		
		for (Item item : ModItems.ITEMS) {
			
			registerItemModel(item);
		}
		
		for (Block block : ModBlocks.BLOCKS) {
			
			registerBlockModel(block);
		}
		
		
	}
	
	@Override
	public void PreInit(FMLPreInitializationEvent event) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void Init(FMLInitializationEvent event) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void PostInit(FMLPostInitializationEvent event) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void ServerStarting(FMLServerStartingEvent event) {
		// TODO Auto-generated method stub
		
	}

	public static void registerItemModel(Item item) {
		
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), DEFAULT_VARIANT));
		
	}
    public static void registerBlockModel(Block block) {
		
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), DEFAULT_VARIANT));
		
	}

}

and my main class:

@Mod(modid = References.MOD_ID, name = References.NAME, version = References.VERSION)
public class Wtemod {
	
	@Instance
	public static Wtemod instance;
	
	@SidedProxy(clientSide = References.CLIENT_PROXY_CLASS, serverSide = References.SERVER_PROXY_CLASS)
	public static IProxy proxy;
	
	@EventHandler
	public void PreInit(FMLPreInitializationEvent event)
	{
		//entities & networking
	}
	
	@EventHandler
	public void Init(FMLInitializationEvent event)
	{
		//registry events
		ModBlocks.init();
		ModRecipes.init();
	}
	
	@EventHandler
	public void PostInit(FMLPostInitializationEvent event)
	{
		//inter-mod stuff
	}
	@EventHandler
    public void serverStarting(FMLServerStartingEvent event)
    {
		//server commands registering
    }

	
}

 

Link to comment
Share on other sites

Alright this is absolutely not working, because the subscribe event triggers before the ModBlocks.init();

So i changed my class to this:

@EventBusSubscriber
public class ModBlocks {
	
	public static final List<Block> BLOCKS = new ArrayList<Block>();
	public static final List<ItemBlock> ITEMBLOCKS = new ArrayList<ItemBlock>();
	
	
	public static void addBlockToRegistryList(Block block) {
		
		BLOCKS.add(block);
		ITEMBLOCKS.add((ItemBlock) new ItemBlock(block).setRegistryName(block.getRegistryName()));
		
		System.out.println(block.getRegistryName() + "has been registered");
		
	}
	
	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event) {
		
		addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.WHITE_STAINED_HARDENED_CLAY, "white_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.ORANGE_STAINED_HARDENED_CLAY, "orange_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.MAGENTA_STAINED_HARDENED_CLAY, "magenta_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.LIGHT_BLUE_STAINED_HARDENED_CLAY, "light_blue_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.YELLOW_STAINED_HARDENED_CLAY, "yellow_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.LIME_STAINED_HARDENED_CLAY, "lime_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.PINK_STAINED_HARDENED_CLAY, "pink_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.GRAY_STAINED_HARDENED_CLAY, "gray_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.SILVER_STAINED_HARDENED_CLAY, "silver_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.CYAN_STAINED_HARDENED_CLAY, "cyan_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.PURPLE_STAINED_HARDENED_CLAY, "purple_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.BLUE_STAINED_HARDENED_CLAY, "blue_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.BROWN_STAINED_HARDENED_CLAY, "brown_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.GREEN_STAINED_HARDENED_CLAY, "green_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.RED_STAINED_HARDENED_CLAY, "red_terracotta_bricks"));
	    addBlockToRegistryList(new BlockTerracotta(Material.ROCK, MapColor.BLACK_STAINED_HARDENED_CLAY, "black_terracotta_bricks"));
		
		
		event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
		
	}
	
	@SubscribeEvent
	public static void registerItemBlocks(RegistryEvent.Register<Item> event) {

		event.getRegistry().registerAll(ModBlocks.ITEMBLOCKS.toArray(new ItemBlock[0]));
		
	}

}

This is working fine, but i'm not sure putting the addBlockToRegistryList inside the onBlockRegister is the correct place.

It had to be within a subscribe event or it won't work.

So i was wondering if there is a subscribevent where i can put it?

 

Link to comment
Share on other sites

Yes i know i can do this as simple as your example.

Main reason was to have clean code, but it takes as much as space like the simple way.

On the other hand, having all blocks and items stored in a list can be usefull some day.

Meh….That sounds stupid when i read it again ?

I guess i just wanted to make it fancy, but you are so right about this.

 

EDIT: It does takes less space to register blocks and itemblocks. both are  done in 1 method, So registering block and it's itemblock takes only 1 line instead of 2 lines each time.

Or can this be done otherwise?

Edited by winnetrie
Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Oh, if only there was a data structure that kept track of registered things... You know, some kind of, i don't know, Registry, maybe?

Yes ….haha i know, that's why i said this: 

 

34 minutes ago, winnetrie said:

Meh….That sounds stupid when i read it again ?

 

Ow yes i could loop trough the registry and look for blocks with my modid, then register the itemblock for it...ofcourse.

Thank you

Link to comment
Share on other sites

btw to get a block from the registry do i call this?:

Block.getBlockFromName(References.MOD_ID + ":" + "white_terracotta_bricks");

 

I ask, because i only know this way.

There is also 

Block.REGISTRY.getObjectById(id) 

But i don't know the id, only the name

Link to comment
Share on other sites

21 minutes ago, winnetrie said:

btw to get a block from the registry do i call this?:


Block.getBlockFromName(References.MOD_ID + ":" + "white_terracotta_bricks");

 

I ask, because i only know this way.

There is also 


Block.REGISTRY.getObjectById(id) 

But i don't know the id, only the name

Don't use ID, you can just have a static instance of the Block in your registry class.

Link to comment
Share on other sites

He just linked you the source-code for the class that specifically holds all registries... perhaps you should use that class?

ForgeRegistries.BLOCKS.getValue(key) to get a specific block, where key is the block's RegistryName,
If you want to get all your mod's blocks at once, you would need to iterate over the registry first. (personally I'd use a lambda stream with a filter matching each blocks's RegistryName's getResourceDomain (mod-id), then save that in a collection somewhere)

 

 

7 minutes ago, Big_Bad_E said:

Don't use ID, you can just have a static instance of the Block in your registry class.

Whilst not using raw ID's is correct (they can be different on different servers!) NEVER use static instances. The whole RegistryEvent was made to remove this practice.
Use the ObjectHolder annotation instead if you must have an associated field.
 

Edited by Matryoshika

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Alright i'm done rewriting the code. Result looks like this:

ModRegistry class:

Spoiler

@EventBusSubscriber
public class ModRegistry {
	
	
	@SubscribeEvent
	public static void onItemRegister(RegistryEvent.Register<Item> event) {
		
		System.out.println("Registering all items from the ITEMS registrylist");
		
		//REGISTERING ALL ITEMBLOCKS
		for (Block block : ForgeRegistries.BLOCKS.getValuesCollection()) {
			if (block.getRegistryName().getResourceDomain().equals(References.MOD_ID)) {

			    event.getRegistry().register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
			}
		}
		
		
		//REGISTERING ALL ITEMS
		event.getRegistry().registerAll(
				
		//adding stained clayballs
		new ItemClayBall("white_stained_clayball"),
		new ItemClayBall("orange_stained_clayball"),
		new ItemClayBall("magenta_stained_clayball"),
		new ItemClayBall("light_blue_stained_clayball"),
		new ItemClayBall("yellow_stained_clayball"),
		new ItemClayBall("lime_stained_clayball"),
		new ItemClayBall("pink_stained_clayball"),
		new ItemClayBall("gray_stained_clayball"),
		new ItemClayBall("silver_stained_clayball"),
		new ItemClayBall("cyan_stained_clayball"),
		new ItemClayBall("purple_stained_clayball"),
		new ItemClayBall("blue_stained_clayball"),
		new ItemClayBall("brown_stained_clayball"),
		new ItemClayBall("green_stained_clayball"),
		new ItemClayBall("red_stained_clayball"),
		new ItemClayBall("black_stained_clayball"),
	
		//adding colored terracotta brick
		new ItemBrick("white_terracotta_brick"),
		new ItemBrick("orange_terracotta_brick"),
		new ItemBrick("magenta_terracotta_brick"),
		new ItemBrick("light_blue_terracotta_brick"),
		new ItemBrick("yellow_terracotta_brick"),
		new ItemBrick("lime_terracotta_brick"),
		new ItemBrick("pink_terracotta_brick"),
		new ItemBrick("gray_terracotta_brick"),
		new ItemBrick("silver_terracotta_brick"),
		new ItemBrick("cyan_terracotta_brick"),
		new ItemBrick("purple_terracotta_brick"),
		new ItemBrick("blue_terracotta_brick"),
		new ItemBrick("brown_terracotta_brick"),
		new ItemBrick("green_terracotta_brick"),
		new ItemBrick("red_terracotta_brick"),
		new ItemBrick("black_terracotta_brick")
		);
	}
	
	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event) {
		
		System.out.println("Registering all blocks from the BLOCKS registrylist");
		
		//REGISTERING ALL BLOCKS
		event.getRegistry().registerAll(
		
		//Creating terracotta bricks
		new BlockTerracotta(Material.ROCK, MapColor.WHITE_STAINED_HARDENED_CLAY, "white_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.ORANGE_STAINED_HARDENED_CLAY, "orange_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.MAGENTA_STAINED_HARDENED_CLAY, "magenta_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.LIGHT_BLUE_STAINED_HARDENED_CLAY, "light_blue_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.YELLOW_STAINED_HARDENED_CLAY, "yellow_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.LIME_STAINED_HARDENED_CLAY, "lime_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.PINK_STAINED_HARDENED_CLAY, "pink_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.GRAY_STAINED_HARDENED_CLAY, "gray_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.SILVER_STAINED_HARDENED_CLAY, "silver_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.CYAN_STAINED_HARDENED_CLAY, "cyan_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.PURPLE_STAINED_HARDENED_CLAY, "purple_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.BLUE_STAINED_HARDENED_CLAY, "blue_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.BROWN_STAINED_HARDENED_CLAY, "brown_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.GREEN_STAINED_HARDENED_CLAY, "green_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.RED_STAINED_HARDENED_CLAY, "red_terracotta_bricks"),
	    new BlockTerracotta(Material.ROCK, MapColor.BLACK_STAINED_HARDENED_CLAY, "black_terracotta_bricks"),
	    
	    
	    //Creating stained clay blocks
	    new BlockStainedClay("white_stained_clayball", Material.CLAY, MapColor.WHITE_STAINED_HARDENED_CLAY, "white_stained_clay"),
	    new BlockStainedClay("orange_stained_clayball", Material.CLAY, MapColor.ORANGE_STAINED_HARDENED_CLAY, "orange_stained_clay"),
	    new BlockStainedClay("magenta_stained_clayball", Material.CLAY, MapColor.MAGENTA_STAINED_HARDENED_CLAY, "magenta_stained_clay"),
	    new BlockStainedClay("light_blue_stained_clayball", Material.CLAY, MapColor.LIGHT_BLUE_STAINED_HARDENED_CLAY, "light_blue_stained_clay"),
	    new BlockStainedClay("yellow_stained_clayball", Material.CLAY, MapColor.YELLOW_STAINED_HARDENED_CLAY, "yellow_stained_clay"),
	    new BlockStainedClay("lime_stained_clayball", Material.CLAY, MapColor.LIME_STAINED_HARDENED_CLAY, "lime_stained_clay"),
	    new BlockStainedClay("pink_stained_clayball", Material.CLAY, MapColor.PINK_STAINED_HARDENED_CLAY, "pink_stained_clay"),
	    new BlockStainedClay("gray_stained_clayball", Material.CLAY, MapColor.GRAY_STAINED_HARDENED_CLAY, "gray_stained_clay"),
	    new BlockStainedClay("silver_stained_clayball", Material.CLAY, MapColor.SILVER_STAINED_HARDENED_CLAY, "silver_stained_clay"),
	    new BlockStainedClay("cyan_stained_clayball", Material.CLAY, MapColor.CYAN_STAINED_HARDENED_CLAY, "cyan_stained_clay"),
	    new BlockStainedClay("purple_stained_clayball", Material.CLAY, MapColor.PURPLE_STAINED_HARDENED_CLAY, "purple_stained_clay"),
	    new BlockStainedClay("blue_stained_clayball", Material.CLAY, MapColor.BLUE_STAINED_HARDENED_CLAY, "blue_stained_clay"),
	    new BlockStainedClay("brown_stained_clayball", Material.CLAY, MapColor.BROWN_STAINED_HARDENED_CLAY, "brown_stained_clay"),
	    new BlockStainedClay("green_stained_clayball", Material.CLAY, MapColor.GREEN_STAINED_HARDENED_CLAY, "green_stained_clay"),
	    new BlockStainedClay("red_stained_clayball", Material.CLAY, MapColor.RED_STAINED_HARDENED_CLAY, "red_stained_clay"),
	    new BlockStainedClay("black_stained_clayball", Material.CLAY, MapColor.BLACK_STAINED_HARDENED_CLAY, "black_stained_clay")
	    
	    );
		
		
	}
	
	
}

 

ClientProxy class:

Spoiler

@EventBusSubscriber
public class ClientProxy implements IProxy{
	
	private static final String DEFAULT_VARIANT = "inventory";

	@SubscribeEvent
	public static void onModelRegister(ModelRegistryEvent event) {
		
		for (Item item : ForgeRegistries.ITEMS.getValuesCollection()) {
			if (item.getRegistryName().getResourceDomain().equals(References.MOD_ID)) {
				registerItemModel(item);
			}
		}
		
		for (Block block : ForgeRegistries.BLOCKS.getValuesCollection()) {
			if (block.getRegistryName().getResourceDomain().equals(References.MOD_ID)) {
				registerBlockModel(block);
			}
		}
		
	}
	
	@Override
	public void PreInit(FMLPreInitializationEvent event) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void Init(FMLInitializationEvent event) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void PostInit(FMLPostInitializationEvent event) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void ServerStarting(FMLServerStartingEvent event) {
		// TODO Auto-generated method stub
		
	}

	public static void registerItemModel(Item item) {
		
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), DEFAULT_VARIANT));
		
	}
    public static void registerBlockModel(Block block) {
		
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), DEFAULT_VARIANT));
		
	}

}

 

 

BlockStainedClay class:

Spoiler

public class BlockStainedClay extends Block{
	
	public String itemdrop;

	public BlockStainedClay(String string, Material blockMaterialIn, MapColor blockMapColorIn, String name) {
		super(blockMaterialIn, blockMapColorIn);
		
		itemdrop = string;
		setHardness(0.1F);
		setSoundType(SoundType.GROUND);
		setUnlocalizedName(name);
		setRegistryName(References.PREFIX + name);
		setCreativeTab(CreativeTabs.BUILDING_BLOCKS);	
		
	}
	@Override
	public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
		
        return ForgeRegistries.ITEMS.getValue(new ResourceLocation(References.PREFIX + itemdrop));
    }

    @Override
    public int quantityDropped(Random random)
    {
        return 4;
    }

}

 

ModRecipes class: 

Spoiler

public class ModRecipes {
	
	public static void init() {
		
		GameRegistry.addSmelting(Utilities.getItem("white_stained_clayball"), new ItemStack(Utilities.getItem("white_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("orange_stained_clayball"), new ItemStack(Utilities.getItem("orange_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("magenta_stained_clayball"), new ItemStack(Utilities.getItem("magenta_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("light_blue_stained_clayball"), new ItemStack(Utilities.getItem("light_blue_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("yellow_stained_clayball"), new ItemStack(Utilities.getItem("yellow_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("lime_stained_clayball"), new ItemStack(Utilities.getItem("lime_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("pink_stained_clayball"), new ItemStack(Utilities.getItem("pink_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("gray_stained_clayball"), new ItemStack(Utilities.getItem("gray_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("silver_stained_clayball"), new ItemStack(Utilities.getItem("silver_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("cyan_stained_clayball"), new ItemStack(Utilities.getItem("cyan_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("purple_stained_clayball"), new ItemStack(Utilities.getItem("_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("blue_stained_clayball"), new ItemStack(Utilities.getItem("_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("brown_stained_clayball"), new ItemStack(Utilities.getItem("_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("green_stained_clayball"), new ItemStack(Utilities.getItem("_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("red_stained_clayball"), new ItemStack(Utilities.getItem("_terracotta_brick"), 1), 0.3F);
		GameRegistry.addSmelting(Utilities.getItem("black_stained_clayball"), new ItemStack(Utilities.getItem("_terracotta_brick"), 1), 0.3F);
		
		
		GameRegistry.addSmelting(Utilities.getBlock("white_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 0), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("orange_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 1), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("magenta_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 2), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("light_blue_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 3), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("yellow_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 4), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("lime_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 5), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("pink_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 6), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("gray_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 7), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("silver_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 8), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("cyan_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 9), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("purple_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 10), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("blue_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 11), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("brown_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 12), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("green_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 13), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("red_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 14), 0.35F);
		GameRegistry.addSmelting(Utilities.getBlock("black_stained_clay"), new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, 15), 0.35F);
		
	}

}

 

And also a Utilities class:

Spoiler

public class Utilities {
	
public static Block getBlock(String string) {
		
		ResourceLocation resourcelocation = new ResourceLocation(References.MOD_ID + ":" + string);
		return ForgeRegistries.BLOCKS.getValue(resourcelocation);
		
	}
    public static Item getItem(String string) {
    	
    	ResourceLocation resourcelocation = new ResourceLocation(References.MOD_ID + ":" + string);
    	return ForgeRegistries.ITEMS.getValue(resourcelocation);
	}

}

 

Can i improve this more or is this a good starting template?

Edited by winnetrie
Link to comment
Share on other sites

14 minutes ago, diesieben07 said:

A minor thing: In your Utilities class you can use the ResourceLocation constructor that takes 2 String instead of constructing it with concatenation. 

 

And start using json recipes.

Oh, alright. I'll change it later. Going to sleep now.

 

I am using .json recipes for crafting btw. Can we also do that with smelting recipes? 

EDIT: Sorry, but i can't find anything about json smelting recipes for 1.12.2.

Even in the minecraft recipe folder, there is none to find.

Edited by winnetrie
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.