Jump to content

Recommended Posts

Posted

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.

Posted

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

×   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



×
×
  • Create New...

Important Information

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