Guest User

ItemBlueBed.java

a guest
Dec 17th, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. package com.living.mod.beds;
  2.  
  3. import com.living.mod.Living;
  4.  
  5. import net.minecraft.block.BlockBed;
  6. import net.minecraft.creativetab.CreativeTabs;
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.init.Blocks;
  9. import net.minecraft.item.Item;
  10. import net.minecraft.item.ItemStack;
  11. import net.minecraft.util.MathHelper;
  12. import net.minecraft.world.World;
  13.  
  14. public class ItemBlueBed extends Item
  15. {
  16. private static final String __OBFID = "CL_00001771";
  17.  
  18. public ItemBlueBed()
  19. {
  20. this.setCreativeTab(Living.livingTab);
  21. }
  22.  
  23. /**
  24. * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
  25. * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
  26. */
  27. public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
  28. {
  29. if (p_77648_3_.isRemote)
  30. {
  31. return true;
  32. }
  33. else if (p_77648_7_ != 1)
  34. {
  35. return false;
  36. }
  37. else
  38. {
  39. ++p_77648_5_;
  40. BlockBlueBed blockbed = (BlockBlueBed)Living.blockBlueBed;
  41. int i1 = MathHelper.floor_double((double)(p_77648_2_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
  42. byte b0 = 0;
  43. byte b1 = 0;
  44.  
  45. if (i1 == 0)
  46. {
  47. b1 = 1;
  48. }
  49.  
  50. if (i1 == 1)
  51. {
  52. b0 = -1;
  53. }
  54.  
  55. if (i1 == 2)
  56. {
  57. b1 = -1;
  58. }
  59.  
  60. if (i1 == 3)
  61. {
  62. b0 = 1;
  63. }
  64.  
  65. if (p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_) && p_77648_2_.canPlayerEdit(p_77648_4_ + b0, p_77648_5_, p_77648_6_ + b1, p_77648_7_, p_77648_1_))
  66. {
  67. if (p_77648_3_.isAirBlock(p_77648_4_, p_77648_5_, p_77648_6_) && p_77648_3_.isAirBlock(p_77648_4_ + b0, p_77648_5_, p_77648_6_ + b1) && World.doesBlockHaveSolidTopSurface(p_77648_3_, p_77648_4_, p_77648_5_ - 1, p_77648_6_) && World.doesBlockHaveSolidTopSurface(p_77648_3_, p_77648_4_ + b0, p_77648_5_ - 1, p_77648_6_ + b1))
  68. {
  69. p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, blockbed, i1, 3);
  70.  
  71. if (p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_) == blockbed)
  72. {
  73. p_77648_3_.setBlock(p_77648_4_ + b0, p_77648_5_, p_77648_6_ + b1, blockbed, i1 + 8, 3);
  74. }
  75.  
  76. --p_77648_1_.stackSize;
  77. return true;
  78. }
  79. else
  80. {
  81. return false;
  82. }
  83. }
  84. else
  85. {
  86. return false;
  87. }
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment