Advertisement
Tenyar97

BedPlacer

Jan 1st, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. package assets.betterdefense.common;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.block.BlockBed;
  5. import net.minecraft.client.renderer.texture.IconRegister;
  6. import net.minecraft.entity.Entity;
  7. import net.minecraft.entity.EntityList;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.item.Item;
  10. import net.minecraft.item.ItemBed;
  11. import net.minecraft.item.ItemBlock;
  12. import net.minecraft.item.ItemStack;
  13. import net.minecraft.potion.Potion;
  14. import net.minecraft.potion.PotionEffect;
  15. import net.minecraft.tileentity.TileEntity;
  16. import net.minecraft.util.DamageSource;
  17. import net.minecraft.util.MathHelper;
  18. import net.minecraft.world.World;
  19.  
  20. public class BedPlacer extends Item
  21.  
  22. {
  23.  
  24. public BedPlacer(int par1) {
  25. super(par1);
  26. this.setCreativeTab(BetterDefense.TabBetterDefense);
  27. }
  28.  
  29. public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
  30. {
  31. if (par3World.isRemote)
  32. {
  33. return true;
  34. }
  35. else if (par7 != 1)
  36. {
  37. return false;
  38. }
  39. else
  40. {
  41. ++par5;
  42. My_Bed MyBed = (My_Bed)BetterDefense.MyBed;
  43. int i1 = MathHelper.floor_double((double)(par2EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
  44. byte b0 = 0;
  45. byte b1 = 0;
  46.  
  47. if (i1 == 0)
  48. {
  49. b1 = 1;
  50. }
  51.  
  52. if (i1 == 1)
  53. {
  54. b0 = -1;
  55. }
  56.  
  57. if (i1 == 2)
  58. {
  59. b1 = -1;
  60. }
  61.  
  62. if (i1 == 3)
  63. {
  64. b0 = 1;
  65. }
  66.  
  67. if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4 + b0, par5, par6 + b1, par7, par1ItemStack))
  68. {
  69. if (par3World.getBlockId(par4, par5 - 1, par6) == Block.grass.blockID)
  70. {
  71. par3World.setBlock(par4, par5, par6, MyBed.blockID, i1, 3);
  72.  
  73. if (par3World.getBlockId(par4, par5, par6) == MyBed.blockID)
  74. {
  75. par3World.setBlock(par4 + b0, par5, par6 + b1, MyBed.blockID, i1 + 8, 3);
  76. }
  77.  
  78. --par1ItemStack.stackSize;
  79. return true;
  80. }
  81. else
  82. {
  83. return false;
  84. }
  85. }
  86. else
  87. {
  88. return false;
  89. }
  90. }
  91. }
  92.  
  93.  
  94. @Override
  95. public void registerIcons(IconRegister par1IconRegister)
  96. {
  97. this.itemIcon = par1IconRegister.registerIcon("betterdefense:W.I.P");
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement