Guest User

Untitled

a guest
Sep 18th, 2015
103
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.mightydanp.eot.block;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import com.mightydanp.eot.EotCore;
  7. import com.mightydanp.eot.client.render.TextureEssenceOre;
  8. import com.mightydanp.eot.inventory.TileEntityEssenceOre;
  9. import com.mightydanp.eot.item.ItemEssenceOre;
  10. import com.mightydanp.eot.lib.BlockStrings;
  11. import com.mightydanp.eot.lib.References;
  12.  
  13. import cpw.mods.fml.common.registry.GameRegistry;
  14. import cpw.mods.fml.relauncher.Side;
  15. import cpw.mods.fml.relauncher.SideOnly;
  16. import net.minecraft.block.Block;
  17. import net.minecraft.block.material.Material;
  18. import net.minecraft.client.Minecraft;
  19. import net.minecraft.client.renderer.texture.IIconRegister;
  20. import net.minecraft.creativetab.CreativeTabs;
  21. import net.minecraft.init.Blocks;
  22. import net.minecraft.item.Item;
  23. import net.minecraft.item.ItemStack;
  24. import net.minecraft.tileentity.TileEntity;
  25. import net.minecraft.util.IIcon;
  26. import net.minecraft.world.IBlockAccess;
  27. import net.minecraft.world.World;
  28.  
  29. public class BlockEssenceOre extends Block {
  30.  
  31. private static boolean isActive;
  32. private final boolean isActive2;
  33.  
  34. @SideOnly(Side.CLIENT)
  35. private IIcon[] iconArray;
  36.  
  37. public static String[] subBlocks = new String[] {"Magic", "Air", "Earth", "Fire", "Water"};
  38.  
  39.  
  40. protected BlockEssenceOre(String unlocalizedName, boolean isActive) {
  41. super(Material.rock);
  42. isActive2 = isActive;
  43. this.setCreativeTab(EotCore.eotTab);
  44. this.setBlockName(unlocalizedName);
  45. this.setTickRandomly(true);
  46. GameRegistry.registerBlock(this, ItemEssenceOre.class, this.getUnlocalizedName());
  47. }
  48.  
  49. public TileEntity createNewTileEntity(World world, int var1) {
  50. return new TileEntityEssenceOre();
  51. }
  52.  
  53. public static void updateBlockTexture(boolean isItDayTime, World world, int x, int y, int z) {
  54. TileEntity tileentity = world.getTileEntity(x, y, z);
  55. isActive = true;
  56.  
  57. if (isItDayTime) {
  58. world.setBlock(x, y, z, ModBlocks.EssenceStoneActive);
  59. } else {
  60. world.setBlock(x, y, z, ModBlocks.EssenceStone);
  61. }
  62. isActive = false;
  63.  
  64. if (tileentity != null) {
  65. tileentity.validate();
  66. world.setTileEntity(x, y, z, tileentity);
  67. }
  68. }
  69.  
  70. @SideOnly(Side.CLIENT)
  71. @Override
  72. public void getSubBlocks(Item item, CreativeTabs creativeTab, List list){
  73. for(int i = 0; i < subBlocks.length; i++){
  74. list.add(new ItemStack(item, 1, i));
  75. }
  76. }
  77.  
  78. @Override
  79. public int damageDropped(int meta){
  80. return meta;
  81. }
  82.  
  83. @SideOnly(Side.CLIENT)
  84. @Override
  85. public void registerBlockIcons(IIconRegister par1IconRegister){
  86. this.iconArray = new IIcon[subBlocks.length];
  87. for(int i = 0; i < subBlocks.length; i++){
  88. this.iconArray[i] = par1IconRegister.registerIcon(this.isActive2 ? References.RESOURCESPREFIX + BlockStrings.ESSENCESTONE_NAME + subBlocks[i] : References.RESOURCESPREFIX + BlockStrings.ESSENCESTONE_NAME);
  89. }
  90. }
  91.  
  92. @SideOnly(Side.CLIENT)
  93. @Override
  94. public IIcon getIcon(int side, int meta)
  95. {
  96. return iconArray[meta];
  97. }
  98. }
RAW Paste Data