Guest User

Item

a guest
Jan 28th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. package com.noshmod.item.itemblock.horror;
  2.  
  3. import java.util.List;
  4.  
  5. import com.noshmod.block.BaseBlock;
  6.  
  7. import net.minecraft.block.Block;
  8. import net.minecraft.entity.player.EntityPlayer;
  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.  
  15. import cpw.mods.fml.relauncher.Side;
  16. import cpw.mods.fml.relauncher.SideOnly;
  17.  
  18. public class ItemPaintingChangeBlock extends Item
  19. {
  20. public ItemPaintingChangeBlock()
  21. {
  22. this.maxStackSize = 1;
  23. }
  24.  
  25. /**
  26. * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
  27. * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
  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 (par7 != 1)
  32. {
  33. return false;
  34. }
  35. else
  36. {
  37. ++par5;
  38. Block block;
  39.  
  40.  
  41. block = BaseBlock.paintingChange;
  42.  
  43.  
  44. if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack))
  45. {
  46. if (!block.canPlaceBlockAt(par3World, par4, par5, par6))
  47. {
  48. return false;
  49. }
  50. else
  51. {
  52. int i1 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
  53. placeDoorBlock(par3World, par4, par5, par6, i1, block);
  54. --par1ItemStack.stackSize;
  55. return true;
  56. }
  57. }
  58. else
  59. {
  60. return false;
  61. }
  62. }
  63. }
  64.  
  65. public static void placeDoorBlock(World p_150924_0_, int p_150924_1_, int p_150924_2_, int p_150924_3_, int p_150924_4_, Block p_150924_5_)
  66. {
  67. byte b0 = 0;
  68. byte b1 = 0;
  69.  
  70. if (p_150924_4_ == 0)
  71. {
  72. b1 = 1;
  73. }
  74.  
  75. if (p_150924_4_ == 1)
  76. {
  77. b0 = -1;
  78. }
  79.  
  80. if (p_150924_4_ == 2)
  81. {
  82. b1 = -1;
  83. }
  84.  
  85. if (p_150924_4_ == 3)
  86. {
  87. b0 = 1;
  88. }
  89.  
  90. int i1 = (p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_, p_150924_3_ - b1).isNormalCube() ? 1 : 0) + (p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_ + 1, p_150924_3_ - b1).isNormalCube() ? 1 : 0);
  91. int j1 = (p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_, p_150924_3_ + b1).isNormalCube() ? 1 : 0) + (p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_ + 1, p_150924_3_ + b1).isNormalCube() ? 1 : 0);
  92. boolean flag = p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_, p_150924_3_ - b1) == p_150924_5_ || p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_ + 1, p_150924_3_ - b1) == p_150924_5_;
  93. boolean flag1 = p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_, p_150924_3_ + b1) == p_150924_5_ || p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_ + 1, p_150924_3_ + b1) == p_150924_5_;
  94. boolean flag2 = false;
  95.  
  96. if (flag && !flag1)
  97. {
  98. flag2 = true;
  99. }
  100. else if (j1 > i1)
  101. {
  102. flag2 = true;
  103. }
  104.  
  105. p_150924_0_.setBlock(p_150924_1_, p_150924_2_, p_150924_3_, p_150924_5_, p_150924_4_, 2);
  106. p_150924_0_.setBlock(p_150924_1_, p_150924_2_ + 1, p_150924_3_, p_150924_5_, 8 | (flag2 ? 1 : 0), 2);
  107. p_150924_0_.notifyBlocksOfNeighborChange(p_150924_1_, p_150924_2_, p_150924_3_, p_150924_5_);
  108. p_150924_0_.notifyBlocksOfNeighborChange(p_150924_1_, p_150924_2_ + 1, p_150924_3_, p_150924_5_);
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment