Add ore dictionary support
This commit is contained in:
parent
2bf03b8a6a
commit
2761f264f7
@ -36,6 +36,8 @@ public class SSSPCore {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
ModBlocks.oreCopper.initOreDict();
|
||||
ModItems.ingotCopper.initOreDict();
|
||||
ModRecipes.init();
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,24 @@ package com.pjht.ssspcore.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class BlockOre extends BlockBase {
|
||||
public BlockOre(String name) {
|
||||
private String oreName;
|
||||
|
||||
public BlockOre(String name, String oreName) {
|
||||
super(Material.ROCK, name);
|
||||
|
||||
this.oreName = oreName;
|
||||
|
||||
setHardness(3f);
|
||||
setResistance(5f);
|
||||
}
|
||||
|
||||
public void initOreDict() {
|
||||
OreDictionary.registerOre(oreName, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockOre setCreativeTab(CreativeTabs tab) {
|
||||
super.setCreativeTab(tab);
|
||||
|
@ -5,7 +5,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
public class ModBlocks {
|
||||
public static BlockOre oreCopper = new BlockOre("ore_copper");
|
||||
public static BlockOre oreCopper = new BlockOre("ore_copper","oreCopper");
|
||||
|
||||
public static void register(IForgeRegistry<Block> registry) {
|
||||
registry.registerAll(
|
||||
|
19
src/main/java/com/pjht/ssspcore/item/ItemOre.java
Normal file
19
src/main/java/com/pjht/ssspcore/item/ItemOre.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.pjht.ssspcore.item;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class ItemOre extends ItemBase {
|
||||
|
||||
private String oreName;
|
||||
|
||||
public ItemOre(String name, String oreName) {
|
||||
super(name);
|
||||
|
||||
this.oreName = oreName;
|
||||
}
|
||||
|
||||
public void initOreDict() {
|
||||
OreDictionary.registerOre(oreName, this);
|
||||
}
|
||||
|
||||
}
|
@ -5,7 +5,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
public class ModItems {
|
||||
public static ItemBase ingotCopper = new ItemBase("ingot_copper");
|
||||
public static ItemOre ingotCopper = new ItemOre("ingot_copper", "ingotCopper");
|
||||
|
||||
public static void register(IForgeRegistry<Item> registry) {
|
||||
registry.registerAll(
|
||||
|
Loading…
x
Reference in New Issue
Block a user