Advertisement
Guest User

Untitled

a guest
Aug 25th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.38 KB | None | 0 0
  1. package wintercraft.blocks;
  2.  
  3. import static net.minecraftforge.common.util.ForgeDirection.DOWN;
  4.  
  5. import java.util.List;
  6. import java.util.Random;
  7.  
  8. import net.minecraft.block.Block;
  9. import net.minecraft.block.BlockContainer;
  10. import net.minecraft.block.material.Material;
  11. import net.minecraft.client.renderer.texture.IIconRegister;
  12. import net.minecraft.creativetab.CreativeTabs;
  13. import net.minecraft.entity.EntityLiving;
  14. import net.minecraft.init.Blocks;
  15. import net.minecraft.item.Item;
  16. import net.minecraft.item.ItemStack;
  17. import net.minecraft.tileentity.TileEntity;
  18. import net.minecraft.util.IIcon;
  19. import net.minecraft.util.MathHelper;
  20. import net.minecraft.world.World;
  21. import net.minecraftforge.common.util.ForgeDirection;
  22. import wintercraft.Wintercraft;
  23. import wintercraft.render.tileEntity.TileEntityOrnament;
  24. import cpw.mods.fml.relauncher.Side;
  25. import cpw.mods.fml.relauncher.SideOnly;
  26.  
  27. public class BlockOrnament extends BlockContainer {
  28.  
  29. public BlockOrnament(int texture, Material material) {
  30. super(material);
  31. this.setCreativeTab(Wintercraft.WintercraftTab);
  32. this.setBlockBounds(0.4F, 0.5F, 0.3F, 0.7F, 1F, 0.65F);
  33. }
  34.  
  35. public Item getItemDropped(int par1, Random par2Random, int par3)
  36. {
  37.     return Item.getItemFromBlock(WinterBlocks.ornament);
  38. }
  39.  
  40. /**
  41.  * checks to see if you can place this block can be placed on that side of a block: BlockLever overrides
  42.  */
  43. public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
  44. {
  45.     ForgeDirection dir = ForgeDirection.getOrientation(par5);
  46.     return dir == DOWN  && !par1World.isSideSolid(par2, par3 + 1, par4, DOWN);
  47.  
  48. }
  49.  
  50. @SideOnly(Side.CLIENT)
  51. private IIcon[] icons;
  52.  
  53. @SideOnly(Side.CLIENT)
  54. public void registerBlockIcons(IIconRegister par1IconRegister)
  55. {
  56.       this.icons = new IIcon[3];
  57.      
  58.       for(int i = 0; i < icons.length; i++)
  59.       {
  60.              this.icons[i] = par1IconRegister.registerIcon(Wintercraft.modid + ":" + (this.getUnlocalizedName().substring(5)) + i);
  61.       }
  62. }
  63. @SideOnly(Side.CLIENT)
  64. public IIcon getIcon(int par1, int par2)
  65. {
  66.       return icons[par2];
  67. }
  68.  
  69. @SideOnly(Side.CLIENT)
  70. public void getSubBlocks(Block par1, CreativeTabs par2CreativeTabs, List par3List)
  71. {
  72.  for (int var4 = 0; var4 < 3; ++var4)
  73.  {
  74.      par3List.add(new ItemStack(par1, 1, var4));
  75.  }
  76. }
  77.  
  78. protected boolean canThisPlantGrowOnThisBlock(Block par1)
  79. {
  80.     return par1 == Blocks.leaves;
  81. }
  82.  
  83.  
  84. /**
  85. * The type of render function that is called for this block
  86. */
  87. public int getRenderType()
  88. {
  89. return -2;
  90. }
  91.  
  92. /**
  93. * Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two
  94. * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
  95. */
  96. public boolean isOpaqueCube()
  97. {
  98. return false;
  99. }
  100.  
  101. /**
  102. * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
  103. */
  104. public boolean renderAsNormalBlock()
  105. {
  106. return false;
  107. }
  108.  
  109. public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
  110. {
  111.     int rotation = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 2.5D) & 3;
  112.     world.setBlock(i, j, k, this, rotation - 1, rotation - 1);
  113. }
  114.  
  115. public TileEntity createNewTileEntity(World par1World, int i)
  116. {
  117. return new TileEntityOrnament();
  118. }
  119.  
  120. public int damageDropped(int par1)
  121. {
  122.     return par1;
  123.  
  124. }
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement