123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- package me.km.blocks;
- import me.km.fluids.BlockFluidBase;
- import me.km.fluids.BlockFluidHoney;
- import me.km.fluids.BlockFluidPoison;
- import me.km.fluids.ModFluids;
- import me.km.items.ItemMetal;
- import me.km.items.ModItems;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.MapColor;
- import net.minecraft.block.material.Material;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemBlock;
- import net.minecraftforge.fml.common.registry.GameRegistry;
- import net.minecraftforge.registries.IForgeRegistry;
- public class ModBlocks
- {
- // ores + blocks
- public static BlockOre copperOre;
- public static BlockBase copperBlock;
-
- public static BlockOre tinOre;
- public static BlockBase tinBlock;
-
- public static BlockBase bronzeBlock;
-
- public static BlockOre silverOre;
- public static BlockBase silverBlock;
-
- // misc
- public static BlockBase guildblock;
- public static BlockBase artefact;
- public static BlockHay realHayBlock;
- public static BlockHayBed realHayBed;
-
- public static BlockBase crateAcacia;
- public static BlockBase crateBigOak;
- public static BlockBase crateBirch;
- public static BlockBase crateJungle;
- public static BlockBase crateOak;
- public static BlockBase crateSpruce;
-
- public static BlockWoodCauldron cauldronOak;
- public static BlockWoodCauldron cauldronBirch;
- public static BlockWoodCauldron cauldronAcacia;
- public static BlockWoodCauldron cauldronJungle;
- public static BlockWoodCauldron cauldronSpruce;
- public static BlockWoodCauldron cauldronBigOak;
-
- public static BlockCampFire campFire;
- public static BlockCampFireBurning campFireBurning;
- public static BlockCampFireBurnt campFireBurnt;
-
- // traps
- public static BlockSpikeTrap spikes;
-
- // fluids
- public static BlockFluidPoison poison;
- public static BlockFluidHoney honey;
-
- public static void initBlocks(IForgeRegistry<Block> r)
- {
- // ores + blocks
- copperOre = register(r, new BlockOre("copper_ore", "oreCopper"));
- copperBlock = register(r, (BlockBase) new BlockBase(Material.IRON, "copper_block", "blockCopper")
- .setMapColor(MapColor.BROWN).setHardness(3).setResistance(10));
- tinOre = register(r, new BlockOre("tin_ore", "oreTin"));
- tinBlock = register(r, (BlockBase) new BlockBase(Material.IRON, "tin_block", "blockTin")
- .setMapColor(MapColor.IRON).setHardness(3).setResistance(5));
- bronzeBlock = register(r, (BlockBase) new BlockBase(Material.IRON, "bronze_block", "blockBronze")
- .setMapColor(MapColor.YELLOW).setHardness(5).setResistance(10));
- silverOre = register(r, new BlockOre("silver_ore", "oreSilver"));
- silverBlock = register(r, (BlockBase) new BlockBase(Material.IRON, "silver_block", "blockSilver")
- .setMapColor(MapColor.IRON).setHardness(5).setResistance(10));
-
- // misc
- guildblock = register(r, (BlockBase) new BlockBase(Material.IRON, "guild_block", "blockGuild")
- .setHardness(50.0F).setResistance(2000.0F));
- artefact = register(r, (BlockBase) new BlockBase(Material.IRON, "artefact", "artefact")
- .setHardness(50.0F).setResistance(2000.0F));
- realHayBlock = register(r, new BlockHay("real_hay_block", "realHayBlock"));
- realHayBed = register(r, new BlockHayBed("real_hay_bed", "realHayBed"));
-
- crateAcacia = register(r, new BlockBase(Material.WOOD, "crate_acacia", "crateAcacia").setCreativeTab(CreativeTabs.DECORATIONS));
- crateBigOak = register(r, new BlockBase(Material.WOOD, "crate_big_oak", "crateBigOak").setCreativeTab(CreativeTabs.DECORATIONS));
- crateBirch = register(r, new BlockBase(Material.WOOD, "crate_birch", "crateBirch").setCreativeTab(CreativeTabs.DECORATIONS));
- crateJungle = register(r, new BlockBase(Material.WOOD, "crate_jungle", "crateJungle").setCreativeTab(CreativeTabs.DECORATIONS));
- crateOak = register(r, new BlockBase(Material.WOOD, "crate_oak", "crateOak").setCreativeTab(CreativeTabs.DECORATIONS));
- crateSpruce = register(r, new BlockBase(Material.WOOD, "crate_spruce", "crateSpruce").setCreativeTab(CreativeTabs.DECORATIONS));
-
- cauldronOak = register(r, new BlockWoodCauldron("cauldron_oak", "cauldronOak"));
- cauldronBirch = register(r, new BlockWoodCauldron("cauldron_birch", "cauldronBirch"));
- cauldronAcacia = register(r, new BlockWoodCauldron("cauldron_acacia", "cauldronAcacia"));
- cauldronJungle = register(r, new BlockWoodCauldron("cauldron_jungle", "cauldronJungle"));
- cauldronSpruce = register(r, new BlockWoodCauldron("cauldron_spruce", "cauldronSpruce"));
- cauldronBigOak = register(r, new BlockWoodCauldron("cauldron_big_oak", "cauldronBigOak"));
- GameRegistry.registerTileEntity(TileEntityCauldron.class, "km:cauldron");
-
- campFire = register(r, new BlockCampFire("camp_fire", "campFire"));
- campFireBurning = (BlockCampFireBurning) register(r, new BlockCampFireBurning("camp_fire_burning", "campFireBurning")).setLightLevel(1);
- campFireBurnt = register(r, new BlockCampFireBurnt("camp_fire_burnt", "campFireBurnt"));
- GameRegistry.registerTileEntity(TileEntityCampFire.class, campFireBurning.getRegistryName().toString());
-
- // traps
- spikes = register(r, new BlockSpikeTrap(Material.IRON, "spikes", "spikes"));
-
- // fluids
- poison = register(r, new BlockFluidPoison(ModFluids.poison, Material.WATER));
- honey = register(r, new BlockFluidHoney(ModFluids.honey, Material.WATER));
-
- // overwrites
- register(r, Blocks.FARMLAND, new BlockNoTrampleFarmland());
- }
-
- private static void register(IForgeRegistry<Block> r, Block old, Block newBlock)
- {
- newBlock.setRegistryName(old.getRegistryName());
- r.register(newBlock);
- }
-
- public static void initItemBlocks(IForgeRegistry<Item> r)
- {
- // ores + blocks
- register(r, copperOre, getItemBlock(copperOre));
- register(r, copperBlock, getItemBlock(copperBlock));
-
- register(r, tinOre, getItemBlock(tinOre));
- register(r, tinBlock, getItemBlock(tinBlock));
-
- register(r, bronzeBlock, getItemBlock(bronzeBlock));
-
- register(r, silverOre, getItemBlock(silverOre));
- register(r, silverBlock, getItemBlock(silverBlock));
- // misc
- register(r, guildblock, getItemBlock(guildblock));
- register(r, artefact, getItemBlock(artefact));
-
- register(r, realHayBlock, getItemBlock(realHayBlock));
-
- register(r, crateAcacia, getItemBlock(crateAcacia));
- register(r, crateBigOak, getItemBlock(crateBigOak));
- register(r, crateBirch, getItemBlock(crateBirch));
- register(r, crateJungle, getItemBlock(crateJungle));
- register(r, crateOak, getItemBlock(crateOak));
- register(r, crateSpruce, getItemBlock(crateSpruce));
-
- cauldronOak.setItem(ModItems.cauldronOak);
- cauldronBirch.setItem(ModItems.cauldronBirch);
- cauldronAcacia.setItem(ModItems.cauldronAcacia);
- cauldronJungle.setItem(ModItems.cauldronJungle);
- cauldronSpruce.setItem(ModItems.cauldronSpruce);
- cauldronBigOak.setItem(ModItems.cauldronBigOak);
-
- // traps
- register(r, spikes, getItemMetal(spikes));
-
- // fluids
- register(r, poison, getItemBlock(poison));
- register(r, honey, getItemBlock(honey));
- }
- private static void register(IForgeRegistry<Item> r, Block block, Item itemBlock)
- {
- r.register(itemBlock);
- if(block instanceof IBlockBase)
- {
- ((IBlockBase) block).registerItemModel(itemBlock);
- }
- if(block instanceof BlockFluidBase)
- {
- ((BlockFluidBase) block).registerBlockModel();
- }
- }
-
- private static <T extends Block> T register(IForgeRegistry<Block> r, T block)
- {
- r.register(block);
- return block;
- }
- private static ItemBlock getItemBlock(Block block)
- {
- ItemBlock itemBlock = new ItemBlock(block);
- itemBlock.setRegistryName(block.getRegistryName());
- return itemBlock;
- }
-
- private static ItemMetal getItemMetal(Block block)
- {
- ItemMetal itemBlock = new ItemMetal(block);
- itemBlock.setRegistryName(block.getRegistryName());
- return itemBlock;
- }
- }
|