Advertisement
Guest User

Block Code

a guest
Nov 17th, 2013
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.61 KB | None | 0 0
  1. package mod.xtronius.bc_mod.blocks.Special;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import mod.xtronius.bc_mod.bc_mod;
  7. import mod.xtronius.bc_mod.lib.Reference;
  8. import net.minecraft.block.Block;
  9. import net.minecraft.block.BlockGlass;
  10. import net.minecraft.block.material.Material;
  11. import net.minecraft.client.renderer.texture.IconRegister;
  12. import net.minecraft.entity.player.EntityPlayer;
  13. import net.minecraft.item.Item;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraft.util.Icon;
  16. import net.minecraft.world.IBlockAccess;
  17.  
  18. public class BlockSifterStructuring extends BlockGlass
  19. {
  20.  
  21. public static boolean connectedTexture = true;
  22.  
  23. public static Icon[] textures = new Icon[47];
  24.  
  25. public static int[] textureRefByID = { 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1,
  26. 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19,
  27. 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27,
  28. 14, 4, 4, 5, 5, 4, 4, 5, 5, 17, 17, 22, 26, 17, 17, 22, 26, 16, 16, 20,
  29. 20, 16, 16, 28, 28, 21, 21, 46, 42, 21, 21, 43, 38, 4, 4, 5, 5, 4, 4,
  30. 5, 5, 9, 9, 30, 12, 9, 9, 30, 12, 16, 16, 20, 20, 16, 16, 28, 28, 25,
  31. 25, 45, 37, 25, 25, 40, 32, 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3,
  32. 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 0, 0,
  33. 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13,
  34. 13, 2, 2, 23, 31, 2, 2, 27, 14, 4, 4, 5, 5, 4, 4, 5, 5, 17, 17, 22, 26,
  35. 17, 17, 22, 26, 7, 7, 24, 24, 7, 7, 10, 10, 29, 29, 44, 41, 29, 29, 39,
  36. 33, 4, 4, 5, 5, 4, 4, 5, 5, 9, 9, 30, 12, 9, 9, 30, 12, 7, 7, 24, 24,
  37. 7, 7, 10, 10, 8, 8, 36, 35, 8, 8, 34, 11 };
  38.  
  39. public BlockSifterStructuring()
  40. {
  41. super(502, Material.glass, false);
  42. setHardness(0.6F);
  43. setResistance(2.0F);
  44. setCreativeTab(bc_mod.tabsBC_ModSpecialItemsAndBlocks);
  45. setStepSound(soundGlassFootstep);
  46. }
  47.  
  48. public int idDropped(int par1, Random par2Random, int par3)
  49. {
  50. return Item.stick.itemID;
  51. }
  52.  
  53. public int quantityDropped(Random par1Random)
  54. {
  55. return 1 + par1Random.nextInt(4);
  56. }
  57.  
  58.  
  59.  
  60. public void registerIcons(IconRegister iconRegistry)
  61. {
  62. for (int i = 0; i < 47; i++) textures[i] = iconRegistry.registerIcon("bc_mod:" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1) + "_" + i++);
  63. }
  64.  
  65. public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
  66. {
  67.  
  68. if(connectedTexture){
  69.  
  70. boolean[] bitMatrix = new boolean[8];
  71.  
  72. if (side == 0 || side == 1)
  73. {
  74. bitMatrix[0] = world.getBlockId(x-1, y, z-1) == this.blockID;
  75. bitMatrix[1] = world.getBlockId(x, y, z-1) == this.blockID;
  76. bitMatrix[2] = world.getBlockId(x+1, y, z-1) == this.blockID;
  77. bitMatrix[3] = world.getBlockId(x-1, y, z) == this.blockID;
  78. bitMatrix[4] = world.getBlockId(x+1, y, z) == this.blockID;
  79. bitMatrix[5] = world.getBlockId(x-1, y, z+1) == this.blockID;
  80. bitMatrix[6] = world.getBlockId(x, y, z+1) == this.blockID;
  81. bitMatrix[7] = world.getBlockId(x+1, y, z+1) == this.blockID;
  82. }
  83. if (side == 2 || side == 3)
  84. {
  85. bitMatrix[0] = world.getBlockId(x+(side==2?1:-1), y+1, z) == this.blockID;
  86. bitMatrix[1] = world.getBlockId(x, y+1, z) == this.blockID;
  87. bitMatrix[2] = world.getBlockId(x+(side==3?1:-1), y+1, z) == this.blockID;
  88. bitMatrix[3] = world.getBlockId(x+(side==2?1:-1), y, z) == this.blockID;
  89. bitMatrix[4] = world.getBlockId(x+(side==3?1:-1), y, z) == this.blockID;
  90. bitMatrix[5] = world.getBlockId(x+(side==2?1:-1), y-1, z) == this.blockID;
  91. bitMatrix[6] = world.getBlockId(x, y-1, z) == this.blockID;
  92. bitMatrix[7] = world.getBlockId(x+(side==3?1:-1), y-1, z) == this.blockID;
  93. }
  94. if (side == 4 || side == 5)
  95. {
  96. bitMatrix[0] = world.getBlockId(x, y+1, z+(side==5?1:-1)) == this.blockID;
  97. bitMatrix[1] = world.getBlockId(x, y+1, z) == this.blockID;
  98. bitMatrix[2] = world.getBlockId(x, y+1, z+(side==4?1:-1)) == this.blockID;
  99. bitMatrix[3] = world.getBlockId(x, y, z+(side==5?1:-1)) == this.blockID;
  100. bitMatrix[4] = world.getBlockId(x, y, z+(side==4?1:-1)) == this.blockID;
  101. bitMatrix[5] = world.getBlockId(x, y-1, z+(side==5?1:-1)) == this.blockID;
  102. bitMatrix[6] = world.getBlockId(x, y-1, z) == this.blockID;
  103. bitMatrix[7] = world.getBlockId(x, y-1, z+(side==4?1:-1)) == this.blockID;
  104. }
  105.  
  106. int idBuilder = 0;
  107.  
  108. for (int i = 0; i <= 7; i++) idBuilder = idBuilder + (bitMatrix[i]?(i==0?1:(i==1?2:(i==2?4:(i==3?8:(i==4?16:(i==5?32:(i==6?64:128))))))):0);
  109.  
  110. return idBuilder>255||idBuilder<0?textures[0]:textures[textureRefByID[idBuilder]];
  111.  
  112. }
  113. return textures[0];
  114. }
  115.  
  116. public Icon getIcon(int side, int meta)
  117. {
  118. return textures[0];
  119. }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement