예제 #1
0
 public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
   MovingObjectPosition movingobjectposition = func_40402_a(world, entityplayer, true);
   if (movingobjectposition == null) {
     return itemstack;
   }
   if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) {
     int i = movingobjectposition.blockX;
     int j = movingobjectposition.blockY;
     int k = movingobjectposition.blockZ;
     if (!world.canMineBlock(entityplayer, i, j, k)) {
       return itemstack;
     }
     if (!entityplayer.func_35190_e(i, j, k)) {
       return itemstack;
     }
     if (world.getBlockMaterial(i, j, k) == Material.water
         && world.getBlockMetadata(i, j, k) == 0
         && world.isAirBlock(i, j + 1, k)) {
       world.setBlockWithNotify(i, j + 1, k, Block.waterlily.blockID);
       if (!entityplayer.capabilities.depleteBuckets) {
         itemstack.stackSize--;
       }
     }
   }
   return itemstack;
 }
예제 #2
0
 public boolean onItemUse(
     ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
   if (l != 1) {
     return false;
   }
   j++;
   BlockBed blockbed = (BlockBed) Block.bed;
   int i1 = MathHelper.floor_double((double) ((entityplayer.rotationYaw * 4F) / 360F) + 0.5D) & 3;
   byte byte0 = 0;
   byte byte1 = 0;
   if (i1 == 0) {
     byte1 = 1;
   }
   if (i1 == 1) {
     byte0 = -1;
   }
   if (i1 == 2) {
     byte1 = -1;
   }
   if (i1 == 3) {
     byte0 = 1;
   }
   if (!entityplayer.func_35190_e(i, j, k)
       || !entityplayer.func_35190_e(i + byte0, j, k + byte1)) {
     return false;
   }
   if (world.isAirBlock(i, j, k)
       && world.isAirBlock(i + byte0, j, k + byte1)
       && world.isBlockNormalCube(i, j - 1, k)
       && world.isBlockNormalCube(i + byte0, j - 1, k + byte1)) {
     world.setBlockAndMetadataWithNotify(i, j, k, blockbed.blockID, i1);
     world.setBlockAndMetadataWithNotify(i + byte0, j, k + byte1, blockbed.blockID, i1 + 8);
     itemstack.stackSize--;
     return true;
   } else {
     return false;
   }
 }