Advertisement
palmerjj01

BlockTable

Oct 21st, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. package palmerjj01.YoshiCraft.Blocks;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.block.BlockContainer;
  5. import net.minecraft.block.material.Material;
  6. import net.minecraft.client.renderer.texture.IIconRegister;
  7. import net.minecraft.entity.EntityLivingBase;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.tileentity.TileEntity;
  10. import net.minecraft.util.MathHelper;
  11. import net.minecraft.world.World;
  12. import palmerjj01.YoshiCraft.TileEntity.TileEntityTongueTable;
  13. import palmerjj01.YoshiCraft.TileEntity.TileEntityYoshiOven;
  14. import cpw.mods.fml.relauncher.Side;
  15. import cpw.mods.fml.relauncher.SideOnly;
  16.  
  17. public class BlockTable extends BlockContainer {
  18.  
  19. public BlockTable(Material material) {
  20. super(material);
  21.  
  22. this.setHardness(2.0F);
  23. this.setResistance(5.0F);
  24.  
  25. }
  26.  
  27. public int getRenderType() {
  28. return -1;
  29. }
  30.  
  31. public boolean isOpaqueCube() {
  32. return false;
  33. }
  34.  
  35. public boolean renderAsNormalBlock() {
  36. return false;
  37. }
  38.  
  39. @Override
  40. public TileEntity createNewTileEntity(World var1, int var2) {
  41. return new TileEntityTongueTable();
  42. }
  43.  
  44. @SideOnly(Side.CLIENT)
  45. public void registerBlockIcons(IIconRegister iconRegister) {
  46. this.blockIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(5));
  47. }
  48.  
  49. public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) {
  50. int l = MathHelper.floor_double((double)(entityplayer.rotationYaw * 4.0F / 360.F) + 0.5D) & 3;
  51.  
  52. if(l == 0) {
  53. world.setBlockMetadataWithNotify(x, y, z, 2, 2);
  54. }
  55.  
  56. if(l == 1) {
  57. world.setBlockMetadataWithNotify(x, y, z, 5, 2);
  58. }
  59.  
  60. if(l == 2) {
  61. world.setBlockMetadataWithNotify(x, y, z, 3, 2);
  62. }
  63.  
  64. if(l == 3) {
  65. world.setBlockMetadataWithNotify(x, y, z, 4, 2);
  66. }
  67.  
  68. if(itemstack.hasDisplayName()) {
  69. ((TileEntityYoshiOven)world.getTileEntity(x, y, z)).setGuiDisplayName(itemstack.getDisplayName());
  70. }
  71. }
  72.  
  73. private void setDefaultDirection(World world, int x, int y, int z) {
  74. if(!world.isRemote) {
  75. Block b1 = world.getBlock(x, y, z - 1);
  76. Block b2 = world.getBlock(x, y, z + 1);
  77. Block b3 = world.getBlock(x - 1, y, z);
  78. Block b4 = world.getBlock(x + 1, y, z);
  79.  
  80. byte b0 = 3;
  81.  
  82. if(b1.func_149730_j() && !b2.func_149730_j()) {
  83. b0 = 3;
  84. }
  85.  
  86. if(b2.func_149730_j() && !b1.func_149730_j()) {
  87. b0 = 2;
  88. }
  89.  
  90. if(b3.func_149730_j() && !b4.func_149730_j()) {
  91. b0 = 5;
  92. }
  93.  
  94. if(b4.func_149730_j() && !b3.func_149730_j()) {
  95. b0 = 4;
  96. }
  97.  
  98. world.setBlockMetadataWithNotify(x, y, x, b0, 2);
  99. }
  100.  
  101. }
  102.  
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement