Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Show your code for creating and registering your BlockItems, they seem to be missing actual blocks.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

  • Author

This is my BlockInit class where I register Blocks and BlockItems

package com.Andrew.Realism.init;

import com.Andrew.Realism.RealismMod;
import com.Andrew.Realism.RealismMod.Realism;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.Item.Properties;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.registries.ObjectHolder;

@ObjectHolder(RealismMod.MOD_ID)
@Mod.EventBusSubscriber(modid = RealismMod.MOD_ID, bus = Bus.MOD)
public class BlockInit 
{
	// Diamond Ores
	public static final Block ore_red_diamond = null;
	public static final Block ore_blue_diamond = null;
	public static final Block ore_green_diamond = null;
	public static final Block ore_yellow_diamond = null;
	public static final Block ore_orange_diamond = null;
	public static final Block ore_pink_diamond = null;
	public static final Block ore_purple_diamond = null;
	
	//Other Ores
	public static final Block ore_ruby = null;
	public static final Block ore_sapphire = null;
	public static final Block ore_steel = null;
	public static final Block ore_titanium = null;
	public static final Block ore_vanadium = null;
	public static final Block ore_ameythest = null;
	
	@SubscribeEvent
	public static void registerBlocks(final RegistryEvent.Register<Block> event)
	{
		//Diamond Ores
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL)).setRegistryName("ore_red_diamond"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL)).setRegistryName("ore_blue_diamond"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL)).setRegistryName("ore_green_diamond"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL)).setRegistryName("ore_yellow_diamond"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL)).setRegistryName("ore_orange_diamond"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL)).setRegistryName("ore_pink_diamond"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL)).setRegistryName("ore_purple_diamond"));
		
		//Other Ores
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL)).setRegistryName("ore_ruby"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL)).setRegistryName("ore_sapphire"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(2.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(1).sound(SoundType.METAL)).setRegistryName("ore_steel"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(4.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(3).sound(SoundType.METAL)).setRegistryName("ore_titanium"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(4.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(3).sound(SoundType.METAL)).setRegistryName("ore_vanadium"));
		event.getRegistry().register(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 2.5F).harvestTool(ToolType.PICKAXE).harvestLevel(3).sound(SoundType.METAL)).setRegistryName("ore_amyethest"));
		
		//Diamond Blocks
	}
	
	@SubscribeEvent
	public static void registerBlockitems(final RegistryEvent.Register<Item> event)
	{
		//Diamond Ores
		event.getRegistry().register(new BlockItem(ore_red_diamond, new Item.Properties().group(Realism.instance)).setRegistryName("ore_red_diamond"));
		event.getRegistry().register(new BlockItem(ore_blue_diamond, new Item.Properties().group(Realism.instance)).setRegistryName("ore_blue_diamond"));
		event.getRegistry().register(new BlockItem(ore_green_diamond, new Item.Properties().group(Realism.instance)).setRegistryName("ore_green_diamond"));
		event.getRegistry().register(new BlockItem(ore_yellow_diamond, new Item.Properties().group(Realism.instance)).setRegistryName("ore_yellow_diamond"));
		event.getRegistry().register(new BlockItem(ore_orange_diamond, new Item.Properties().group(Realism.instance)).setRegistryName("ore_orange_diamond"));
		event.getRegistry().register(new BlockItem(ore_pink_diamond, new Item.Properties().group(Realism.instance)).setRegistryName("ore_pink_diamond"));
		event.getRegistry().register(new BlockItem(ore_purple_diamond, new Item.Properties().group(Realism.instance)).setRegistryName("ore_purple_diamond"));
		
		//Other Ores
		event.getRegistry().register(new BlockItem(ore_ruby, new Item.Properties().group(Realism.instance)).setRegistryName("ore_ruby"));
		event.getRegistry().register(new BlockItem(ore_sapphire, new Item.Properties().group(Realism.instance)).setRegistryName("ore_sapphire"));
		event.getRegistry().register(new BlockItem(ore_steel, new Item.Properties().group(Realism.instance)).setRegistryName("ore_steel"));
		event.getRegistry().register(new BlockItem(ore_titanium, new Item.Properties().group(Realism.instance)).setRegistryName("ore_titanium"));
		event.getRegistry().register(new BlockItem(ore_vanadium, new Item.Properties().group(Realism.instance)).setRegistryName("ore_vanadium"));
		event.getRegistry().register(new BlockItem(ore_ameythest, new Item.Properties().group(Realism.instance)).setRegistryName("ore_amyethest"));
		//Diamond Blocks
		
	}
}

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.