Posted April 9, 20196 yr 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 } } Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
April 9, 20196 yr Author 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? Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
April 9, 20196 yr Author 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 April 9, 20196 yr by winnetrie Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
April 9, 20196 yr Author 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 Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
April 9, 20196 yr Author 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 Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
April 9, 20196 yr 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.
April 9, 20196 yr 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 April 9, 20196 yr 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.
April 9, 20196 yr Author Should i use ForgeRegistries.BLOCKS.getValuesCollection() because getValues() is deprecated, but it says this: @Nonnull default Collection<V> getValuesCollection() { // TODO rename this to getValues in 1.13 return getValues(); Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
April 9, 20196 yr Author 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 April 9, 20196 yr by winnetrie Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
April 9, 20196 yr Author 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 April 9, 20196 yr by winnetrie Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
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.