Advertisement
Guest User

Untitled

a guest
Jun 12th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. package com.vanityblocks.Blocks;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import net.minecraft.block.Block;
  7. import net.minecraft.block.BlockRedstoneLight;
  8. import net.minecraft.client.renderer.texture.IIconRegister;
  9. import net.minecraft.creativetab.CreativeTabs;
  10. import net.minecraft.item.Item;
  11. import net.minecraft.item.ItemStack;
  12. import net.minecraft.util.IIcon;
  13. import net.minecraft.world.World;
  14.  
  15. import com.vanityblocks.VanityBlocks;
  16. import com.vanityblocks.Registrations.RedstoneLampRegistrations;
  17.  
  18. import cpw.mods.fml.relauncher.Side;
  19. import cpw.mods.fml.relauncher.SideOnly;
  20.  
  21. public class RedstonedimLamps extends BlockRedstoneLight {
  22. // private final boolean powered;
  23. private final boolean field_150171_a;
  24.  
  25. public RedstonedimLamps(int par1, boolean par2) {
  26. super(par2);
  27. this.field_150171_a = par2;
  28. setCreativeTab(VanityBlocks.tabvanityblocks);
  29. }
  30.  
  31. @SideOnly(Side.CLIENT)
  32. private IIcon[] icons;
  33.  
  34. @SideOnly(Side.CLIENT)
  35. // @Override
  36. public void registerBlockIcons(IIconRegister par1IconRegister) {
  37. icons = new IIcon[9];
  38. icons[0] = par1IconRegister
  39. .registerIcon("vanityblocks:redstonelamps/blackLamp");
  40. icons[1] = par1IconRegister
  41. .registerIcon("vanityblocks:redstonelamps/redLamp");
  42. icons[2] = par1IconRegister
  43. .registerIcon("vanityblocks:redstonelamps/greenLamp");
  44. icons[3] = par1IconRegister
  45. .registerIcon("vanityblocks:redstonelamps/brownLamp");
  46. icons[4] = par1IconRegister
  47. .registerIcon("vanityblocks:redstonelamps/blueLamp");
  48. icons[5] = par1IconRegister
  49. .registerIcon("vanityblocks:redstonelamps/purpleLamp");
  50. icons[6] = par1IconRegister
  51. .registerIcon("vanityblocks:redstonelamps/pinkLamp");
  52. icons[7] = par1IconRegister
  53. .registerIcon("vanityblocks:redstonelamps/lightBlueLamp");
  54. icons[8] = par1IconRegister
  55. .registerIcon("vanityblocks:redstonelamps/magentaLamp");
  56. }
  57.  
  58. @Override
  59. public IIcon getIcon(int side, int metadata) {
  60.  
  61. if (metadata == 0) {
  62. return icons[0];
  63. }
  64. if (metadata == 1) {
  65. return icons[1];
  66. }
  67. if (metadata == 2) {
  68. return icons[2];
  69. }
  70. if (metadata == 3) {
  71. return icons[3];
  72. }
  73. if (metadata == 4) {
  74. return icons[4];
  75. }
  76. if (metadata == 5) {
  77. return icons[5];
  78. }
  79. if (metadata == 6) {
  80. return icons[6];
  81. }
  82. if (metadata == 7) {
  83. return icons[7];
  84. }
  85. if (metadata == 8) {
  86. return icons[8];
  87. }
  88. return blockIcon;
  89. }
  90.  
  91. @Override
  92. public void onBlockAdded(World par1World, int x, int y, int z) {
  93. int metadata = par1World.getBlockMetadata(x, y, z);
  94.  
  95. if (!par1World.isRemote) {
  96. if (this.field_150171_a
  97. && !par1World.isBlockIndirectlyGettingPowered(x, y, z)) {
  98. par1World.scheduleBlockUpdate(x, y, z,
  99. RedstoneLampRegistrations.RedstoneLampLit, metadata);
  100. } else if (!this.field_150171_a
  101. && par1World.isBlockIndirectlyGettingPowered(x, y, z)) {
  102. par1World.setBlock(x, y, z,
  103. RedstoneLampRegistrations.RedstoneLampLit, metadata, 3);
  104. }
  105. }
  106. }
  107.  
  108. /**
  109. * Lets the block know when one of its neighbor changes. Doesn't know which
  110. * neighbor changed (coordinates passed are their own) Args: x, y, z,
  111. * neighbor blockID
  112. */
  113. @Override
  114. /**
  115. * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
  116. * their own) Args: x, y, z, neighbor Block
  117. */
  118. public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_,
  119. int p_149695_3_, int p_149695_4_, Block p_149695_5_) {
  120. int metadata = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_,
  121. p_149695_4_);
  122. if (!p_149695_1_.isRemote) {
  123. if (this.field_150171_a
  124. && !p_149695_1_.isBlockIndirectlyGettingPowered(
  125. p_149695_2_, p_149695_3_, p_149695_4_)) {
  126. p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_,
  127. p_149695_4_, RedstoneLampRegistrations.RedstoneLampLit,
  128. metadata);
  129. } else if (!this.field_150171_a
  130. && p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_,
  131. p_149695_3_, p_149695_4_)) {
  132. p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_,
  133. RedstoneLampRegistrations.RedstoneLampLit, metadata, 2);
  134. }
  135. }
  136. }
  137.  
  138. /**
  139. * Ticks the block if it's been scheduled
  140. */
  141. @Override
  142. public void updateTick(World par1World, int x, int y, int z,
  143. Random par5Random) {
  144. int metadata = par1World.getBlockMetadata(x, y, z);
  145.  
  146. if (!par1World.isRemote && this.field_150171_a
  147. && !par1World.isBlockIndirectlyGettingPowered(x, y, z)) {
  148. par1World.setBlock(x, y, z,
  149. RedstoneLampRegistrations.RedstoneLampLit, metadata, 3);
  150. }
  151. }
  152.  
  153. @Override
  154. public int damageDropped(int metadata) {
  155. return metadata;
  156. }
  157.  
  158. // @Override
  159. public int idPicked(World par1World, int x, int y, int z) {
  160. int metadata = par1World.getBlockMetadata(x, y, z);
  161. return metadata;
  162. }
  163.  
  164. @SideOnly(Side.CLIENT)
  165. public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_,
  166. List p_149666_3_) {
  167. p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0));
  168. p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1));
  169. p_149666_3_.add(new ItemStack(p_149666_1_, 1, 2));
  170. p_149666_3_.add(new ItemStack(p_149666_1_, 1, 3));
  171. p_149666_3_.add(new ItemStack(p_149666_1_, 1, 4));
  172. p_149666_3_.add(new ItemStack(p_149666_1_, 1, 5));
  173. p_149666_3_.add(new ItemStack(p_149666_1_, 1, 6));
  174. p_149666_3_.add(new ItemStack(p_149666_1_, 1, 7));
  175. p_149666_3_.add(new ItemStack(p_149666_1_, 1, 8));
  176. }
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement