From f50f144b28576099696bc987fcecb25fe5ca0138 Mon Sep 17 00:00:00 2001 From: Gig Date: Sun, 12 Apr 2015 20:21:33 +0100 Subject: [PATCH] Added storage blocks --- .../java/techreborn/blocks/BlockStorage.java | 86 +++++++++++++++++++ src/main/java/techreborn/init/ModBlocks.java | 7 ++ .../itemblocks/ItemBlockStorage.java | 16 ++++ .../assets/techreborn/lang/en_US.lang | 18 ++++ 4 files changed, 127 insertions(+) create mode 100644 src/main/java/techreborn/blocks/BlockStorage.java create mode 100644 src/main/java/techreborn/itemblocks/ItemBlockStorage.java diff --git a/src/main/java/techreborn/blocks/BlockStorage.java b/src/main/java/techreborn/blocks/BlockStorage.java new file mode 100644 index 000000000..2fa1e1148 --- /dev/null +++ b/src/main/java/techreborn/blocks/BlockStorage.java @@ -0,0 +1,86 @@ +package techreborn.blocks; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraftforge.common.util.ForgeDirection; +import techreborn.client.TechRebornCreativeTab; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockStorage extends Block{ + + public static final String[] types = new String[] + { + "Silver", "Aluminium", "Titanium", "Sapphire", "Ruby", "GreenSapphire", "Chrome", "Electrum", "Tungsten", + "Lead", "Zinc", "Brass", "Steel", "Platinum", "Nickel", "Invar", + }; + + private IIcon[] textures; + + public BlockStorage(Material material) + { + super(material); + setBlockName("techreborn.storage"); + setCreativeTab(TechRebornCreativeTab.instance); + setHardness(2f); + } + + @Override + public Item getItemDropped(int par1, Random random, int par2) + { + return Item.getItemFromBlock(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; meta++) + { + list.add(new ItemStack(item, 1, meta)); + } + } + + @Override + public int damageDropped(int metaData) + { + return metaData; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) + { + this.textures = new IIcon[types.length]; + + for (int i = 0; i < types.length; i++) + { + textures[i] = iconRegister.registerIcon("techreborn:" + "storage"+types[i]); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metaData) + { + metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); + + if (ForgeDirection.getOrientation(side) == ForgeDirection.UP + || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) + { + return textures[metaData]; + } else { + return textures[metaData]; + } + } + +} diff --git a/src/main/java/techreborn/init/ModBlocks.java b/src/main/java/techreborn/init/ModBlocks.java index fcbf27c8f..69b4482dd 100644 --- a/src/main/java/techreborn/init/ModBlocks.java +++ b/src/main/java/techreborn/init/ModBlocks.java @@ -7,11 +7,13 @@ import net.minecraftforge.oredict.OreDictionary; import techreborn.blocks.BlockOre; import techreborn.blocks.BlockQuantumChest; import techreborn.blocks.BlockQuantumTank; +import techreborn.blocks.BlockStorage; import techreborn.blocks.BlockThermalGenerator; import techreborn.client.TechRebornCreativeTab; import techreborn.itemblocks.ItemBlockOre; import techreborn.itemblocks.ItemBlockQuantumChest; import techreborn.itemblocks.ItemBlockQuantumTank; +import techreborn.itemblocks.ItemBlockStorage; import techreborn.tiles.TileQuantumChest; import techreborn.tiles.TileQuantumTank; import techreborn.tiles.TileThermalGenerator; @@ -24,6 +26,7 @@ public class ModBlocks { public static Block quantumTank; public static Block quantumChest; public static Block ore; + public static Block storage; public static void init() { @@ -42,6 +45,10 @@ public class ModBlocks { ore = new BlockOre(Material.rock); GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore"); LogHelper.info("TechReborns Blocks Loaded"); + + storage = new BlockStorage(Material.rock); + GameRegistry.registerBlock(storage, ItemBlockStorage.class, "techreborn.storage"); + LogHelper.info("TechReborns Blocks Loaded"); registerOreDict(); } diff --git a/src/main/java/techreborn/itemblocks/ItemBlockStorage.java b/src/main/java/techreborn/itemblocks/ItemBlockStorage.java new file mode 100644 index 000000000..abce3c256 --- /dev/null +++ b/src/main/java/techreborn/itemblocks/ItemBlockStorage.java @@ -0,0 +1,16 @@ +package techreborn.itemblocks; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemMultiTexture; +import techreborn.blocks.BlockOre; +import techreborn.blocks.BlockStorage; +import techreborn.init.ModBlocks; + +public class ItemBlockStorage extends ItemMultiTexture{ + + public ItemBlockStorage(Block block) + { + super(ModBlocks.storage, ModBlocks.storage, BlockStorage.types); + } + +} diff --git a/src/main/resources/assets/techreborn/lang/en_US.lang b/src/main/resources/assets/techreborn/lang/en_US.lang index 06fb1dbc7..76b91784a 100644 --- a/src/main/resources/assets/techreborn/lang/en_US.lang +++ b/src/main/resources/assets/techreborn/lang/en_US.lang @@ -18,6 +18,24 @@ tile.techreborn.ore.Sheldonite.name=Sheldonite Ore tile.techreborn.ore.Olivine.name=Olivine Ore tile.techreborn.ore.Sodalite.name=Sodalite Ore +#Storage +tile.techreborn.storage.Silver.name=Block of Silver +tile.techreborn.storage.Aluminium.name=Block of Aluminium +tile.techreborn.storage.Titanium.name=Block of Titanium +tile.techreborn.storage.Sapphire.name=Block of Sapphire +tile.techreborn.storage.Ruby.name=Block of Ruby +tile.techreborn.storage.GreenSapphire.name=Block of Green Sapphire +tile.techreborn.storage.Chrome.name=Block of Chrome +tile.techreborn.storage.Electrum.name=Block of Electrum +tile.techreborn.storage.Lead.name=Block of Lead +tile.techreborn.storage.Zinc.name=Block of Zinc +tile.techreborn.storage.Brass.name=Block of Brass +tile.techreborn.storage.Steel.name=Block of Steel +tile.techreborn.storage.Platinum.name=Block of Platinum +tile.techreborn.storage.Nickel.name=Block of Nickel +tile.techreborn.storage.Invar.name=Block of Invar +tile.techreborn.storage.Tungsten.name=Block of Tungsten + #Dusts item.techreborn.dust.Almandine.name=Almandine Dust item.techreborn.dust.Aluminium.name=Aluminium Dust