Advertisement
Guest User

Render Block

a guest
Nov 18th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. package mod.xtronius.bc_mod.blocks.Special;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import mod.xtronius.bc_mod.bc_mod;
  6. import mod.xtronius.bc_mod.tileEntity.TileEntitySifterPipe;
  7. import mod.xtronius.bc_mod.tileEntity.TileEntitySifterVentalator;
  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.IconRegister;
  12. import net.minecraft.entity.EntityLivingBase;
  13. import net.minecraft.item.ItemStack;
  14. import net.minecraft.tileentity.TileEntity;
  15. import net.minecraft.util.MathHelper;
  16. import net.minecraft.world.World;
  17.  
  18. public class BlockSifterVentalator extends BlockContainer{
  19.  
  20. public BlockSifterVentalator(int id) {
  21. super(id, Material.iron);
  22.  
  23. this.setCreativeTab(bc_mod.tabsBC_ModSpecialItemsAndBlocks);
  24.  
  25.  
  26. }
  27.  
  28. @Override
  29. public TileEntity createNewTileEntity(World world) {
  30. return new TileEntitySifterVentalator();
  31. }
  32.  
  33.  
  34. public int getRenderType(){
  35. return -1;
  36. }
  37.  
  38. public boolean isOpaqueCube(){
  39. return false;
  40. }
  41. public boolean RenderAsNormalBlock(){
  42. return false;
  43. }
  44.  
  45. @Override
  46. @SideOnly(Side.CLIENT)
  47.  
  48. public void registerIcons(IconRegister iconRegister){
  49. blockIcon = iconRegister.registerIcon("bc_mod:" + (this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)));;
  50. }
  51. private void setDefaultDirection(World world, int x, int y, int z) {
  52. if(!world.isRemote) {
  53. int zNeg = world.getBlockId(x, y, z - 1);
  54. int zPos = world.getBlockId(x, y, z + 1);
  55. int xNeg = world.getBlockId(x - 1, y, z);
  56. int xPos = world.getBlockId(x + 1, y, z);
  57. byte meta = 3;
  58.  
  59. if(Block.opaqueCubeLookup[xNeg] && !Block.opaqueCubeLookup[xPos]) meta = 5;
  60. if(Block.opaqueCubeLookup[xPos] && !Block.opaqueCubeLookup[xNeg]) meta = 4;
  61. if(Block.opaqueCubeLookup[zNeg] && !Block.opaqueCubeLookup[zPos]) meta = 3;
  62. if(Block.opaqueCubeLookup[zPos] && !Block.opaqueCubeLookup[zNeg]) meta = 2;
  63.  
  64. world.setBlockMetadataWithNotify(x, y, z, meta, 2);
  65. }
  66. }
  67.  
  68.  
  69. public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack) {
  70. int rotation = MathHelper.floor_double((double)(entity.rotationYaw * 4F / 360F) + 0.5D) & 3;
  71.  
  72. if(rotation == 0) {
  73. world.setBlockMetadataWithNotify(x, y, z, 2, 2);
  74. }
  75.  
  76. if(rotation == 1) {
  77. world.setBlockMetadataWithNotify(x, y, z, 5, 2);
  78. }
  79.  
  80. if(rotation == 2) {
  81. world.setBlockMetadataWithNotify(x, y, z, 3, 2);
  82. }
  83.  
  84. if(rotation == 3) {
  85. world.setBlockMetadataWithNotify(x, y, z, 4, 2);
  86. }
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement